Free Support Forum - aspose.com

HorizontalPageBreaks does not work when using FitToPagesWide

I'm building a spreadsheet that has 40 customers. Each customer should have it's own page of data. I've attempted to use HorizontalPageBreaks between each customer section, and this works, except the data in all the columns is too wide to fit on one page across.

>> workbook.Worksheets(myReportName).HorizontalPageBreaks.Add(first_line_of_new_customer, 0)

The solution in Excel is to limit to "1 Page Width". I would like to use the FitToPagesWide method as shown below, but this appears to negate the HorizontalPageBreaks. How can I get both features to work together?

Thanks in advance, Jack

-----

' PAGE SETUP

With sheet.PageSetup

.PaperSize = PaperSizeType.PaperLetter

.FitToPagesWide = 1

.FitToPagesTall = totalcustomers

.Orientation = PageOrientationType.Landscape

End With

Hi,


Well, I tested your case and it works fine. I think it works as MS Excel does. To confirm this, I have tested the following code using my template file (attached). The output file is also attached. Please see the input file first and check the page breaks in the first worksheet. Also, check the output file which is as expected. I tried the steps (as mentioned in the blow code) by manually performing in MS Excel, it works same as my output file.

Sample code:
Dim workbook = New Workbook(“e:\test2\MySampleFile.xlsx”)
Dim worksheet = workbook.Worksheets(0)
worksheet.PageSetup.Orientation = PageOrientationType.Landscape
worksheet.PageSetup.FitToPagesWide = 1
worksheet.PageSetup.FitToPagesTall = 0
worksheet.PageSetup.PaperSize = PaperSizeType.PaperLetter

workbook.Save(“e:\test2\out_MySampleFile.xlsx”)


Also, I am using the latest version/fix v6.0.0.3, please try it.

Thank you.

Thanks for the help. This line appears to be the key to solving my problem:

worksheet.PageSetup.FitToPagesTall = 0

I tried leaving that property off, as well as using a very large number, as well as using the exact number of pages "Tall". None of those worked, but "zero" did.

Hi,

Good to know that your issue is solved.

Thank you.