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.
Could you advice, if it is possible to do so using Aspose.Cells?
Best regards, Sergey.
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.
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.
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
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.
- 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.
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?
Manually in excel we can drag and drop the automatic page is the similar thing possible using Aspose.Cells in .Net.
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.
Sample and Output Excel Files.zip (68.1 KB)
Workbook wb = new Workbook("sample.xlsx"); Worksheet ws = wb.Worksheets; //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.
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.
@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.
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 ??
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.