removeRow is just a convenience wrapper to remove the rows from the sheet (before saving). Internally it calls lapply.

createRow(sheet, rowIndex = 1:5)

getRows(sheet, rowIndex = NULL)

removeRow(sheet, rows = NULL)

setRowHeight(rows, inPoints, multiplier = NULL)

Arguments

sheet

a worksheet object as returned by createSheet or by subsetting getSheets.

rowIndex

a numeric vector specifying the index of rows to create. For getRows, a NULL value will return all non empty rows.

rows

a list of Row objects.

inPoints

a numeric value to specify the height of the row in points.

multiplier

a numeric value to specify the multiple of default row height in points. If this value is set, it takes precedence over the inPoints argument.

Value

For getRows a list of java object references each pointing to a row. The list is named with the row number.

See also

To extract the cells from a given row, see Cell.

Author

Adrian Dragulescu

Examples



file <- system.file("tests", "test_import.xlsx", package = "xlsx")

wb <- loadWorkbook(file)
sheets <- getSheets(wb)

sheet <- sheets[[2]]
rows  <- getRows(sheet)  # get all the rows

# see all the available java methods that you can call
rJava::.jmethods(rows[[1]])
#>  [1] "public int org.apache.poi.xssf.usermodel.XSSFRow.getPhysicalNumberOfCells()"                                                                       
#>  [2] "public void org.apache.poi.xssf.usermodel.XSSFRow.setRowStyle(org.apache.poi.ss.usermodel.CellStyle)"                                              
#>  [3] "public java.util.Iterator org.apache.poi.xssf.usermodel.XSSFRow.cellIterator()"                                                                    
#>  [4] "public org.apache.poi.xssf.usermodel.XSSFCell org.apache.poi.xssf.usermodel.XSSFRow.getCell(int)"                                                  
#>  [5] "public org.apache.poi.ss.usermodel.Cell org.apache.poi.xssf.usermodel.XSSFRow.getCell(int)"                                                        
#>  [6] "public org.apache.poi.xssf.usermodel.XSSFCell org.apache.poi.xssf.usermodel.XSSFRow.getCell(int,org.apache.poi.ss.usermodel.Row$MissingCellPolicy)"
#>  [7] "public org.apache.poi.ss.usermodel.Cell org.apache.poi.xssf.usermodel.XSSFRow.getCell(int,org.apache.poi.ss.usermodel.Row$MissingCellPolicy)"      
#>  [8] "public org.apache.poi.ss.usermodel.Cell org.apache.poi.xssf.usermodel.XSSFRow.createCell(int)"                                                     
#>  [9] "public org.apache.poi.xssf.usermodel.XSSFCell org.apache.poi.xssf.usermodel.XSSFRow.createCell(int)"                                               
#> [10] "public org.apache.poi.ss.usermodel.Cell org.apache.poi.xssf.usermodel.XSSFRow.createCell(int,int)"                                                 
#> [11] "public org.apache.poi.xssf.usermodel.XSSFCell org.apache.poi.xssf.usermodel.XSSFRow.createCell(int,int)"                                           
#> [12] "public org.apache.poi.xssf.usermodel.XSSFSheet org.apache.poi.xssf.usermodel.XSSFRow.getSheet()"                                                   
#> [13] "public org.apache.poi.ss.usermodel.Sheet org.apache.poi.xssf.usermodel.XSSFRow.getSheet()"                                                         
#> [14] "public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow org.apache.poi.xssf.usermodel.XSSFRow.getCTRow()"                                 
#> [15] "public void org.apache.poi.xssf.usermodel.XSSFRow.setRowNum(int)"                                                                                  
#> [16] "public java.lang.String org.apache.poi.xssf.usermodel.XSSFRow.toString()"                                                                          
#> [17] "public int org.apache.poi.xssf.usermodel.XSSFRow.compareTo(java.lang.Object)"                                                                      
#> [18] "public int org.apache.poi.xssf.usermodel.XSSFRow.compareTo(org.apache.poi.xssf.usermodel.XSSFRow)"                                                 
#> [19] "public java.util.Iterator org.apache.poi.xssf.usermodel.XSSFRow.iterator()"                                                                        
#> [20] "public int org.apache.poi.xssf.usermodel.XSSFRow.getRowNum()"                                                                                      
#> [21] "public void org.apache.poi.xssf.usermodel.XSSFRow.setHeight(short)"                                                                                
#> [22] "public short org.apache.poi.xssf.usermodel.XSSFRow.getFirstCellNum()"                                                                              
#> [23] "public void org.apache.poi.xssf.usermodel.XSSFRow.removeCell(org.apache.poi.ss.usermodel.Cell)"                                                    
#> [24] "public short org.apache.poi.xssf.usermodel.XSSFRow.getHeight()"                                                                                    
#> [25] "public boolean org.apache.poi.xssf.usermodel.XSSFRow.isFormatted()"                                                                                
#> [26] "public short org.apache.poi.xssf.usermodel.XSSFRow.getLastCellNum()"                                                                               
#> [27] "public void org.apache.poi.xssf.usermodel.XSSFRow.setZeroHeight(boolean)"                                                                          
#> [28] "public boolean org.apache.poi.xssf.usermodel.XSSFRow.getZeroHeight()"                                                                              
#> [29] "public float org.apache.poi.xssf.usermodel.XSSFRow.getHeightInPoints()"                                                                            
#> [30] "public void org.apache.poi.xssf.usermodel.XSSFRow.setHeightInPoints(float)"                                                                        
#> [31] "public org.apache.poi.xssf.usermodel.XSSFCellStyle org.apache.poi.xssf.usermodel.XSSFRow.getRowStyle()"                                            
#> [32] "public org.apache.poi.ss.usermodel.CellStyle org.apache.poi.xssf.usermodel.XSSFRow.getRowStyle()"                                                  
#> [33] "public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException"                                                        
#> [34] "public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException"                                                           
#> [35] "public final void java.lang.Object.wait() throws java.lang.InterruptedException"                                                                   
#> [36] "public boolean java.lang.Object.equals(java.lang.Object)"                                                                                          
#> [37] "public native int java.lang.Object.hashCode()"                                                                                                     
#> [38] "public final native java.lang.Class java.lang.Object.getClass()"                                                                                   
#> [39] "public final native void java.lang.Object.notify()"                                                                                                
#> [40] "public final native void java.lang.Object.notifyAll()"                                                                                             
#> [41] "public default java.util.Spliterator java.lang.Iterable.spliterator()"                                                                             
#> [42] "public default void java.lang.Iterable.forEach(java.util.function.Consumer)"                                                                       

# for example
rows[[1]]$getRowNum()   # zero based index in Java
#> [1] 0

removeRow(sheet, rows)  # remove them all

# create some row
rows  <- createRow(sheet, rowIndex=1:5)
setRowHeight( rows, multiplier=3)  # 3 times bigger rows than the default