Style changed while converting Excel to PDF in .NET

the question is my excel has 2 pages but pdf has more pages,pdf seems to be fat .the excel is office 2016.

here is the code:

string sourceExcelFile=“xxxx.xlsx”;
string targetPdfFile=“xxxx.pdf”;
Workbook wb = new Workbook(sourceExcelFile);
excel.zip (5.9 KB)

            PdfSaveOptions options = new PdfSaveOptions();
            //options.AllColumnsInOnePagePerSheet = true;
            wb.Save(targetPdfFile, options);

the result is the pdf is fatter than excel.
if i set options.AllColumnsInOnePagePerSheet = true;
it become heigher to take more pages although the same effect if AllColumnsInOnePagePerSheet =false

how can i get the pdf just like i turn it by office,two pages pdf,

do the aspose.cell can follow the excel page setting? or how can do to achieve it.

@cubujifang,

Thanks for the template file and sample code.

Well, actually MS shows three pages when taking the print preview of the first sheet in the workbook. I also checked your file and found there are slightly bigger values for left and right margin. To cope with it, you may minimize the left and right margin of the page. Please add the following two, it will also render 3 pages as I tested:
e.g
Sample code:

......
  wb.Worksheets[0].PageSetup.LeftMargin = 0.2;
    wb.Worksheets[0].PageSetup.RightMargin = 0.2;  

Hope, this helps a bit.

hi,Tanks for your help.

the purpose of my code is to test aspose.cell to turn excel to pdf ,we focus on the pdf pages,we hopes that i can get the same look pdf as turning it by office.

the excel is designed first,and i think set margin may break the design,and when i add the margin set,the pdf page1 is still over high to extend to the page 2

here is the pdfs what office turn and apsose turn.
could you tell me how to get the officeE2P.pdf by aspose?this is important.0426.zip (56.6 KB)

appropriate page setting on code is accepted.

Workbook wb = new Workbook(sourceExcelFile);
wb.Worksheets[0].PageSetup.LeftMargin = 0;
wb.Worksheets[0].PageSetup.RightMargin = 0;
PdfSaveOptions options = new PdfSaveOptions();
options.AllColumnsInOnePagePerSheet = true;
options.Compliance = PdfCompliance.None;
wb.Save(targetPdfFile, options);

does the excel page size is related to turning to pdf,we have two size page,A4 and letter.

thank you again!

@cubujifang,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46704 - Style changed while converting Excel to PDF

@cubujifang,

We are pleased to inform you that your issue has been resolved now. We will soon provide you the fix (after performing QA and other enhancements).

@cubujifang,

Please try our latest version/fix: Aspose.Cells for .NET v19.4.4:

Aspose.Cells19.4.4 For .Net2_AuthenticodeSigned.Zip (4.9 MB)
Aspose.Cells19.4.4 For .Net4.0.Zip (4.9 MB)

Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-46704) have been fixed in Aspose.Cells for .NET v19.5. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

thanks for your update