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

Free Support Forum - aspose.com

Get number of pages in CSV file

Thank you Alexy for the quick response , I will include the FontSubstitution .
Now , I am trying to get the page count for CSV using sheet renderer page count , its always returning zero for me and no exceptions
Sample-Spreadsheet-5000-rows.csv.zip (154.9 KB)

   Workbook book = new Workbook(filePath);
       ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
//        Default	    0	Prints all pages.
//        IgnoreBlank	1	Don't print the pages which the cells are blank.
//        IgnoreStyle	2	Don't print the pages which cells only contain styles.
SheetRender sr = new SheetRender(sheet, imgOptions);
nt sheetPageCount = sr.getPageCount();

Apose.cells for java was downgraded from 2022.1 to 2021.12 , it appears that CSV processing in broken in latest aspose verison


I have tested your scenario/case with the following sample code using our latest version/fix: Aspose.Cells for Java v22.1 and your CSV file. It works fine and as expected:
Sample code:

Workbook book = new Workbook("f:\\files\\Sample-Spreadsheet-5000-rows.csv");
Worksheet sheet = book.getWorksheets().get(0);
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
//        Default	    0	Prints all pages.
//        IgnoreBlank	1	Don't print the pages which the cells are blank.
//        IgnoreStyle	2	Don't print the pages which cells only contain styles.
SheetRender sr = new SheetRender(sheet, imgOptions);
int sheetPageCount = sr.getPageCount();
System.out.println(sheetPageCount);//192 - Ok

As you can see it works fine with latest version/fix and we could not find any issue, so kindly use latest version. If you still find the issue with latest version/fix, then please give more details and sample code with template file to reproduce the issue on our end. We will check your issue soon.

PS. we cannot evaluate issues with older version. Neither we can include fixes to older APIs set. The fixes are based on latest version/APIs set only.

Thank you very much Amjad for the response , I will try to upgrade and re-run CSV , but before that I would like to understand how aspose calculated the value of 192 as the page count for the file attached,
When I set the print area and a print I see the total number of pages to be printed as 214 , If I switch to landspace mode ,it is 152 . I will have to explain to our internal team how the pages numbers are calculated , in our case we have not applied any page setups like top margin etc , even though aspose is not showing the true page count
Any response in this regard will help us to better understand the product
I am attaching the screen shot the print view of the file

  1. Please use paper size as US letter
  2. I am using excel 2021 with version 16.57 for opening the CSV and do the print preview

Please note I am not able to attach any further screen shots in this post


The page count may differ on different environment, it is based on printer settings, page size and printable areas. You may simply open the file into your MS Excel and take the print preview and check how many pages MS Excel will display in print preview. Then try to use Aspose.Cells (latest version) and check if you get different value.

Please zip the screenshots and files prior attaching here.

Hi Amjad, Trying to share the screen shots [ Available in the word document attached] , please let me know how you got the page count as 192 ?
Thanks for all your help and support , I hope I can get this one thing confirmed before finalizing the evaluation of the productAsposeCSV-Testing.docx (1002.8 KB)


I actually got 194 for default paper size and printer settings via Aspose.Cells for Java using your code segment. Also, when I changed paper size and orientation (Landscape) manually, the pages count are 148 in MS Excel’s print preview (Windows platform). Anyways, could you please try our latest version (Aspose.Cells for Java v22.1) using your original code and template file and let us know what pages count you get.

I did once again update to 22.1 , page count is 0 for CSV files , we tried in multiple machines (MAC) , same results
Below are the results from 21.12

Apose.cells verion : 21.12 , JDK 17

Total page count 194
Setting - setPrintingPage = 2
setPaperSize - 1 (Paper Letter)

Total page count 136
Setting - setPrintingPage = 2
setPaperSize - 1 (Paper Letter)
setOrientation - 0 (landscape)


Could you please try our latest fix/version: Aspose.Cells for Java v22.1.1 (attached)
aspose-cells-22.1.1-java.zip (7.5 MB)

It should give similar results as per Aspose.Cells for Java v21.12.

Let us know if you still find the issue with the attached fix.

Thanks Amjad , I am not able to unzip the attached file , can you please send the jar file if you want me to test it ?
In any case , I will need to understand why the page count calculated by aspose cells ( even the latest one ) DO NOT match to the actual page count , please let me know how the page count can be 194 when the actual page count while printing is 224
Is there any font substitution that is happening similar to the rule for doc files


You need to use some zip tool (e.g. WinRAR) to extract the zipped archive (I shared previously). Please extract the Aspose.Cells JAR file from the archive and then give it a try on your end. Let us know the results. We cannot attach JARs directly in the forums, so we have to zip the JARs prior attaching here.

Yes, it might also affect the page count. Also, I already shared that the page count may be different on different environments (Windows MAC, etc.), it is also based on printer settings, page size and printable areas, etc.

You still confirm if Aspose.Cells for Java v22.1 gives zero page count using your original code and file?


There was an issue in the release v22.1. It had been fixed in the fix v22.1.1.

There are too many factors affecting page count, e.g. margins, paper size, default font…
Please try the following code, it returns 214 for PageOrientationType.PORTRAIT and 148 for PageOrientationType.LANDSCAPE, which is same as Excel on my side.
see screenshot:
landscape.png (72.5 KB)
portrait.png (75.7 KB)

Workbook wb = new Workbook("Sample-Spreadsheet-5000-rows.csv");

//change default font to Calibri 11
Style defaultStyle = wb.getDefaultStyle();

Worksheet sheet = wb.getWorksheets().get(0);

//set default row height

PageSetup pageSetup = sheet.getPageSetup();

//set margins same as Excel

//set paper size

//set page oritan

ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
SheetRender sr = new SheetRender(sheet, imgOpt);


Thank you … this explain’s why the page counts were differing in my previous tests , as I doubted …it has to do with the fonts & in addition setting the standheight

  1. For the test file shared earlier, I am getting the page count as 148 (landscape) and 214 (portrait)
    The actual page count is slightly varying its 143 (landscape) and 210 (portrait) when I see it in ms office mac after providing all the settings (page orientation, paper size, margins, cell height, font size and font style)

  2. I was able to get similar page count results like above using 2022.1.1. version, looks like processing CSV is resolved , let me know once the version is released.
    thanks for fixing the problem.

Questions :

#1 If we do not set the font size, what is the font size aspose defaults to , is it 10 ?

#2 We have set the row height to 15, what’s the default row height used by aspose ? is it 15 since excel mentions it as 15.

I want to limit the static values set to process the page count and default as many variable as possible.

#3 https://docs.aspose.com/cells/net/configuring-fonts-for-rendering-spreadsheets/
Based on this, first point, by file system it means the font directory or does it mean the fonts in the OS


The default font used by aspose is Arial 10.

The default row height used by aspose is 12.75.

Actually, the default font and default row height varies depending on language in Excel. For English US, the default font is Calibri 11 and default row height is 15 pt.

For Aspose.Cells for Java, it means the font directory.

Is there a table or page which includes the default values of fonts , font size , row height for different languages ?


Apparently there is no such table available but we will check it and provide details on it.


What does you use the table/page to do? So we can provide solution or workaround for it.