buildingbad.blogg.se

.net office interop copy word table to excel
.net office interop copy word table to excel













.net office interop copy word table to excel

The interop one wouldn't read the entire Word file, just pick up the table content, which you'd need to turn into an array, then drop into Excel. I'm not sure to which suggestion you're referring in this question. At that point, you can use System.IO.Packaging or the Open XML SDK to access the content. If you save a Word 2003 file as *.docx then it will be Word Open XML (the 2007/2010 kind of file format). Neither the Open XML SDK nor System.IO.Packaging is required. Essentially, the content of will be the same as the XML for the table that you can pull out of the 2003 document saved as *.xml. WordProcessingML is essentially a precursor of Word Open XML (much is very similar). xml, which will save it as an XML document in WordProcessingML. A Word 2003 binary file (*.doc) can also be saved with the extension. Word 2003 does have its own XML vocabulary that you can access while the file is open in Word 2003.

.net office interop copy word table to excel

Is this all to be done for Office 2003? (You propose saving in docx file format, but would this only be for the convenience of getting at the XML?) But you'd have to work through all the "extraneous" information (formatting, etc.) to boil the XML down to just the data in the tableīefore I can answer your questions I need to know more about the environment in which your solution will be used.Īre you doing this "server-side" or will there be user-interaction with Word/Excel? To change it to the new line character Excel uses (Char 10, as I recall).Īnother possibility would be to use to pick up the table content as XML, then transform that to an array.

.net office interop copy word table to excel

And before you dump it in Excel you'd need So you'd need to replace the paragraph marks with a different character before coverting the table to text. Problem if the cells contain new paragraph marks, as Word will use these as the record (row) delimiters. Read that string into memory, convert it to an array. That's usually pretty fast on the Excel side.Ī way to speed things up on the Word side is to use the ConvertTableToText method to convert the table to a delimited string (think of the content of a *.csv file for an example). The most efficient method, using the Interop, would probably be to extract the Word table information into an array, then assign the array to a Range in Excel.

.net office interop copy word table to excel

Open XML is a completely different file format (a zipped package of XML files).















.net office interop copy word table to excel