builder.write(“some text”);
and i have method which return a Aspose.Word.Tables.Table
and i don’t know how can my table insert after text…
Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. There are two ways of building tables using Aspose.Words. You can build tables using DocumentBuilder as described here:
Also, you can build table using DOM (Document Object Model).
You are using both of these ways. I little bit changed your method, please see the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Test");
NakresliTabulku(builder, 10, 10);
// Save output document.
doc.Save(@"Test194\out.doc");
public void NakresliTabulku(DocumentBuilder db, int stlpcov, int riadkov)
{
db.StartTable();
db.RowFormat.Borders.Color = Color.Black;
db.RowFormat.Borders.LineStyle = LineStyle.Single;
db.RowFormat.Borders.LineWidth = 1;
for (int i = 0; i <= riadkov - 1; i++)
{
for (int j = 0; j <= stlpcov - 1; j++)
{
db.CellFormat.Borders.LineStyle = LineStyle.Single;
if (i % 2 == 0)
db.CellFormat.Shading.BackgroundPatternColor = Color.DarkGray;
else
db.CellFormat.Shading.BackgroundPatternColor = Color.LightGray;
if (i == 0 || j == 0)
db.CellFormat.Shading.BackgroundPatternColor = Color.Gray;
db.InsertCell();
}
db.EndRow();
}
}
Best regards,
i try this and it work… it’s a right creating word document?
Hi Michal,
Your code looks good, apart from you normally should be using document builder off a new document object. Please see the code below:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//generate table here
doc.Save(...);
Thanks,
Ok… thans for youre reply…