xceedsoftware / DocX

Fast and easy to use .NET library that creates or modifies Microsoft Word files without installing Word.
Other
1.78k stars 474 forks source link

Table.IndentFromLeft not working? #470

Closed samuel-carradice closed 9 months ago

samuel-carradice commented 9 months ago

Using DocX version 3.0.0 with .NET Framework 4.7.2 The Table class IndentFromLeft property appears to take a double value in points but any value I have tried results in invalid xml and a file that will not open. I am using an old version of Word (2007) but I would have expected it to support this property.

XceedBoucherS commented 9 months ago

Hi, Under Microsoft 365, the resulting docx opens and the Table is correctly indented: image image

Are you using a decimal values for the indentation ? Can you try with Word from Microsoft 365? Are you creating a new file or opening an existing one ?

Thank you

samuel-carradice commented 9 months ago

Thanks for having a look. I am using an integer double value (as indicated in the documentation) and creating a new file. I have tried the code exactly as you suggest and it doesn't work in Word 2007. In 365 on-line, the file opens but the table is not indented - I don't think the on-line version supports this property, so no surprise there! Unfortunately I don't have a local version of 365 available. Not to worry if there is no easy fix for this one - it's a very minor problem.

XceedBoucherS commented 9 months ago

Hi,

Ok, I know why. Word 2007 needs to know the type of the Indentation value in order to load the document. In 365, this is not required. I can make the fix for this property. If you find any other property with this issue, just poke us :-)

It will be fixed in the next service release. In the meantime, if you have access to source code, go in file: Xceed.document.NET/Src/Table.cs In property setter: IndentFromLeft and add this line at the end of the setter: tblInd.Add( new XAttribute( XName.Get( "type", Document.w.NamespaceName ), "dxa" ) );

Thank you

samuel-carradice commented 9 months ago

That does indeed fix the problem. Thanks very much for your support.