Home     Products      Support      Corporate     Sign In 

Support Knowledge Base, Article 1232

Product
WordWriter
Title
Backwards compatability issue with WordWriter version 3.8.1 - NumColumns property removed.
Problem

Before version 3.8.1, WordWriter's Table object had a NumColumns property which was problematic because it did not handle the common case of tables whose rows contain variable numbers of columns. If one used this property as an iterator, a runtime error would be received if the number of columns was not the same for every row.

Solution

To solve this problem, a new method has been added which takes the row number as a parameter, Table.GetNumColumns(row). The old NumColumns property has been removed from the API because it was confusing and could cause runtime exceptions (since there is no way to reliably determine at compile-time whether or not a given table is rectangular).

The following code example demonstrates the correct way to iterate through a table using the new method:

// instantiate WordWriter
WordApplication wa = new WordApplication();
// open a document that contains a table
Document doc = wa.Open("C:\\InputFiles\\DocumentWithTable.doc");
// get the first table in the document
SoftArtisans.OfficeWriter.WordWriter.Table table = 
   (SoftArtisans.OfficeWriter.WordWriter.Table)doc.get_Elements(Element.Type.Table)[0];
// iterate through the cells of the table and print out the text in each cell
for (int row = 0; row < table.NumRows; row++)
{
     for (int col = 0; col < table.GetNumColumns(row); col++)
     {
          SoftArtisans.OfficeWriter.WordWriterTableCell cell = table[row, col];      
          Response.Write("cell[" + row + "," + col + "]: " + cell.Text + "<br/>");
     }
}
Created : 3/8/2007 10:00:45 AM (last modified : 3/9/2007 9:57:47 AM)

Rate this article!

 
Comments



Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.

Site Map     |     Privacy Policy     |     Contact Us