Docx problem with dynamically generated table

Hi,

I’m dynamically generating a table using Aspose and somehow when I generate docx I’m not able to open the file. doc, pdf work fine. I’m attaching doc and docx versions of the document. I think the issue is related to row height but I’m not sure. Is this a known issue or am I doing something wrong?

Hello
Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (10.1.0) and the following code:

// Open DOC Document.
Document doc = new Document("C:\\Temp\\PSI123.doc");
// Save the result as DOCX.
doc.Save("C:\\Temp\\out.docx", SaveFormat.Dotx);

Could you please try using the latest version of Aspose.Words and let me know how it goes on your side?
Best regards,

Hi Andrey,

Thanks for your reply. The problem is not with every Docx document. It comes specifically when I try to generate a dynamic table. I checked the document.xml inside of the generated document and there was some problem in row height property (I’m using RowFormat.HeightRule = HeightRule.Auto). I was hoping this was a known problem and there was a workaround to it…

Hi
Thanks for your request. Could you please provide the code which will allow me to reproduce the problem on my side?
Best regards,

Hi Andrey,

These are the lines in document.xml(inside of the docx file) which creates the problem

<w:trPr>
<w:trHeight w:hRule="auto" />
<w:jc w:val="left" />
</w:trPr>

I’m attaching my code (its actually a .cs file but I changed the extension to be able to attach it). The problem is either due to LBREDynamicTablesWrite or LBREDynamicTablesD method.

Hello
Thank you for additional information. But I still cannot reproduce the problem on my side. I use the following simple code for testing:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.StartTable();
// Apply new row formatting
builder.RowFormat.HeightRule = HeightRule.Auto;
// Insert a cell
builder.InsertCell();
builder.Writeln("This is row 1 cell 1");
// Insert a cell
builder.InsertCell();
builder.Writeln("This is row 1 cell 2");
builder.EndRow();
builder.EndTable();
// Save the result as DOCX.
doc.Save("C:\\Temp\\out.docx", SaveFormat.Docx);

Could you please create a simple application which will allow me to reproduce the problem on my side? I will check the problem and provide you more information.
Also, have you tried using the latest version of Aspose.Words?
Best regards,

Hi Andrey,

I’m attaching a piece of code with which you can see the problem (its a .cs file, I changed the extension). If you generate a doc with this code it will work fine but if you generate a docx then you’ll not be able to open the file. I hope this will make it easier for you to locate the problem.

Thanks

Hi
Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (10.1.0) and the code you provided.
Could you please try using the latest version of Aspose.Words and let me know how it goes on your side?
Also please see the attached documents produced on my side.
Best regards,

Thanks Andrey, with the latest version of the API it works fine