This project has moved. For the latest updates, please go here.

Convert specific Worksheet of Excel file

May 11, 2016 at 3:28 PM
Is there a way to only convert a specific worksheet of an excel file? I want to create a separate PDF for each worksheet and not just 1 PDF of the entire spreadsheet.
Coordinator
May 11, 2016 at 3:36 PM
Hi

Presently, there's no means of specifying a specific worksheet other than the /excel_active_sheet option, which will only convert the "active" sheet in the spreadsheet. If you can modify the sheet between calls to activate the desired worksheet, you could use this option to make multiple PDFs.

I've raised https://officetopdf.codeplex.com/workitem/32 about being able select worksheets to convert. We'll consider this for a future release, but can't provide a timeframe.

Regards
Vittal
Marked as answer by PieterGunst on 5/11/2016 at 8:09 AM
May 11, 2016 at 4:09 PM
I'll look into using '/excel_active_sheet' but I'm doubtful I'll find a decent solution. Thanks for your response.
Coordinator
May 12, 2016 at 1:03 PM
Hi

I've made a build that allows an "/excel_worksheet <sheet_num>" option here: https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=officetopdf&WorkItemId=32&FileAttachmentId=1570273

So, if you want to make a PDF of just the second worksheet, use:
officetopdf.exe /excel_worksheet 2 my_spreadsheet.xlsx
If you attempt to make a PDF from a worksheet that doesn't exist, it'll return with error code 256. So, if you want to make PDFs for each worksheet, but don't know the number of sheets in the workbook, you can call officetopdf.exe repeatedly with an increasing /excel_worksheet value until it exists with code 256.

Regards
Vittal
Marked as answer by cognidox on 5/12/2016 at 6:40 AM
May 13, 2016 at 11:24 AM
I tested this again and it works now. Thanks a lot!

I used office 2016, fyi.

kind regards,

Pieter
Coordinator
May 13, 2016 at 11:39 AM
No problems Pieter - glad it's working for you. This change will be included in the next official release.

If you find OfficeToPDF useful, a tweet to @Cognidox is always appreciated :)

Regards
Vittal
Oct 6, 2016 at 12:23 PM
Hi, is there any way to make a PDF of different sheets? For example, if my excel has 3 sheets and I only want to make a PDF of 1 and 2.
Coordinator
Oct 6, 2016 at 2:52 PM
Edited Oct 6, 2016 at 2:56 PM
Hi @Cristianslei

You can't make a single PDF from selected worksheets with a single call to OfficeToPDF.

However, with the latest development version (https://www.dropbox.com/s/n3wvha935g99hke/OfficeToPDF.exe?dl=0), you can call OfficeToPDF.exe multiple times for each sheet and have the results appended to a single PDF.

e.g.
officetopdf.exe /excel_worksheet 1 myworkbook.xlsx myoutput.pdf
officetopdf.exe /excel_worksheet 2 /pdf_append myworkbook.xlsx myoutput.pdf
The first command creates myoutput.pdf from the first worksheet, the second command adds the PDF from the second worksheet to myoutput.pdf.

Regards
Vittal
Marked as answer by cognidox on 10/7/2016 at 1:28 AM
Oct 7, 2016 at 8:07 AM
That's wonderful! That was what I was looking for, thank you very much!