IWarningCallback: "Table width exceed maximum allowed" with percent width

See attached sample: it creates a word table whose columns all have a percentage width. The table has a preferred width of “100%”.
TableWidthValidator.zip (5.4 KB)

After adding a “IWarningCallback” to our project, this results in this warning:

  • WarningType = “MinorFormattingLoss”
  • Source = “Validator”
  • Description = “Table width exceed maximum allowed, table was resized.”

The sum of the column percentage widths is exactly “100%”, but the warning also happens if I reduce the width of one column.

Do you have an idea? Is there something wrong in my code (which is quite ugly - it is printed by our aspose table wrapper when adding the table to a document)?

Best regards

Wolfgang

@wknauf

The warning you are encountering, “Table width exceed maximum allowed, table was resized,” typically occurs when the total width of the columns in a table exceeds the maximum allowable width for the table itself. Even if the sum of the column percentage widths is exactly 100%, other factors can influence the final rendered width of the table.

Here are a few suggestions to troubleshoot and potentially resolve this issue:

  1. Check Table Properties: Ensure that the table’s preferred width is set correctly. If the table’s preferred width is set to 100%, it should ideally match the total width of the columns. However, if there are additional paddings or margins applied, it could lead to exceeding the maximum width.

  2. Column Widths: Review the individual column widths. If you have set specific widths for any columns, ensure that they do not conflict with the percentage widths. Sometimes, a combination of fixed and percentage widths can lead to unexpected results.

  3. Cell Padding and Spacing: Check the padding and spacing settings for the cells. Excessive padding or spacing can add to the overall width of the table, causing it to exceed the maximum allowed width.

  4. IWarningCallback Implementation: Since you are using an IWarningCallback, consider logging the details of the warning to get more insights into which specific property or setting is causing the issue. This can help you identify if it’s a specific column or a general table setting.

  5. Testing with Simplified Table: As a debugging step, try creating a simplified version of your table with fewer columns or without percentage widths to see if the warning persists. This can help isolate the issue.

If you continue to face challenges, please share a snippet of your code that constructs the table, as it may provide further context for diagnosing the problem.

For more detailed examples and best practices regarding table creation and formatting, you can refer to the Aspose documentation and code examples available in their GitHub repository.

If you have any further questions or need additional assistance, feel free to ask!

About the bot suggestions: I don’t set padding or spacing, should all have the default of “0”.

@wknauf As I can see the table in the output looks fine. So most likely, the warning is false positive and you can safely ignore it.

Ignoring it is not so easy, as I have a reporting framework that generates a bunch of word documents, and I register the IWarningCallback globally for the entire framework. So I cannot suppress it for a special document, I can just suppress the “Table width exceed maximum allowed” message for all documents. But it might be reasonable (and fixable) under some circumstances.

Is it a problem in Aspose.Words that will be fixed in the future? If yes I don’t have a bad feeling to ignore the message temporarely :smiley:.

@wknauf After analysis, most likely the code that generates this warning will be revised or removed. The code of this method looks obsolete and unlikely to produce anything similar to MS Word table layout, especially the part that tries to resize nested tables to container width.

Sounds good, thanks. Is there an issue id that I can keep track of, so that I can remove my workaround to ignore the message?

If you remove the code, this issue of mine might be obsolete?

@wknauf Actually, we detected that the code that shows this warning is obsolete while analyzing the issue you have reported in your another thread. So you can track this issue.