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

Free Support Forum - aspose.com

Using aspose cells to export to pdf format does not work well

Hello everybody,

I have been using Aspose.cells to generate worksheets. I have this page which is very long, but it fits ok when I export to “xlsx” format. The problem comes when I try to export it to PDF format. Because the page is very long, when I export to pdf, the software tries to fit almost all the rows in one page.
For instance, let’s say I have 400 rows to export. It will decrease the font of the rows, and will try to fit at least 200 rows in one page. Therefore, it will become the ugliest and unreadable pdf document. Exporting to Excel works fine though. I this case, it would be great if I could print something like 40 rows per page.

You can clearly see what I am talking about by looking at the two files I attached to this post.

I also have been searching in this forum for posts related to my problem, but I could not find a solution yet. I don’t have this aspose.pdf, only aspose.cells.

Thank you for your attention.

Arthur Medeiros.

Hi Arthur,

Thank you for sharing the sample spreadsheet.

Please try using the PageSetup.FitToPagesTall & PageSetup.FitToPagesWide properties in order to control the number of rendered PDF pages. Please also check the article on this subject.


var book = new Workbook(dir + “visão_2016419216.xlsx”);
//Accessing the first worksheet in the Excel file
var sheet = book.Worksheets[0];
//Setting the number of pages to which the length of the worksheet will be spanned
sheet.PageSetup.FitToPagesTall = 5;
//Setting the number of pages to which the width of the worksheet will be spanned
sheet.PageSetup.FitToPagesWide = 1;
//Saving to PDF
book.Save(dir + “output.pdf”, new PdfSaveOptions());

Hello Barbar,

Thank you so much for your help, I really appreciate this.
Using these two properties worked!
I only have one more question, is ‘7’ the greatest value that can be set to the “PageSet.FitToPagesTall” property? I am trying to set something like 100, but it will keep creating only 7 pages.

Again, thank you very much!

Arthur Medeiros.

Hi Arthur,

It is good to know that the provided solution helped in your scenario. Regarding your recent concerns, please allow me some time to look further into the matter and get back with updates in this regard.

Hi again,

First of all, please note that the Aspose.Cells APIs follow Excel’s guidelines and specifications in its processes. If you check the same scenario in Excel, you will notice that Excel shows 7 printing pages (please review attached snapshot for your reference) against your provided spreadsheet. As you can observe that while changing the values of these properties in Excel application, the scaling factor also changes, which is limited to the scope of 10% to 100%. That means, you cannot shrink a worksheet print less than 10% or enlarge greater than 100% this is because when you change the values for Fit to, Excel shrinks the printed image or expands it up to 100 percent, as necessary. Moreover, it also depends on the number of rows and columns (data matrix) to what extent the Excel could shrink/expand a worksheet print to fit a specific number of pages, that means; if you have 2 printing pages for a given worksheet, you cannot print it to 100 pages.

That said, if you’re worried only about the width or only about the height, you can specify the value for one of the properties while setting 0 for other. For example, if you have a long table and want to make sure that all the columns fit within a page you can set FitToPagesWide as 1 and FitToPagesTall as 0, and vice versa if you need the opposite.