Free Support Forum - aspose.com

Autoresize of cells in table

Hi - I am writing a generic routine that would populate a datatable in word. How do I autoresize the columns based on the contents? Please provide example code in c#

Thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think that you can try using FitText and WrapText properties. For example see the following code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.CellFormat.FitText = false;

builder.CellFormat.WrapText = false;

builder.InsertCell();

builder.Write("Aspose.Words test text ");

builder.EndRow();

builder.EndTable();

doc.Save(@"Test022\out.doc");

I hope this could help you.

If you are using a template then you can attach it here for testing.

Best regards.

Sorry your suggestion does not work

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Could you please attach your documents for investigating? I will try to find solution for you.

Best regards.