Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing and generating Microsoft Office 2007 files (.docx, .xlsx, .pptx)

I have a web project where I must import text and images from a user-supplied document, and one of the possible formats is Microsoft Office 2007. There's also a need to generate documents in this format.

The server runs CentOS 5.2 and has PHP/Perl/Python installed. I can execute local binaries and shell scripts if I must. We use Apache 2.2 but will be switching over to Nginx once it goes live.

What are my options? Anyone had experience with this?

like image 508
DV. Avatar asked Oct 06 '08 05:10

DV.


People also ask

Can Office 2007 read docx files?

If you are using Microsoft Office Word 2007 or Word 2010, you can open . docx or . docm files that were created in Word 2016 and 2013. However, a few newer features may not be supported in older versions or they may not be editable.

In which format word files are saved?

docx file is an Open XML formatted Microsoft Word document.

What is extension of ms word Excel and PowerPoint?

docx, . xlsx, and . pptx. These formats and file name extensions apply to Microsoft Word, Microsoft Excel, and Microsoft PowerPoint.


1 Answers

The Office 2007 file formats are open and well documented. Roughly speaking, all of the new file formats ending in "x" are zip compressed XML documents. For example:

To open a Word 2007 XML file Create a temporary folder in which to store the file and its parts.

Save a Word 2007 document, containing text, pictures, and other elements, as a .docx file.

Add a .zip extension to the end of the file name.

Double-click the file. It will open in the ZIP application. You can see the parts that comprise the file.

Extract the parts to the folder that you created previously.

The other file formats are roughly similar. I don't know of any open source libraries for interacting with them as yet - but depending on your exact requirements, it doesn't look too difficult to read and write simple documents. Certainly it should be a lot easier than with the older formats.

If you need to read the older formats, OpenOffice has an API and can read and write Office 2003 and older documents with more or less success.

like image 175
1800 INFORMATION Avatar answered Oct 02 '22 02:10

1800 INFORMATION