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

Free Support Forum - aspose.com

Get rid of automatic page breaks

Hello,

My version is Aspose.Cells 7.6.

I setup print area and divided it into several pages using HorizontalPageBreaks and VerticalPageBreaks.

Now, in case the size of the print page is bigger than the paper size of the sheet, excel adds automatic page breaks to fit the paper size.
And I need the exact page breaks setup in the output, so this situation is not acceptable.

Setting up the largest possible ws.PageSetup.PaperSize is not an option, because no one knows which sizes support the printer of the client.

In the excel itself, it is possible to move the automatic page breaks wherever you want, and form as large print page as necessary, regardless the paper size of the sheet.
http://screencast.com/t/32rVxsngfWr

Could you advice, if it is possible to do so using Aspose.Cells?



Best regards, Sergey.

Hi,


Well, we are not sure about your requirements. Do you need to generate PDF or image from Excel files? Also, if MS Excel cannot fulfill your needs, how could Aspose.Cells as it follows MS Excel standards and use its diverse file formats after all.

You may off course clear existing page breaks and re-add page breaks accordingly, see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/Managing+Page+Breaks

By the way, if you want to split pages by your desired pagebreaks only, and you do not want the result what MS Excel produces, e.g add auto breaks when one splitting area is greater than paper size. If this is the case we can try to accomplish it, however it is a bit complex, we may check it out. Could you confirm this and elaborate your requirements and provide more details and sample Excel files etc., it will help us to look into it more precisely soon.

Thank you.

Hi,

no need if that’s complex. We will do a workaround.

I thought of any already existing solution that behaves the same as manual moving of automatic page breaks in excel (see the video from the prev. post).

Thank you anyway.

Best regards, Sergey.

@SergeyPonomar

Could you please help me with the way you have achieved the above. I am really trying hard to remove the automatic age breaks in excel and just keep the manual ones. The video you shared is no longer playing. Could you please help me with this.

@ish.dewan

Please share your source Excel file and your desired Excel file. We will compare both of them and provide you a sample code to fulfill your needs. You can create both of them manually using Microsoft Excel.

@shakeel.faiz : My concern is to remove the automatic page breaks from the excel file and to display only the Manual Page Breaks

@ish.dewan

Automatic Page Breaks means Page Breaks created by Microsoft Excel Automatically when you open the Excel Workbook.

You can only add and remove the manual page breaks not automatic page breaks.

However, worksheet has three views. i.e.

  • Normal
  • Page Layout
  • Page Break Preview

If you will set your worksheet to Normal view, then page breaks will not show up.

For more information, please refer to this question

You can’t delete automatic page breaks. But if you close, then reopen the workbook, they will be hidden until you either set a manual page break or print preview the sheet.

@shakeel.faiz

Can we use workBook.Worksheets[“ABC”].HorizontalPageBreaks.RemoveAt(Convert.ToInt32(list2[q])); to remove the automatic page break if we know the location where the automatic page break is occuring?

@shakeel.faiz

Manually in excel we can drag and drop the automatic page is the similar thing possible using Aspose.Cells in .Net.

@ish.dewan

Please check the attached sample Excel file, its output Excel file as well as its sample code (please also read the comment inside the code) for your reference.

Download Link:
Sample and Output Excel Files.zip (68.1 KB)

C#

Workbook wb = new Workbook("sample.xlsx");

Worksheet ws = wb.Worksheets[0];

//This line is important
ws.PageSetup.Zoom = 46;

ws.HorizontalPageBreaks.Add(101);
ws.VerticalPageBreaks.Add(20);

wb.Save("output.xlsx");

@shakeel.faiz : i am not able to open the files that you shared.

@ish.dewan

What error you are getting? First download the zip file and unzip it using WinRAR tool.

However, these are the screenshots of the Input and Output Excel files for your reference.

Input Excel File:

Output Excel File:

@shakeel.faiz : i get the error as “Sorry, this file is private. Only visible to topic owner and staff members.” while i try to download.

Yes, The screens you shared I need something like this only where i can get rid of the automatic page breaks in the final o/p.

I have tried using PageSetup.Zoom but it was also of no help.

@ish.dewan

Please download the Zip file from this Dropbox link.

You will have to try different values of Zoom. First try 10 then 20, 30, 40 till 100 and see which value works for you.

@shakeel.faiz : Can we move the automatic page breaks somehow to the end because we need the file in a particular format where zoom is not of use for us.

Also, does RemoveAt works with Automatic Page breaks ??

@ish.dewan

RemoveAt only removes Manual Page Breaks.

When you try to remove Automatic Page Breaks using Microsoft Excel by dragging the pointer/cursor horizontally and vertically, Scale (i.e. Zoom) changes.

It means, you cannot remove Automatic Page Breaks without setting Zoom. Please see the following screenshot for more help.