B4J Question setRepeatingRows

stevel05

Expert
Licensed User
Longtime User
I don't know the library but when you say "I cannot seem to find the routine in RunMethod " Do you get an error when trying it?

You will need to create a cellrangeaddress object to pass to the method.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
B4X:
   Dim sheetJo As JavaObject = Sheet
   sheetJo.RunMethod("setRepeatingRows", Array("Sheet.Name!$1:$1"))

gives me this error:
Waiting for debugger to connect...
Program started.
Error occurred on line: 69 (cPoiRoutines)
java.lang.RuntimeException: Method: setRepeatingRows not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
at b4j.example.cpoiroutines._setheadercenter(cpoiroutines.java:434)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Yes. Can't figure how to call this example below
B4X:
http://poi.apache.org/spreadsheet/quick-guide.html#Repeating

Repeating rows and columns
It's possible to set up repeating rows and columns in your printouts by using the setRepeatingRows() and setRepeatingColumns() methods in the Sheet class.

These methods expect a CellRangeAddress parameter which specifies the range for the rows or columns to repeat. For setRepeatingRows(), it should specify a range of rows to repeat, with the column part spanning all columns. For setRepeatingColums(), it should specify a range of columns to repeat, with the row part spanning all rows. If the parameter is null, the repeating rows or columns will be removed.

Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
Sheet sheet1 = wb.createSheet("Sheet1");
Sheet sheet2 = wb.createSheet("Sheet2");

// Set the rows to repeat from row 4 to 5 on the first sheet.
sheet1.setRepeatingRows(CellRangeAddress.valueOf("4:5"));
// Set the columns to repeat from column A to C on the second sheet
sheet2.setRepeatingColumns(CellRangeAddress.valueOf("A:C"));

FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Thanks. That lets me set a cell range.

But the setRepeatingRows does not seem to do anything.

Tried $1:$1 like I would do in any other Excel sheet (as a cell range and even SheetName !$1:$1)

Also tried the call method "setPrintRowAndColumnHeadings" (called on sheet level) according to the docs that is suppose to turn on and off the printing of column heading.

But that crashes as "java.lang.RuntimeException: Method: setPrintRowAndColumnHeadings not found in: org.apache.poi.xssf.streaming.SXSSFSheet"

Like always, seems like simple stuff.
 
Upvote 0
Top