How can I extract a specific table and copy from MS Word to Excel in Perl?
I have an MS Word 2003 file which contains several tables in it and I want to extract a specific table contents. For example, tables will be coming under some sections and I want to extract the contents of the table that are coming under section 6 alone and no other table contents, I want copy those contents to an new Excel sheet with formatting.
SECTION 4
开发者_如何学JAVA Table data Table data Table dataSECTION 5
Table data Table data Table dataSECTION 6
Table data # TABLE DATA TO BE EXTRACTED AND IMPORTED TO AN NEW EXCEL SHEET Table data # TABLE DATA TO BE EXTRACTED AND IMPORTED TO AN NEW EXCEL SHEET Table data # TABLE DATA TO BE EXTRACTED AND IMPORTED TO AN NEW EXCEL SHEETSECTION 7
Table data Table data Table dataUnless you are thinking of using something like antiword, your starting point is the Perl module Win32::OLE, which is installed as part of ActiveState Perl. You need to start a Microsoft Word application using OLE, open your document, then look at the Sections object of the document object, find the Section object which is your section six, then look at the Tables property of the Range property of the Section object, and find the Table object you want in it.
Copying to an Excel sheet involves something similar.
It's difficult to write a code example unless I have a document to work with, so I'm not even going to attempt that.
精彩评论