Re: Win32::OLE not support Ubuntu 14.10
by Corion (Patriarch) on Jun 11, 2015 at 09:55 UTC
|
Your OS is unsupported. Win32::OLE only works on Windows. Also, Win32::OLE needs Microsoft Word installed on the computer, which also only works on Windows.
| [reply] |
Re: Win32::OLE not support Ubuntu 14.10
by marto (Cardinal) on Jun 11, 2015 at 09:56 UTC
|
"Would you please give me any hints?"
Not everything is cross platform, the module name should be a hint. The Win32 namespace is for modules for the Microsoft Windows system, they won't run on other OS. See also Linux:: modules.
| [reply] |
Re: Win32::OLE not support Ubuntu 14.10
by marinersk (Priest) on Jun 11, 2015 at 11:16 UTC
|
As noted, the approach you found is Windows-dependent.
While not impossible, I do find it unlikely that you'll find a module out there which does the heavy lifting for you on this one.
I'd say your options are:
- Research the file format for word docs and roll your own solution;
- Same as above, but do the extra work to make it a CPAN module.
WARNING: Make sure this is legal and approved where you work -- in a tech company in the USA it is likely not (see Professional Employees and Works for Hire);
- Leave the problem unsolved;
- Update: Involve a Windows system with Word installed in the solution stream.
Good luck!
| [reply] |
|
Research the file format for word docs and roll your own solution
The "new" DOCX format is a ZIP archive of XML files and some other stuff. One of the XML files contains the document text. Archive::Zip can pack and unpack ZIP archives, XML::LibXML and some other modules can process XML.
The "older" DOC formats are binary blobs. No easy way there, sorry.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] |
|
Without looking up the format, I have to say that .DOCXfiles appear to be a cinch to edit. I just unzipped one, changed into the worddirectory it created, and popped open document.xml.
While it has the typical Microsoft Word overabundant nonlinear code insertion (I did hack one of the early .DOCformats way back when and remember that observation being applicable), the raw text components seem to be fairly consistently in between <w:t>and </w:t>tags. Before writing production code I'd want to research that a bit, of course, but for a quick-n-dirty word replacement I'd probably be willing to gamble.
Sample of what I found:
<w:t xml:space="preserve"> so we can order food. Please
include in your RSVP how many people will be attending.
</w:t>
| [reply] [d/l] [select] |
Re: Win32::OLE not support Ubuntu 14.10
by dasgar (Priest) on Jun 11, 2015 at 14:45 UTC
|
As others have pointed out, you're not going to be able to use Win32::OLE on Ubuntu.
I've got one idea that could work, but I have never looked into. You should be able to install LibreOffice, which can read most Word documents (see here for more details). I suspect (but don't know for sure) that there might be some kind of API available to automate LibreOffice - similar to using OLE to automate Office applications on Windows. If not, you should be able to open the Word document for viewing/editing.
This link might have some helpful information about automating LibreOffice.
| [reply] |
Re: Win32::OLE not support Ubuntu 14.10
by crusty_collins (Friar) on Jun 11, 2015 at 20:52 UTC
|
| [reply] |
Re: Win32::OLE not support Ubuntu 14.10
by Anonymous Monk on Jun 11, 2015 at 23:06 UTC
|
| [reply] |
Re: Win32::OLE not support Ubuntu 14.10
by PhillipHuang (Beadle) on Jun 12, 2015 at 02:17 UTC
|
Well, thanks for your kindly suggestion . Since it is so difficult to edit Microsoft Word in Ubuntu, I think if using PDF is another way. There are some PDF modules found on CPAN already. | [reply] |
|
| [reply] |
|
I am a pre-sales technical support engineer. Nearly everyday a lot of sales call me to provide product-combination and related price. I use Perl to create a CGI page to meet the requirement. By Perl, Excel has already been created automatically, while how to get the report(used to be Word format) is my question.
PS, the WORD report is based on some templates, so what I need to do is find and replace some key strings.
| [reply] |
|
|
PDF isn't meant to be edited. What about HTML?
| [reply] |