Error with table in word

Hi,

I’ve installed aspose.word and i’m trying the evaluation now. I wanted to make a table with the builder but when i save the word file and open it word gives me an error on the table. Word sks then to repair my file and then it works.

i’ve used this code :

public void BuildChessBoard(DocumentBuilder builder)
{
builder.Font.Size = 10;
builder.Font.Name = “Tahoma”;
builder.RowFormat.Height = 30;
builder.CellFormat.Width = 100;

foreach (Border border in builder.CellFormat.Borders)
{
border.LineStyle = LineStyle.Single;
border.LineWidth = 1;
border.Color = System.Drawing.Color.Black;
}
builder.InsertCell();
builder.Write(“Beschrijving”);
builder.InsertCell();
builder.Write(“Totaal bedrag”);
builder.InsertCell();
builder.Write(“Saldo”);
builder.InsertCell();
builder.Write(“Te Betalen”);
builder.EndRow();
}

Can someone help me with this problem.

Hi Tim,

I had a similar problem,

then I inserted a ParagraphBreak after finishing the table:


builder.InsertBreak(BreakType.ParagraphBreak);


Perhaps this helps you too.

Regards,
Mirjam

thx mirjam, now it works just fine

grtz,
Tim

Thanks, I’ll make a note on this and see if it needs a fix.

I would like to fix this one, but I cannot reproduce in my tests. Can you please let me know what MS Word version do you use, what sort of template document do you use and where in the template you insert the table? Maybe you can send the template document to word@aspose.com.

I’ve posted my Word2003 document and a codesnippet
which reproduces this on my system.

Regards,
Mirjam

Thanks, I’ve fixed this and it will go out in the next hotfix in a few days.

By the way, I’ve added another public DocumentBuilder.EndTable method to end a table explicitly. If you don’t call it, it will be called automatically, but it is better to call it explicitly after calling EndRow to move the cursor out of the table.

Romank, would it not now be useful to add an implicit DocumentBuilder.StartTable, thereby allowing us to start and end a table within the cell of another table ??

I cannot write nested tables out properly - the format is undocumented. If I resolve this later, I will allow creating nested tables in DocumentBuilder. At that time, yes, probably all start/end table/row/cell will need to be public.