Free Support Forum - aspose.com

Set multiple PageBreaks in an Excel worksheet in Java

I am trying to set multiple page breaks in a worksheet.

Till now I used to set single page break in a worksheet, do we need to call the following API multiple times to set the multiple page breaks in a single worksheet.

Something like this :

m_workSheet.addPageBreaks(10,30);

m_workSheet.addPageBreaks(20,60);



Please let me know the exact procedure of accomplishing it. Sample Java code would be better.

Regards,

Praveen S D

Hi,

We have found the issue regarding setting page break after an initial test. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id: CELLSJAVA-14590.

Thank You & Best Regards,

Hi,

Do you have a fix available for setting the page breaks? What is the best API to set HPagebreak and VPagebreak. Just to repeat, I am using ASPOSE Cells for Java. Please provide a good example.

Regards,
Praveen S D

Hi Praveen,

I checked your issue with the attached latest version of Aspose.Cells and it works fine. Please try the attached version and see the following sample code for your reference:

Workbook workbook = new Workbook();

Worksheets worksheets = workbook.getWorksheets();

Worksheet worksheet = worksheets.getSheet(0);

worksheet.getCells().getCell("A1").setValue("Aspose.Cells");

worksheet.addPageBreaks(10,30);

worksheet.addPageBreaks(20,60);

workbook.save("D:\\book1.xls");

Thank You & Best Regards,

Hi,

I tried the exact same sample code you provided with the attached version of the ASPOSE Cells library. I cannot get the pagebreaks to work.

Thanks
PS

Praveen Sagar:
Hi,

I tried the exact same sample code you provided with the attached version of the ASPOSE Cells library. I cannot get the pagebreaks to work.

Thanks
PS

Hi,

Thank you for the sample code and generated file.

Well, the page breaks are applied properly using the above code (also present in your generated file). You need to change the View of the workbook from “Normal” to some other view and then back to “Normal” to see the page breaks. MS Excel also follows the same approach and you may check it by simply creating a file manually in MS Excel, add page breaks and then save it. When you will open the file again the page breaks will not be shown by default until you change the view manually.

Thank You & Best Regards,