Free Support Forum - aspose.com

Create a single PDF from different sheets/charts

Hello,

I have a need to be able to create a single PDF from multiple “prints” in a spreadsheet.

For instance, I need to print all the workbook tabs that aren’t charts first, and then all tabs that are charts, and I need this in a single PDF. I can get all the sheets that aren’t charts, and then the reverse by hiding the sheets as needed, it’s the PDF creation I need.

I would prefer to append the pages on the fly without having to create two PDF files and then appending them together.

Is this possible?

Thanks,

Sheri

@sheri_steeves,

Thanks for your query.

Well, Aspose.Cells follows MS Excel standards and specifications when rendering to PDF file format. You may surely hide your unwanted worksheets except your desired sheets (i.e., all sheets without chart sheet type) for case1 and render to PDF (e.g out1.pdf) file format. Then you may hide all sheets except chart sheets and render to out2.pdf for case2. But how could you manipulate and render in single PDF file (as per your description), this is not possible (even in MS Excel either) because Aspose.Cells is a spreadsheet management library rather than PDF management component. One way can be you render two PDFs by Aspose.Cells APIs and then use Aspose.PDF to merge both PDFs into single PDF.

But if you want to accomplish the task using only Aspose.Cells APIs, we can devise a workaround, i.e., by using Worksheet.MoveTo() method and using your own code, you may move a worksheet to another location in the same worksheet. So, you got to move certain worksheets at their specified (according to your needs, i.e., first normal worksheets should be in place and then chart sheets should be pasted) indexed position in the workbook, see the document for your reference:
https://docs.aspose.com/display/cellsnet/Copying+and+Moving+Worksheets#CopyingandMovingWorksheets-MoveWorksheetswithinWorkbook

after you have done all the worksheets in place (in the workbook) according to your needs, you may now render to PDF file by Aspose.Cells APIs.

Hope, this helps a bit.