C#NET2008 Add Row to Microsoft WORD 2003 Document Template Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    C#NET2008 Add Row to Microsoft WORD 2003 Document Template Table

    Hullo Wonderful Friends,
    I need your help again. Please help me.


    I am using WORD Template which has a table containing only 1 row and 5 columns. This row is for Column headers Text. description

    While using DataReader I tried to ADD row progressively during the WHILE LOOP command but this object objTable is causing Error Messages.

    Here are the objTable error messages:
    Error 1 No overload for method 'Add' takes '0' arguments
    Error 2 Use of unassigned local variable 'objTable'
    Code:
     Word.Table objTable;
     int intRow = 0;
    
     while (DR.Read())
     {
       objTable.Rows.Add();  < --- error 
    
       intRow += 1;
    
      objTable.Cell(intRow, 1).Range.Text = Convert.ToString(DR["OrderID"]);
      objTable.Cell(intRow, 2).Range.Text = Convert.ToString(DR["OrderDate"]);
      objTable.Cell(intRow, 3).Range.Text = Convert.ToString(DR["RequiredDate"]);
      objTable.Cell(intRow, 4).Range.Text = Convert.ToString(DR["ShippedDate"]);
     objTable.Cell(intRow, 5).Range.Text = Convert.ToString(DR["Freight"]);
     }
Working...