How to get the number of rows in a page

Hi,

My requirement is to get the number of rows in first page out 10 number of pages.
While searching in the forum, I get the below codes. But could not able to find out the methods which used in the below code using JAVA. Could you please help me to execute the below code using JAVA.

https://forum.aspose.com/t/137289

Well, you may use:
CellArea [] area = worksheet.GetPrintingPageBreaks(printoption);

Then, you can count the number of rows and read the data from each page.

e.g

Workbook workbook = new Workbook();
workbook.Open(“e:\test\book1.xls”);
Worksheet worksheet = workbook.Worksheets[0];
ImageOrPrintOptions printoption = new ImageOrPrintOptions();
printoption.PrintingPage = PrintingPageType.Default;
SheetRender sr = new SheetRender(worksheet, printoption);
int pageCount = sr.PageCount;
MessageBox.Show(pageCount.ToString());
CellArea [] area = worksheet.GetPrintingPageBreaks(printoption);
MessageBox.Show(area.Length.ToString());
//Get the first page rows.
int strow = area[0].StartRow;
int stcol = area[0].StartColumn;

int numrows = area[0].EndRow - strow + 1;
int numcols = area[0].EndColumn - stcol + 1;



Regards
Prabu R

Hi Prabu,


Thank you for contacting Aspose support.

Please try the following piece of code that returns the number of rows and columns for each printing page in a given workhseet. I have also attached the sample spreadsheet that I have used to evaluate the case.

Java

Workbook workbook = new Workbook(dir + “book1.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(0);
ImageOrPrintOptions printoption = new ImageOrPrintOptions();
printoption.setPrintingPage(PrintingPageType.DEFAULT);
SheetRender sr = new SheetRender(worksheet, printoption);
int pageCount = sr.getPageCount();
System.out.println(pageCount);
CellArea [] area = worksheet.getPrintingPageBreaks(printoption);
System.out.println(area.length);
for(int i =0 ;i<area.length;i++)
{
//Get the first page rows.
int strow = area[i].StartRow;
int stcol = area[i].StartColumn;

int numrows = area[i].EndRow - strow + 1;
int numcols = area[i].EndColumn - stcol + 1;
System.out.println(numrows + " " + numcols);
}