These functions are provided for convenience only. Use directly the Java API to access additional functionality.

createRange(rangeName, firstCell, lastCell)

getRanges(wb)

readRange(range, sheet, colClasses = "character")

Arguments

rangeName

a character specifying the name of the name to create.

firstCell

a cell object corresponding to the top left cell in the range.

lastCell

a cell object corresponding to the bottom right cell in the range.

wb

a workbook object as returned by createWorksheet or loadWorksheet.

range

a range object as returned by getRanges.

sheet

a sheet object as returned by getSheets.

colClasses

the type of the columns supported. Only numeric and character are supported. See read.xlsx2 for more details.

Value

getRanges returns the existing ranges as a list. readRange reads the range into a data.frame. createRange returns the created range object.

Author

Adrian Dragulescu

Examples



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

wb <- loadWorkbook(file)
sheet <- getSheets(wb)[["deletedFields"]]
ranges <- getRanges(wb)

# the call below fails on cran tests for MacOS.  You should see the
# FAQ: https://code.google.com/p/rexcel/wiki/FAQ
#res  <- readRange(ranges[[1]], sheet, colClasses="numeric") # read it

ranges[[1]]$getNameName()  # get its name
#> [1] "Price1"

# see all the available java methods that you can call
rJava::.jmethods(ranges[[1]])
#>  [1] "public void org.apache.poi.xssf.usermodel.XSSFName.setNameName(java.lang.String)"          
#>  [2] "public boolean org.apache.poi.xssf.usermodel.XSSFName.isFunctionName()"                    
#>  [3] "public boolean org.apache.poi.xssf.usermodel.XSSFName.isDeleted()"                         
#>  [4] "public void org.apache.poi.xssf.usermodel.XSSFName.setSheetIndex(int)"                     
#>  [5] "public void org.apache.poi.xssf.usermodel.XSSFName.setFunction(boolean)"                   
#>  [6] "public java.lang.String org.apache.poi.xssf.usermodel.XSSFName.getNameName()"              
#>  [7] "public java.lang.String org.apache.poi.xssf.usermodel.XSSFName.getRefersToFormula()"       
#>  [8] "public void org.apache.poi.xssf.usermodel.XSSFName.setRefersToFormula(java.lang.String)"   
#>  [9] "public int org.apache.poi.xssf.usermodel.XSSFName.getSheetIndex()"                         
#> [10] "public java.lang.String org.apache.poi.xssf.usermodel.XSSFName.getSheetName()"             
#> [11] "public void org.apache.poi.xssf.usermodel.XSSFName.setComment(java.lang.String)"           
#> [12] "public boolean org.apache.poi.xssf.usermodel.XSSFName.equals(java.lang.Object)"            
#> [13] "public int org.apache.poi.xssf.usermodel.XSSFName.hashCode()"                              
#> [14] "public boolean org.apache.poi.xssf.usermodel.XSSFName.getFunction()"                       
#> [15] "public int org.apache.poi.xssf.usermodel.XSSFName.getFunctionGroupId()"                    
#> [16] "public void org.apache.poi.xssf.usermodel.XSSFName.setFunctionGroupId(int)"                
#> [17] "public java.lang.String org.apache.poi.xssf.usermodel.XSSFName.getComment()"               
#> [18] "public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException"
#> [19] "public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException"   
#> [20] "public final void java.lang.Object.wait() throws java.lang.InterruptedException"           
#> [21] "public java.lang.String java.lang.Object.toString()"                                       
#> [22] "public final native java.lang.Class java.lang.Object.getClass()"                           
#> [23] "public final native void java.lang.Object.notify()"                                        
#> [24] "public final native void java.lang.Object.notifyAll()"                                     

# create a new named range
firstCell <- sheet$getRow(14L)$getCell(4L)
lastCell  <- sheet$getRow(20L)$getCell(7L)
rangeName <- "Test2"
# same issue on MacOS
#createRange(rangeName, firstCell, lastCell)