Aspose Cells splitting sheet issue in different pages

Hi,

We are using Aspose Cells 23.1 with JDK version 8 on CentOS 7.

In converted PDF,

  1. Page footer is overwriting the text on first page
  2. Adding extra pages with blanks rows at the end.

Earlier I was using the setting opt.setOnePagePerSheet(true);
Now we don’t want one page per sheet, it should split sheet into different pages.
Q. Is there any criteria to split the sheet in pages (like X no of rows in one page)?

Please note that, I have generated this with my test program without setting license thats why it is showing evaluation header.

@rutuja.mahajan
1,Can you share the locale setting of the machine that created this file ?
The default row height is strange 14.4pt in the file.
Could you resave the file in MS Excel, then export to pdf?
2, Adding extra pages with blanks rows at the end.
If you print the file in MS Excel, you will see same pages with blank rows.

In the mean time, after an initial test, we reproduced the issue with Input.xlsx file you mentioned. We found page footer is overwriting the text on first page.

To evaluate/investigate your issue, we have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45099

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

You can use page breaks feature to split your number of rows to be rendered on a page.

@rutuja.mahajan

The row height in the source file is auto height, the cached height is 14.4 pt, when you open the source file in Excel, Excel auto re-calculates the row height to 15 pt, please use the code Worksheet.auotFitRows(true) to do the same thing.
Also, please move FontConfigs.setFontFolders to the start.
So the code will be:

	public static void main(String args[]) {

		String[] fontFolders = {"user/share/fonts",}; 
		FontConfigs.setFontFolders(fontFolders, true);

		try {
			  // Save the document in PDF format
			  Workbook workbook = new Workbook("C:\\Workspace\\workspace\\PRV-PA-ITP-00014.xlsx");
			  WorksheetCollection col = workbook.getWorksheets();
			  PdfSaveOptions opt = new PdfSaveOptions();
			 // opt.setOnePagePerSheet(true);
			  for (int i=0; i<col.getCount(); i++) {				 
				  Worksheet sheet = workbook.getWorksheets().get(i);
				  sheet.autoFitRows(true);
				  
				  sheet.getPageSetup().setPrintArea(null);
			  }
			 
			  
			  workbook.save("C:\\Workspace\\workspace\\PRV-PA-ITP-00014.pdf", opt);
			  
		} catch (Exception e) {
			System.out.println("Exception: "+e);
		}
    }

Please manually save the source file to pdf in Excel and share it to us. Also, highlight the issue and share us screenshots.

Thanks for your response.

  1. By setting autoFitRows now footer is not overriding the text.
  2. If I manually save the excel in PDF it is also adding the extra blank pages at the end, do we have any solution to avoid this?

Also, If we don’t set the onePagePerSheet property, it is creating problem for CAD drawings, it just splits the drawing in multiple pages,
Can you check these attachment,
Excel_With_CAD.zip (719.8 KB)

@rutuja.mahajan

You should remove rows/cells that only with borders in the source file.

You can set a larger paper size or set a custom width and heihgt for the sheet

Hi,
For page break feature I need to define cells value (eg. Y30), which is not a dynamic solution.
If I don’t provide page break and If I don’t set onePagePerSheet, what is default criteria to split a sheet in pages?

@rutuja.mahajan

It will calculate numbers of rows and columns that can be put in a page according to the source file.

image.png (327.5 KB)

Can it split pages based on page break view defined in excel?
If yes, Do we need any code change for this?

@rutuja.mahajan

Page breaks should be same as you see in Excel page break view(or in Excel printview).
If there are difference, please share us the source file and your code.

Compare the page break view of these excels with converted PDF its not same,
Files_Not_Using_Pagebreak_to_split_sheet_in_pages.zip (2.6 MB)

@rutuja.mahajan,

Thanks for the source files and sample code segment.

We will evaluate your issue soon. We also appreciate if you could share some screenshots to highlight the problematic areas (while comparing Excel’s print preview vs. output PDF pages (by Aspose.Cells). This will help us to evaluate your issue precisely. Please remove printable areas for the sheets in MS Excel manually before taking the print previews.

@rutuja.mahajan

Your source files have fit to page wide/tall set and printarea set, if you clear the printrea, the sheet zoom will be different, so the page breaks will be different.

So if you clear the printarea in code, you should also clear printarea manually in Excel for comparing pagebreaks.

If you still have issues, please share us your current code and the sreenshots to highlight the page break issues.

Thank you for your response, we can close this topic.

@rutuja.mahajan,
I’m glad your issue has been solved. If you have any questions, please feel free to contact us.