Table as html extracted from Excel range presents different layout in the presence of hidden columns

Hello,
we use Aspose Cells version 24.12 to extract as HTML a range from an Excel file.
The layout of the table, showed into the browser, changes if into the sheet where is present the range there is at least an hide column.

We would like to understand why the layout of the table changes if there are hidden columns into the sheet.

This is the original Excel layout: original-excel-layout.png
This is the layout of the table extracted from IDS-2577-FROM-SCRATCH.xlsx: expected-layout.png
This is the layout of the table extracted from IDS-2577-FROM-SCRATCH-WITH-COLUMNS-HIDE.xlsx: bad-layout.png

We attached a zip file that contains all files that can help you to replicate the scenario:

  • IDS-2577-FROM-SCRATCH.xlsx → original Excel file without hide columns
  • IDS-2577-FROM-SCRATCH-WITH-COLUMNS-HIDE.xlsx → copy of original Excel file where we have hidden the columns B and C
  • areaAsHtml.html → table as html extracted from the original file
  • areaAsHtmlWithColumnsHide.html → table as html extracted from the copied file
  • TestExtractHtmlFromRange.java → code using to extract the html from Excel file

Many thanks.
Regards,
Giulio

IDS-2577.zip (143.7 KB)

@giulio.andolfi

The issue you’re experiencing with the layout of the HTML table changing when hidden columns are present is likely related to how Aspose.Cells handles merged cells in conjunction with hidden rows or columns. When a range contains merged cells that span into hidden areas, it can lead to discrepancies in the resulting HTML output, causing some cells to appear misaligned or offset from their intended positions.

This behavior has been observed in previous versions of Aspose.Cells, where the presence of hidden rows or columns resulted in uneven HTML tables. It appears that the library may not correctly account for the hidden elements when generating the HTML, leading to the layout issues you are seeing.

To address this, you might want to consider the following steps:

  1. Check for Merged Cells: Ensure that your range does not include merged cells that extend into hidden columns. If they do, it may be necessary to adjust your range or the way you handle merged cells.

  2. Update Aspose.Cells: If you are using an older version of Aspose.Cells, consider updating to the latest version, as there may have been fixes or improvements related to this issue.

  3. Use Export Options: When exporting to HTML, you can specify options that control how hidden rows and columns are treated. For example, you can set the HiddenColDisplayType and HiddenRowDisplayType to remove or adjust how hidden elements are represented in the output.

If the problem persists, it may be beneficial to report this behavior to Aspose support, as they can provide more specific guidance or investigate further.

For more detailed information on handling such scenarios, you can refer to discussions on similar issues in the Aspose community, where users have shared their experiences and solutions.

If you have any further questions or need assistance with specific code examples, feel free to ask!

@giulio.andolfi,

Thanks for the sample Excel files, screenshots and code segment.

Let us evaluate your issue using your sample files and code snippet. We will get back to you soon.

Thank you @amjad.sahi for your support.
Let me know as soon as possible, please.
Regards,
Giulio

@giulio.andolfi,

I have tested your scenario/case using your sample Excel files and code snippet. Please try to replace the lines of code:

options.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.REMOVE);
options.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE); 

with:

options.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.HIDDEN);
options.setHiddenColDisplayType(HtmlHiddenColDisplayType.HIDDEN);

and it will work for the purpose.

Let us know if you still find any issue.