Free Support Forum - aspose.com

Unexpected table state at the end of the row. Please report this file to word@aspose.com

Hi,

I’m running Aspose.Word 1.6 (trial) and got this error when trying to open word template.

Unexpected table state at the end of the row. Please report this file to word@aspose.com.

at Aspose.Word.File.af.b(Int32 A_0)

at Aspose.Word.File.af.a(u A_0)

at Aspose.Word.File.af.c(Int32 A_0, Int32 A_1)

at Aspose.Word.File.af.b()

at Aspose.Word.File.x.a(bv A_0)

at Aspose.Word.Document.a(bv A_0)

at Aspose.Word.Document…ctor(String fileName)

at Aspose.Word.Word.Open(String fileName)


I know, I’m not on a latest 1.7 version, but thought you may still want to see it. Let me know if you want me to send you the file I have error with.


Thanks,

Svetlana

Hi, please send your document to me to word@aspose.com.

In latest Aspose.Word 1.7.4 the exception is not thrown. However, you are using a nested table and while Aspose.Word can read nested tables okay it cannot write them back in .DOC format properly.

If you have control over the file, I’d recommend you rework the document to avoid nested tables. It is reasonably easy to do as you can merge and split cells in any way you want.

How could merge and split accomplish this?

IMAGE HERE
Gender N %N
Male 10 50
Female 10 50
Totals 20 100

You need to use the "common denominator" approach.

In this case you need 4 rows and 4 columns. 4 cells in the first column should be vertically merged.

Word word = new Word();

Document doc = word.Open(@"X:\Aspose\Aspose.Word\Aspose.Word.Test\Testing\Blank.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

//1st row

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.First;

builder.Write("IMAGE HERE");

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Gender");

builder.InsertCell();

builder.Write("N");

builder.InsertCell();

builder.Write("N%");

builder.EndRow();

//2nd row

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.Previous;

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Male");

builder.InsertCell();

builder.Write("10");

builder.InsertCell();

builder.Write("50");

builder.EndRow();

//3rd row

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.Previous;

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Female");

builder.InsertCell();

builder.Write("10");

builder.InsertCell();

builder.Write("50");

builder.EndRow();

//4th row

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.Previous;

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Totals");

builder.InsertCell();

builder.Write("20");

builder.InsertCell();

builder.Write("100");

builder.EndRow();

builder.EndTable();

doc.Save(@"X:\Aspose\Aspose.Word\Aspose.Word.Test\Testing\V.doc");