Free Support Forum - aspose.com

How do I save a single Sheet as a PDF or HTML

I have a spreadsheet with multiple tabs (sheets) and I want to save just one of the sheets as a PDF or as a single HTML file without any folders or extra stuff. Is there a way to do that? I can only find save on the workbook and it saves all the sheets.

Thanks.

Hi,

Thanks for your posting and using Aspose.Cells.

Yes, it is possible to save each individual worksheet into pdf or html. First you will hide all of your worksheets except the worksheet which you want to save to pdf or html, then you will save your workbook into pdf or html using Aspose.Cells.

This approach has been mentioned in this article. Please check and implement it at your end.

( http://www.aspose.com/docs/display/cellsjava/Save+Each+Worksheet+to+a+Different+PDF+File )

Thanks, that got me what I want with the PDF, unfortunately the HTML file is still not what I am looking for.

I need a single HTML file without the tab bar at the bottom. Even hidden it creates all the worksheets in a sub-directory. I need a single HTML file with no sub-directory or extra files with the one sheet that is visible.

Thanks.

Never mind, I figured it out. I used HtmlSaveOptions and set the Export Hidden Worksheet to false and the Export Images As Base64 to true and I got my single HTML file with no sub-folder or extra stuff.

Thanks for the help.

Hi,

Thanks for your feedback and using Aspose.Cells.

It is good to know that you were able to sort out this issue. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

sherter:
Thanks, that got me what I want with the PDF, unfortunately the HTML file is still not what I am looking for.

I need a single HTML file without the tab bar at the bottom. Even hidden it creates all the worksheets in a sub-directory. I need a single HTML file with no sub-directory or extra files with the one sheet that is visible.

Thanks.


Here is the code snippet for reference.

Java

HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportActiveWorksheetOnly(true);
options.setExportImagesAsBase64(true);
Workbook sourcebook = new Workbook(“D:/sample.xlsx”);
WorksheetCollection sheets = sourcebook.getWorksheets();
for (int i=0; i<sheets.getCount(); i++)
{
sheets.setActiveSheetIndex(i);
sourcebook.save(“D:/” + sheets.get(i).getName() + “.html”, options);
}