I create 3 tables. The 1st has a fixed width for the last cell (with _builder.CellFormat.Width), and table 2 and 3 are created identical (also with some fixed cell widths and some auto-widths)
The 2nd row of the 2nd table differs from the 3rd table: the cell width are not aligned properly. The 3rd table (again, created by calling the same function a second time) is OK like so:
If I comment out the first table creation (the CreateFirstTableThatCausesProblemOn2ndTable(); function), the 2nd table is OK. If I remove the fixed cell width on the first table, the 2nd table is OK.
It really seems that using CellFormat.Width = ___ and _builder.CellFormat.PreferredWidth = PreferredWidth.Auto; somehow causes an issue on the very next table.
Can you confirm the bug or help me understand what I’m doing wrong?
We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-21313. We will further look into the details of this problem and will keep you updated on the status of the linked issue. We apologize for any inconvenience.
@awais.hafeez
More information about the issue: step by step debugging shows that calling _builder.CellFormat.PreferredWidth = PreferredWidth.Auto; or _builder.CellFormat.ClearFormatting() does not clear out the _builder.CellFormat.Width value (i.e. does not put it back to 0 which means “no value” I think). That can certainly be the (or one of the) cause of the problem.
Regarding WORDSNET-21313, we have completed the work on this issue and concluded to close this issue with “not a bug” status. The analysis reveals the following.
You use the ‘DocumentBuilder.CellFormat.Width’ property to set the width of the cell.
You also use the ‘DocumentBuilder.CellFormat.ClearFormatting()’ method to reset the cell width to zero.
And you also use the ‘DocumentBuilder.CellFormat.PreferredWidth’ property to reset the cell width from a fixed value to ‘auto’.
But you get unexpected results:
The ‘DocumentBuilder.CellFormat.ClearFormatting()’ method doesn’t reset the cell width to zero.
The ‘DocumentBuilder.CellFormat.PreferredWidth’ property doesn’t reset the cell width from a fixed value to ‘auto’.
For the ‘DocumentBuilder.CellFormat.ClearFormatting()’ method, it is noticed that this method does not change the width of the cell.
And for the ‘DocumentBuilder.CellFormat.Width’ property, it is noticed: 1) setting this property is not recommended; 2) consider using PreferredWidth for setting the cell width; 3) setting Width property sets PreferredWidth implicitly.
So we have:
_builder.CellFormat.ClearFormatting(); // does not change the cell width
_builder.CellFormat.Width = 0; // implicitly PreferredWidth = 0;
_builder.CellFormat.PreferredWidth = Tables.PreferredWidth.Auto; // takes no effect to Width
Therefore the suggested solution is to use the ‘DocumentBuilder.CellFormat.PreferredWidth’ property like this:
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.