The setPrintArea() call doesn't work when saving xls as HTML.
Kindly suggest on options for setting HTML print area boundary.
Thanks
The setPrintArea() call doesn't work when saving xls as HTML.
Kindly suggest on options for setting HTML print area boundary.
Thanks
Hi Suresh,
Hi Thanks for your reply.
The solution that you had provided works, but my requirement is little different.
After generating an XLS, when I need to convert it to HTML the data area should be hidden and only the chart should be shown.
When I hide cells with the cells.hideRow() method, the data goes away and no chart gets generated and the generated HTML shows up blank.
Kindly help on this query on Priority.
Thanks,
Suresh
Hi Suresh,
Hi,
Pls find attached the xls that Iam converting to HTML.
I need the range of cells - A1:AD44 alone to be included in the generated HTML and want to ignore the data area (i.e) the range AF49 : AZ54.
Pls find below the code that iam using for the conversion.
----------
Workbook workbook = new Workbook("D:/test/testFile_1.xlsx");
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML);
saveOptions.getImageOptions().setImageFormat(ImageFormat.getPng());
saveOptions.getImageOptions().setTransparent(true);
saveOptions.setExportHiddenWorksheet(false);
saveOptions.setPresentationPreference(true);
saveOptions.getImageOptions().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
saveOptions.getImageOptions().setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
PageSetup pgSetup = workbook.getWorksheets().get(0).getPageSetup();
pgSetup.setPrintArea("A1:AD44");
workbook.save("D:/test/testFile_1.html", saveOptions);
----------
Hi Suresh,
Hi Suresh,
I have looked further into this matter, and digging revealed that by default the Excel application and the Aspose.Cells APIs will render the chart empty if its data source is hidden. You may confirm this in Excel as well. In order to avoid this problem you can set the “Show data in hidden rows and columns” option in Excel (please check attached snapshot), whereas the same option is available as Chart.PlotVisibleCellsproperty in Aspose.Cells APIs. Moreover, you cannot remove the hidden rows/columns from the rendering process, instead, you should be setting them as hidden. Please check the following piece of code, and give it a try on your end to feed us back with your results.
Java
Workbook workbook = new Workbook(“D:/testFile_1.xlsx”);
<b>workbook.getWorksheets().get(“Data”).getCells().hideRows(43, 15);
//workbook.getWorksheets().get(“Data”).getCells().hideColumns(32, 20);</b>
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML);
saveOptions.getImageOptions().setImageFormat(ImageFormat.getPng());
saveOptions.getImageOptions().setTransparent(true);
saveOptions.setExportHiddenWorksheet(false);
saveOptions.setPresentationPreference(true);
saveOptions.getImageOptions().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
saveOptions.getImageOptions().setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
<b>saveOptions.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.HIDDEN);
//saveOptions.setHiddenColDisplayType(HtmlHiddenColDisplayType.HIDDEN);</b>
<b>workbook.getWorksheets().get(“Data”).getCharts().get(0).setPlotVisibleCells(false);</b>
workbook.save(“D:/testFile_1.html”, saveOptions);
Hi Thanks for the solution.
Hi Suresh,