Dear Aspose Support Team
The attached file FromAspose.xlsx has been created with Aspose.Cells. According to the getPrintingPageBreaks(…) API, the second page is up to and including cell J59. A ‘hard’ page break was added after this row (we need to insert dynamic titles after each page break).
When opening the file in Excel, however, it shows a ‘soft’ page break already one row before. After saving the file with Excel (see SavedWithExcel.xlsx in attachment), then also getPrintingPageBreaks(…) reports the second page only up to cell J58.
Interestingly, also some of the row heights changed (for some of the units) when opening/saving the file with Excel. See Comparison.xlsx for a comparison of the page breaks and row heights. The below code was used to retrieve the page breaks and row heights:
package support.pagebreak;
import com.aspose.cells.CellArea;
import com.aspose.cells.Cells;
import com.aspose.cells.ImageOrPrintOptions;
import com.aspose.cells.License;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
public class PageBreak {
private static final String PROBLEM_FILE = "src\\support\\pagebreak\\FromAspose.xlsx";
private static final String PROBLEM_FILE_SAVED_EXCEL = "src\\support\\pagebreak\\SavedWithExcel.xlsx";
private static Worksheet worksheet;
private static Cells cells;
public static void main(String[] args) throws Exception {
if (!License.isLicenseSet())
new License().setLicense("Aspose.Cells.lic");
Workbook workbook = new Workbook(PROBLEM_FILE);
worksheet = workbook.getWorksheets().get(0);
printInfo();
workbook = new Workbook(PROBLEM_FILE_SAVED_EXCEL);
worksheet = workbook.getWorksheets().get(0);
printInfo();
}
private static void printInfo() throws Exception {
for (CellArea a : worksheet.getPrintingPageBreaks(new ImageOrPrintOptions())) {
System.out.println(a);
}
cells = worksheet.getCells();
for (int row = 0; row <= 63; row++) {
System.out.println(cells.getRowHeight(row) + "//" + cells.getRowHeightPixel(row) + "//" + cells.getRowHeightInch(row));
}
}
}
My main concern here is the page break. I need stable page breaks, that are the same as calculated by Aspose even when I open / save the document in Excel. How can I achieve this?
PageBreak.zip (29.1 KB)
We are currently using Aspose Cells for Java version 20.6.3.
Thank you in advance for your feedback.