public class EGSimpleWorkbookHelper extends Object
The sheetWithNumber(int)
and sheetWithName(String)
methods
may return a null object, but any of the other methods for returning a sheet or a cell
are guaranteed to not return a null. If necessary, a sheet or a cell will be created.
The stringAtLocation
and numberAtLocation
methods are also
guaranteed to not return null. This allows one to use code like the following, without
fear of an exception.
EGSimpleWorkbookHelper helper = new EGSimpleWorkbookHelper();
helper.currentSheet().setNumberAtLocation(24, 2, 2);
helper.currentSheet().setStringAtLocation("Hello", 3, 4);
String aNumber = helper.currentSheet().numberAtLocation(1, 1).toString();
The POI classes use numbers for rows and, implicitly, columns. This class also allows
the use of the string-based column names one always sees on spreadsheets. So the methods
that take a row number and a column number and return a call can also take a column name,
such as "A", "B", ..., "Z", "AA", "AB", and so on. Using a column name not wholly
composed of capital letters will generate a IllegalArgumentException.Modifier and Type | Field and Description |
---|---|
protected org.apache.poi.hssf.usermodel.HSSFWorkbook |
_workbook |
Constructor and Description |
---|
EGSimpleWorkbookHelper() |
EGSimpleWorkbookHelper(org.apache.poi.hssf.usermodel.HSSFWorkbook workbook) |
Modifier and Type | Method and Description |
---|---|
org.apache.poi.hssf.usermodel.HSSFCell |
cellAtLocation(int rownum,
int colnum) |
org.apache.poi.hssf.usermodel.HSSFCell |
cellAtLocation(int rownum,
String columnName) |
org.apache.poi.hssf.usermodel.HSSFSheet |
currentSheet()
Returns the sheet that has been designated as the current sheet.
|
int |
currentSheetNumber()
Returns the number of the current sheet.
|
Date |
dateAtLocation(int rownum,
int colnum) |
Date |
dateAtLocation(int rownum,
String columnName) |
static EGSimpleWorkbookHelper |
newInstance() |
Number |
numberAtLocation(int rownum,
int colnum) |
Number |
numberAtLocation(int rownum,
String columnName) |
void |
setCurrentSheetName(String name) |
void |
setDateAtLocation(Date value,
int rownum,
int colnum) |
void |
setDateAtLocation(Date value,
int rownum,
String columnName) |
void |
setNumberAtLocation(Number value,
int rownum,
int colnum) |
void |
setNumberAtLocation(Number value,
int rownum,
String columnName) |
void |
setStringAtLocation(String value,
int rownum,
int colnum) |
void |
setStringAtLocation(String value,
int rownum,
String columnName) |
org.apache.poi.hssf.usermodel.HSSFSheet |
sheetWithName(String name)
Returns the sheet in this workbook that is identified by a particular name.
|
org.apache.poi.hssf.usermodel.HSSFSheet |
sheetWithNumber(int number)
Returns the sheet in this workbook that is identified by a number, with the numbers
being set in the order in which the sheets were created.
|
String |
stringAtLocation(int rownum,
int colnum) |
String |
stringAtLocation(int rownum,
String columnName) |
void |
switchToSheetNumber(int number)
Switches the current sheet to a sheet identified by number, with the number
being set by the order in which the sheets were created.
|
void |
switchToSheetWithName(String name)
Switches the current sheet to a sheet identified by name.
|
org.apache.poi.hssf.usermodel.HSSFWorkbook |
workbook()
Returns the HSSFWorkbook instance that this class is helping to build.
|
boolean |
write(String filename)
Writes the XLS data to a file given the filename.
|
String |
writeToTemp() |
public EGSimpleWorkbookHelper()
public EGSimpleWorkbookHelper(org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
public static EGSimpleWorkbookHelper newInstance()
public org.apache.poi.hssf.usermodel.HSSFWorkbook workbook()
public void switchToSheetNumber(int number)
public void switchToSheetWithName(String name)
public org.apache.poi.hssf.usermodel.HSSFSheet currentSheet()
null
.public org.apache.poi.hssf.usermodel.HSSFSheet sheetWithNumber(int number)
null
. To avoid getting a null, use the
switchToSheetNumber() method and then call currentSheet().public org.apache.poi.hssf.usermodel.HSSFSheet sheetWithName(String name)
null
.
To avoid getting a null, use the switchToSheetWithName() method and then
call currentSheet().public int currentSheetNumber()
public void setCurrentSheetName(String name)
public org.apache.poi.hssf.usermodel.HSSFCell cellAtLocation(int rownum, int colnum)
public org.apache.poi.hssf.usermodel.HSSFCell cellAtLocation(int rownum, String columnName)
public Number numberAtLocation(int rownum, int colnum)
public void setNumberAtLocation(Number value, int rownum, int colnum)
public Date dateAtLocation(int rownum, int colnum)
public void setDateAtLocation(Date value, int rownum, int colnum)
public String stringAtLocation(int rownum, int colnum)
public void setStringAtLocation(String value, int rownum, int colnum)
public String writeToTemp()
public boolean write(String filename)
filename
- to be overwritten with the spreadsheet dataCopyright © 2002 – 2020 Project Wonder.