We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Generated Word table in new aspose falling out side of the page


I am trying to create word table through aspose word 11.7.0 version and the word table is falling out side of the page in word. This process working fine in older version of aspose word 10.2.0. I have attached both copy one is fine generated by aspose word 10.2.0 (Fixed Doc - With Aspose Word 10.2.docm) and one is broken which is generated by aspose word 11.7.0 (Broken Doc - With Aspose Word 11.7.docm).

I can manually fix it through Office Word itself by following these steps:

  1. Right click on the table
  2. Click on the AutoFit -> AutoFit to Window

I found Aspose has API to do similar task -> Table.AutoFit(AutoFitBehavior.AutoFitToWindow) I tried this one as well and looks like it fixed table width issue but broken some other stuff.

I also tried latest Aspose 11.11.0 and it didn’t work as well.

Please this post as well.

Please provide advise as soon as possible as this is argent issue for us.


Thanks for your inquiry. Please share the source code you used to generate these documents on your side here for testing. I will investigate the issue on my side and provide you more information.

Best regards,

Please try this code with the attached sample file.

const string excelFile = @"C:\Users\meetp\Desktop\New folder\Broken Doc - With Aspose 7.3.2.docm";
const string excelFile1 = @"C:\Users\meetp\Desktop\New folder\Broken Doc - With Aspose 7.3.2_1.docm";

var doc = new Document(excelFile);

var table = (Aspose.Words.Tables.Table) doc.GetChild(NodeType.Table, 0, true);


Expected behavior: After running this code table in excelFile1should be fitted into the page.
Actual behavior: Whole table is broken.

If I execute same command in MS Word it’s working fine follow these steps to test:

  1. Download the attached sample word file.
  2. Open excelFile in MS Word 2010
  3. Right click inside the table anywhere
  4. Click on the AutoFit -> AutoFit to Window (I attached the snapshot of this option here MSWordOption.png)

Actual behavior: Table is fitted inside the page.

I tried this with the latest Aspose.Word 11.11 version and same behavior.

Note: When I build this word table I am also setting wordTable.PreferredWidth = PreferredWidth.Auto; but no luck.

Please keep in mind I am looking for workaround for this issue for now.

Thanks - Meet


Thanks for your inquiry. In your case please specify the preferred width of table as 100% by using the following code snippet:

var doc =
new Document(excelFile);
var table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
table.PreferredWidth = PreferredWidth.FromPercent(100);

I hope, this helps.

Best regards,