Fetch all the pagebreaks

Hi Team,

I would like to fetch all the pagebreaks from worksheet using Aspose.cells.

I have similar functionality in VB where i can use worksheet.HPageBreaks, I am looking for similar functionality in Aspose.

Please respond to me ASAP.

Regards,

Niveditha

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please use the following properties to get all the horizontal and vertical page breaks for your needs.

  • worksheet.HorizontalPageBreaks
  • worksheet.VerticalPageBreaks

Hi Team,

I am expecting like this. HorizontalPageBreak is not working ....It is giving Null value i.e, count as 0

For Each pb In ws.HPageBreaks
Rng = "A" & (pb.Location.Row - 1)
Pgebrk = pb.Location.Row
--do something--
Next pbv

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please provide us your source file and full runnable sample code to look into this issue. We will investigate your issue at our end and update you asap.

Please find the attached code project

Hi,

Thanks for your posting and using Aspose.Cells.

You are fetching page breaks from empty workbook and from non-existent worksheet. Please see the exception which is thrown by your project code. Please fetch the page breaks from your source workbook which contains the page breaks to fix it.

You can take any workbook that has 3-4 page breaks and take that workbook and check if we are able to fetch pagebreaks for it. We can see pagebreaks in our template file but we are not able to fetch them using code.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We have tested your issue with the following code with the given sample file and printed the horizontal and vertical page breaks count, it printed the correct count.

C#


string filePath = “F:\Shak-Data-RW\Downloads\MySampleFile.xlsx”;


Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.Worksheets[0];

int horizontalCount = worksheet.HorizontalPageBreaks.Count;

int verticalCount = worksheet.VerticalPageBreaks.Count;


Debug.WriteLine("Horizontal Page Breaks: " + horizontalCount);

Debug.WriteLine("Vertical Page Breaks: " + verticalCount);


Output:
Horizontal Page Breaks: 3
Vertical Page Breaks: 2