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

Free Support Forum - aspose.com

Weird Issue with templates

Attached is a test project.
in this project, I am adding a table to a cell.
here’s the weird.

I get the correct results ONLY IF I delete the first row in the table I am working on(I marked the line in the .cs file)

since I keep running into weird issues in my delphi program (for instance, I can make this work in a c# program, but using the same code in delphi is showing bad), I’m wondering if you can help me figure out what is wrong with the original table…
AsposeTest.zip (19.9 KB)

@conniem,

Thanks for your inquiry. Please note when you set cell width to some fixed value, you need to use FixedColumnWidths value of AutoFitBehavior. Please find updated code and resultant document for reference. Hopefully it will help you to accomplish the task.

    .....
    Document AsposeDocument = new Document(s + "\\test.dot");
    Aspose.Words.Tables.Row newRow;
    Aspose.Words.Tables.Table tbl = AsposeDocument.FirstSection.Body.Tables[0];
    //testing logic here
    newRow = AppendRow(AsposeDocument, tbl, 1);
    //tbl.Rows.RemoveAt(0);//for some reason, original row/cell causes yackage

    string cWidths = "110.699996948242" + (char)24 + "332.099990844727";
    newRow = AppendCells(AsposeDocument, tbl, cWidths);
    newRow = AppendCells(AsposeDocument, tbl, cWidths);
    // AsposeDocument.Save(s  + "\\result1.docx");

    Split(newRow.Cells[1], 2); 
    // AsposeDocument.Save(s  + "\\result2.docx");

    addTable(AsposeDocument, newRow.Cells[1], 3, 1);
    addTable(AsposeDocument, newRow.Cells[2], 3, 1);
    //end testing logic
    tbl.AllowAutoFit = true;
    tbl.AutoFit(AutoFitBeavior.FixedColumnWidths);
    AsposeDocument.Save(s  + "\\result.docx");
    .....

result.zip (7.2 KB)

Best Regards,

not sure why, but can’t seem to download result.zip.

I added those lines in both the AsposeTest and the AddTable procedures, and it made no difference.
I am using Aspose.Words 16.1.
is this an issue that is fixed in a later version?

@conniem

Thanks for your feedback. Please download and check output file from this link, we have used Aspose.Words for .NET 17.6. Please replace above code in you project and try latest version of Aspose.Words for .NET, it will resolve the issue.

Best Regards,

I have downloaded and installed aspose.words.dll 17.6.
I have added the lines of code

Split(newRow.Cells[1], 2); 
AsposeDocument.Save(s  + "\\result2.docx");

addTable(AsposeDocument, newRow.Cells[1], 3, 1);
addTable(AsposeDocument, newRow.Cells[2], 3, 1);
//end testing logic
tbl.AllowAutoFit = true;
tbl.AutoFit(Aspose.Words.Tables.AutoFitBehavior.FixedColumnWidths);

it is still not working , unless I remove the first row/cell

attached is my results.
result.Autofit is with that last line in place
result.no,autofit is with that last line commented, and is what I am also seeing in my delphi application…results.zip (14.5 KB)

@conniem

Thanks for your feedback. I am afraid it is working fine at my end. Please download the Program.cs, test at your end with Aspose.Words for .NET 17.6 and share the results.

We are sorry for the inconvenience.

Best Regards,

It’s definitely a version fix.
it recreates consistently using 16.1, but seems to be fixed in 17.6.
(I think I had the reference hinked up in the project or something).

What is the latest v 16 release, and where can I obtain that?

@conniem

Thanks for your feedback. It seems your issue has been fixed in some later version. It is always recommended to use latest version of Aspose.Words. As we maintain a single code base of Aspose.Words, so all the fixes and new features/enhancements are implemented in latest version of DLL.

Please feel free to contact us for any further assistance.

Best Regards,