N
nish
Hi,
I am struggling with this code. I am trying to create 3 separate
tables and print them in word, however I end up with 1 big table and 1
nested table inside and 1 more nested table within that.
Here is my code..
// CALL CreateTable - see method below
Word.Table oTable = CreateTable();
// Return with created table and add cell items
for (int y=0; y < dt.Columns.Count; y++)
{
for (int z=1; z <= 2; z++)
{
if (z == 1)
oTable.Cell(y,z).Range.Text = dt.Columns[y].ColumnName;
else
oTable.Cell(y,z).Range.Text = dt.Rows[x][y].ToString();
}
}
private Word.Table CreateTable()
{
// Create Table
object oTableBehavior =
Word.WdDefaultTableBehavior.wdWord9TableBehavior;
object oFitBehavior = Word.WdAutoFitBehavior.wdAutoFitFixed;
Word.Table oTable = oDoc.Tables.Add(oWord.Selection.Range, 24, 2,
ref oTableBehavior, ref oFitBehavior);
//Set table properties
object oStyle = "Table Grid";
oTable.set_Style(ref oStyle);
return oTable;
}
Please advise...
I am saving and activating this....
oDoc.SaveAs(ref fileName, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing);
oDoc = oWord.Documents.Open(ref fileName, ref oMissing, ref
readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref
oMissing, ref oMissing, ref oMissing, ref oMissing);
oWord.ShowMe();
oDoc.Activate();
// Exit out of word
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
Many thanks,
Nisha
I am struggling with this code. I am trying to create 3 separate
tables and print them in word, however I end up with 1 big table and 1
nested table inside and 1 more nested table within that.
Here is my code..
// CALL CreateTable - see method below
Word.Table oTable = CreateTable();
// Return with created table and add cell items
for (int y=0; y < dt.Columns.Count; y++)
{
for (int z=1; z <= 2; z++)
{
if (z == 1)
oTable.Cell(y,z).Range.Text = dt.Columns[y].ColumnName;
else
oTable.Cell(y,z).Range.Text = dt.Rows[x][y].ToString();
}
}
private Word.Table CreateTable()
{
// Create Table
object oTableBehavior =
Word.WdDefaultTableBehavior.wdWord9TableBehavior;
object oFitBehavior = Word.WdAutoFitBehavior.wdAutoFitFixed;
Word.Table oTable = oDoc.Tables.Add(oWord.Selection.Range, 24, 2,
ref oTableBehavior, ref oFitBehavior);
//Set table properties
object oStyle = "Table Grid";
oTable.set_Style(ref oStyle);
return oTable;
}
Please advise...
I am saving and activating this....
oDoc.SaveAs(ref fileName, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing);
oDoc = oWord.Documents.Open(ref fileName, ref oMissing, ref
readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref
oMissing, ref oMissing, ref oMissing, ref oMissing);
oWord.ShowMe();
oDoc.Activate();
// Exit out of word
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
Many thanks,
Nisha