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

Free Support Forum - aspose.com

Convert only one worksheet to pdf

Hi Aspose Team,

I've a workbook with 5 worksheets.
I define a print area in the last worksheet.
When I convert the workbook to pdf, all the worksheets get converted.
I only want the content of the print area in the last worksheet to be converted.
How can I do that?

I'll send you the workbook by mail.



MemoryStream str = new MemoryStream();


wbk.Save(str, FileFormatType.AsposePdf);


If you do not want to convert other worksheets to pdf, please hide them before saving the file.

If the print area of the worksheet is not set , Excel will print all datas in the worksheet.

for (int i = 0; i < wbk.Worksheets.Count; i++)
if (wbk.Worksheets[i].Name != "Releve")
wbk.Worksheets[i].IsVisible = false;

wbk.Save(str, FileFormatType.AsposePdf);

Thanks, it works.

I've an another question, regarding the printed pdf.

When I look at the first printed page in excel it span on one page only.
But in the resulting pdf, it span on two pages.

How can i keep it on one page?


I think you may utiilize fit to pages wide / tall (Click File|Page Setup|Page tab.... in MS Excel Or using the code: Aspose.Cells.PageSetup pagesetup = worksheet.PageSetup; pagesetup.FitToPagesWide = 1; pagesetup.FitToPagesTall = 0; ) for your requirement, save the file and then convert it to .pdf file.

If you still find the issue, kindly post your template excel file here, we will check it soon.

Thank you.

Solution fixed it great,