We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Regression: HTML Conversion with Hidden Columns Produces Empty Table

Hello,

We found a bug that seems to be regressive to Aspose Cells version 8.6.3. Under Aspose Cells version 8.6.2, it was possible to hide columns prior to converting a worksheet to HTML. However, as of version 8.6.3, the hidden columns cause the resulting HTML to produce an empty table.

To reproduce this issue:
First extract the “HiddenCols.xlsx” file attached and create a Java class with the following test code:


try {
setLicense(); // internal method to set the License
<span style="color: #000080">String </span><span style="color: #000000">wbPath = </span><span style="color: #555555">"HiddenCols.xlsx"</span><span style="color: #000000">;</span> </span><span style="font-family: Consolas"><span style="font-family: Consolas"><span style="color: #008000">// assumes file is in path</span></span>
<span style="color: #000000">Workbook wb = </span><span style="color: #0000ff">new </span><span style="color: #000000">Workbook(</span></span><span style="font-family: Consolas"><span style="color: #000000"><span style="font-family: Consolas"><span style="color: #000080"></span><span style="color: #000000">wbPath</span></span>);</span>
<span style="color: #000000">NameCollection names = wb.getWorksheets().getNames();</span>
<span style="color: #000080">Name </span><span style="color: #000000">name = names.get(</span><span style="color: #555555">"<b>PartialHidden</b>"</span><span style="color: #000000">);</span>

<span style="color: #000000">Range rng = name.getRange();</span>
<span style="color: #000000">Worksheet sheet = rng.getWorksheet();</span>
<span style="color: #000000">Cells cells = sheet.getCells();</span>
<span style="color: #0000ff">int </span><span style="color: #000000">firstCol = rng.getFirstColumn();</span>
<span style="color: #0000ff">int </span><span style="color: #000000">firstRow = rng.getFirstRow();</span>
<span style="color: #0000ff">int </span><span style="color: #000000">maxCol = cells.getMaxDisplayRange().getColumnCount();</span>
<span style="color: #0000ff">int </span><span style="color: #000000">maxRow = cells.getMaxDisplayRange().getRowCount();</span>

<span style="color: #008000">// HIDE all the rows and columns that are not part of the range (zero-based)</span>
<span style="color: #0000ff">if </span><span style="color: #000000">(firstCol > </span><span style="color: #ff0000">0</span><span style="color: #000000">) {</span>
<span style="color: #000000">cells.hideColumns(</span><span style="color: #ff0000">0</span><span style="color: #000000">, firstCol);</span>
<span style="color: #000000">}</span>
<span style="color: #0000ff">if </span><span style="color: #000000">(firstCol + rng.getColumnCount() < maxCol) {</span>
<span style="color: #000000">cells.hideColumns(firstCol + rng.getColumnCount(), maxCol);</span>
<span style="color: #000000">}</span>
<span style="color: #0000ff">if </span><span style="color: #000000">(firstRow > </span><span style="color: #ff0000">0</span><span style="color: #000000">) {</span>
<span style="color: #000000">cells.hideRows(</span><span style="color: #ff0000">0</span><span style="color: #000000">, firstRow);</span>
<span style="color: #000000">}</span>
<span style="color: #0000ff">if </span><span style="color: #000000">(firstRow + rng.getRowCount() < maxRow) {</span>
<span style="color: #000000">cells.hideRows(firstRow + rng.getRowCount(), maxRow);</span>
<span style="color: #000000">}</span>

<span style="color: #000000">wb.getWorksheets().setActiveSheetIndex(sheet.getIndex());</span>

<span style="color: #008000">// export the worksheet</span>
<span style="color: #000000">HtmlSaveOptions options = </span><span style="color: #0000ff">new </span><span style="color: #000000">HtmlSaveOptions(SaveFormat.</span><span style="color: #000080">HTML</span><span style="color: #000000">);</span>
<span style="color: #000000">options.setEncoding(</span><span style="color: #000080">Encoding</span><span style="color: #000000">.getUTF8());</span>

<span style="color: #000000">options.setHtmlCrossStringType(HtmlCrossType.CROSS);</span>
<span style="color: #000000">options.setPresentationPreference(</span><span style="color: #0000ff">true</span><span style="color: #000000">);</span>
<span style="color: #000000">options.setExportActiveWorksheetOnly(</span><span style="color: #0000ff">true</span><span style="color: #000000">);</span>
<span style="color: #000000">options.setExportImagesAsBase64(</span><span style="color: #0000ff">true</span><span style="color: #000000">);</span>
<span style="color: #000000">options.setCreateDirectory(</span><span style="color: #0000ff">false</span><span style="color: #000000">);</span>
<span style="color: #000000">options.setExpImageToTempDir(</span><span style="color: #0000ff">false</span><span style="color: #000000">);</span>
<span style="color: #008000">// Note, HtmlHiddenColDisplayType.REMOVE is used for columns only. <br></span></span><span style="font-family: Consolas"><span style="color: #008000"><span style="font-family: Consolas">    <span style="color: #008000">// </span></span>We found a different bug where</span> </span><span style="font-family: Consolas"><span style="font-family: Consolas"><span style="color: #008000">the hidden columns were showing up</span></span>
<span style="color: #008000">// </span></span><span style="font-family: Consolas"><span style="color: #008000"><span style="font-family: Consolas"><span style="font-family: Consolas"><span style="color: #008000">in the transformed HTML - </span></span></span>even though they are hidden.</span>
<span style="color: #000000">options.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE);</span>

<span style="color: #000080">String </span><span style="color: #000000">html = </span></span><span style="font-family: Consolas"><span style="color: #000000"><span style="font-family: Consolas"><span style="color: #000080"></span><span style="color: #000000">wbPath</span></span>.replace(</span><span style="color: #555555">".xlsx"</span><span style="color: #000000">, <font color="#0000FF">CellsHelper.getVersion()</font> + </span><span style="color: #555555">".html"</span><span style="color: #000000">);</span>
<span style="color: #000000">wb.save(html, options);</span>

} catch (Exception ex) {
System.out.println(“Unexpected EXCEPTION: \n\t” + ex.getMessage());
ex.printStackTrace();
}



Next steps:
  • Run the program using Aspose Cells 8.7.0 or 8.6.3
  • Open the resulting HTML file. Notice it has an empty table. None of the expected data from the exported worksheet exists in the produced HTML.
  • Now run the program using Aspose Cells 8.6.2.
  • Notice the resulting HTML contains the expected worksheet data.
In the attached zip file I have included the HTML output from Aspose Cells versions 8.7.0, 8.6.3 and 8.6.2. We’ve reproduced this issue under:
  • Windows 7 running Java 1.7.0_85 and
  • LINUX 5 running Java 1.7.0_85.
Thanks.

Hi,


Thanks for providing us template file and sample code.

I think we have already addressed your mentioned issue. Please try our latest version/fix: Aspose.Cells for Java v8.7.1, you may download it here:
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry694155.aspx

I have tested your scenario/case using your sample code and template file with v8.7.1, it works fine and similar to v8.6.2.

Thank you.

Hi Amjad,

Thanks for your response. Using Aspose Cells 8.7.1, I was no longer able to reproduce the issue with the original file “HiddenCols.xlsx”. However, I can still reproduce the issue with a simple spreadsheet.

For example, if you use the attached Workbook “ForExport.xlsx” and the named range “ExportCells” - it results in an empty HTML file.

To reproduce:

  1. Download the attached "ForExport.xlsx"file.
  2. Using the sample code provided above, replace:
    String wbPath = “HiddenCols.xlsx”; 
    with
    String wbPath = ForExport.xlsx”; 
  3. Then replace:
    Name name = names.get(PartialHidden);
    with:
    Name name = names.get(ExportCells);
  4. Run the program and examine the resulting HTML file.
This was reproduced with Aspose Cells version 8.7.1.

Please let me know if you see the same results

Hi,


Thank you for sharing the new sample.

We have evaluated the presented scenario against the latest revision of Aspose.Cells for Java 8.7.1.2 and we are able to notice the said problem, that is; the resultant HTML file seems to be empty. However, when same case is executed against v8.6.2, the result is correct. Based on these findings, we have raised the said issue as regression in our database with tracking Id CELLSJAVA-41772. Please spare us little time to properly analyze this scenario and get back to you with updates in this regard.

Hi,

Thanks for using Aspose.Cells.

It is to inform you that we are working over your issue and we are hopeful to provide you a fix soon.

Hi,

Thanks for using Aspose.Cells.

This is to inform you that we have fixed your issue CELLSJAVA-41772 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for Java v8.7.2.5 and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-41772) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.