|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.extentech.ExtenXLS.WorkBookHandle
public class WorkBookHandle
The WorkBookHandle provides a handle to the XLS file
and includes convenience methods for working with the WorkSheets
and Cell values within the XLS file.
for example:
WorkBookHandle book = new WorkBookHandle("testxls.xls");
WorkSheetHandle sheet1 = book.getWorkSheet("Sheet1");
CellHandle cell = sheet1.getCell("B22");
// your license key is set thus
String licensekey = "1255087426532DDD35268256220ABTRRW";
System.setProperty("com.extentech.extenxls.licensekey", licensekey);
// path to the file containing prototype.ser and other required ExtenXLS files - this could be a .war or .ear
String jarloc = "/home/user/workspace/lib/ExtenXLSFilesNamedSomethingElse.jar";
System.setProperty("com.extentech.extenxls.jarloc",jarloc);
System.getProperties().put("com.extentech.formats.LEO.usetempfile", "true");
WorkBook,
WorkSheetHandle,
CellHandle| Field Summary | |
|---|---|
static java.lang.String |
CONVERTMULBLANKS
|
| Fields inherited from interface com.extentech.ExtenXLS.WorkBook |
|---|
ALLOWDUPES, CALCULATE_ALWAYS, CALCULATE_AUTO, CALCULATE_EXPLICIT, DEBUG_HIGH, DEBUG_LOW, DEBUG_MEDIUM, SHAREDUPES, STRING_ENCODING_AUTO, STRING_ENCODING_COMPRESSED, STRING_ENCODING_UNICODE |
| Constructor Summary | |
|---|---|
WorkBookHandle()
Default constructor creates a new, empty WorkBookHandle with 3 WorkSheets: "Sheet1","Sheet2",and "Sheet3". |
|
WorkBookHandle(byte[] barray)
constructor which takes a byte Array containing the bytes of a valid XLS file. |
|
WorkBookHandle(java.io.File fx)
constructor which takes the XLS file |
|
WorkBookHandle(java.io.InputStream inx)
constructor which takes an InputStream containing the bytes of a valid XLS file. |
|
WorkBookHandle(com.extentech.toolkit.ProgressListener pn)
Constructor which takes a ProgressListener which monitors the progress of creating a new Excel file. |
|
WorkBookHandle(java.lang.String fname)
constructor which takes the XLS file name( |
|
WorkBookHandle(java.lang.String fname,
int debug)
constructor which takes the XLS file name |
|
WorkBookHandle(java.lang.String fname,
com.extentech.toolkit.ProgressListener pn)
Constructor which takes the XLS file name and a ProgressListener which monitors the progress of reading the Excel file. |
|
WorkBookHandle(java.net.URL u,
com.extentech.security.User user)
constructor which reads spreadsheet bytes from a URL |
|
| Method Summary | |
|---|---|
void |
addProperty(java.lang.String name,
java.lang.Object val)
add non-Excel property |
boolean |
addSheetFromWorkBook(WorkBookHandle sourceBook,
java.lang.String sourceSheetName,
java.lang.String destSheetName)
Inserts a worksheet from a Source WorkBook. |
boolean |
addSheetFromWorkBookWithFormatting(WorkBookHandle sourceBook,
java.lang.String sourceSheetName,
java.lang.String destSheetName)
Inserts a worksheet from a Source WorkBook. |
void |
addWorkSheet(byte[] serialsheet,
java.lang.String NewSheetName,
java.lang.String origWorkBookName)
Inserts a new worksheet and places it at the end of the workbook The source bytes from the WorkSheet are from a serialized WorkSheet created by the WorkSheetHandle getSerialBytes() method. |
void |
addWorkSheet(WorkSheetHandle sht,
java.lang.String NewSheetName)
Inserts a new worksheet and places it at the end of the workbook |
void |
calculateFormulas()
Iterate through the formulas in this WorkBook and call the calculate method on each. |
void |
close()
Closes the WorkBook and releases resources. |
void |
copyChartToSheet(ChartHandle chart,
WorkSheetHandle sheet)
Copies an existing Chart to another WorkSheet |
void |
copyChartToSheet(java.lang.String chartname,
java.lang.String sheetname)
Copies an existing Chart to another WorkSheet |
WorkSheetHandle |
copyWorkSheet(java.lang.String SourceSheetName,
java.lang.String NewSheetName)
Copy (duplicate) a worksheet in the workbook and add it to the end of the workbook with a new name |
ChartHandle |
createChart(java.lang.String name,
WorkSheetHandle wsh)
Creates a new Chart and places it at the end of the workbook Under development and unsupported! |
NameHandle |
createNamedRange(java.lang.String name,
java.lang.String rangeDef)
Create a named range in the workbook |
WorkSheetHandle |
createWorkSheet(java.lang.String name)
Creates a new worksheet and places it at the end of the workbook |
WorkSheetHandle |
createWorkSheet(java.lang.String name,
int sheetpos)
Creates a new worksheet and places it at the end of the workbook |
void |
deleteChart(java.lang.String chartname,
WorkSheetHandle wsh)
delete an existing chart of the workbook |
void |
finalize()
Closes the WorkBook and releases resources. |
byte[] |
getBytes()
Deprecated. |
CellHandle |
getCell(java.lang.String address)
Returns the Cell at the specified Location |
CellRange[] |
getCellRanges()
Returns an Array of the CellRanges existing in this WorkBook specifically the Ranges referenced in Formulas, Charts, and Named Ranges. |
CellHandle[] |
getCells()
Returns an array containing all cells in the WorkBook |
ChartHandle |
getChart(java.lang.String chartname)
Returns a Chart Handle |
ChartHandle |
getChartById(int id)
retrieve a ChartHandle via id |
ChartHandle[] |
getCharts()
Returns all Chart Handles contained in the WorkBook |
com.extentech.formats.XLS.WorkBookFactory |
getFactory()
returns a low-level WorkBookFactory NOTE: The WorkBook class is NOT a part of the published API. |
FormatHandle[] |
getFormats()
Returns an array of all FormatHandles in the workbook |
int |
getFormulaCalculationMode()
Get the calculation mode for the workbook. |
FormulaHandle |
getFormulaHandle(java.lang.String celladdress)
Returns a Formula Handle |
ImageHandle |
getImage(java.lang.String imagename)
Returns an ImageHandle ------------------------------------------------------------ |
ImageHandle[] |
getImages()
Returns all ImageHandles in the workbook ------------------------------------------------------------ |
boolean |
getIsExcel2007()
Returns whether the underlying spreadsheet is in Excel 2007 format by default. |
java.lang.String |
getName()
Returns the name of this WorkBook |
NameHandle |
getNamedRange(java.lang.String rangename)
Returns a Named Range Handle |
NameHandle[] |
getNamedRanges()
Returns all Named Range Handles |
WorkBookHandle |
getNoSheetWorkBook()
Returns a WorkBookHandle containing an empty version of this WorkBook. |
int |
getNumCells()
Returns the number of Cells in this WorkBook |
int |
getNumWorkSheets()
Returns the number of Sheets in this WorkBook |
PivotTableHandle |
getPivotTable(java.lang.String ptname)
get a handle to a PivotTable in the WorkBook |
PivotTableHandle[] |
getPivotTables()
get an array of handles to all PivotTables in the WorkBook |
java.util.Map |
getProperties()
|
java.lang.Object |
getProperty(java.lang.String name)
get a non-Excel property |
java.lang.String |
getStats()
Return useful statistics about this workbook ------------------------------------------------------------ |
static java.lang.String |
getVersion()
Return the version of ExtenXLS |
com.extentech.formats.XLS.WorkBook |
getWorkBook()
Returns a low-level WorkBook. |
java.lang.String |
getWorkingDirectory()
Returns the directory containing the ExtenXLS.jar and extenxls.lic files. |
WorkSheetHandle |
getWorkSheet(int sheetnum)
returns the handle to a WorkSheet by number. |
WorkSheetHandle |
getWorkSheet(java.lang.String handstr)
returns the handle to a WorkSheet by name. |
WorkSheetHandle[] |
getWorkSheets()
Returns an array of handles to all of the WorkSheets in the Workbook. |
java.lang.String |
getXLSVersionString()
Returns the lowest version of Excel compatible with the input file. |
boolean |
is1904()
Returns whether this WorkBook is using the '1904' date system. |
void |
removeAllWorkSheets()
Removes all of the WorkSheets from this WorkBook. |
void |
reset()
Resets the values of this WorkBookHandle to defaults. |
int |
searchAndReplace(java.lang.String searchfor,
java.lang.String replacewith)
Searches all Cells in the workbook for the string occurrence and replaces with the replacement text. |
void |
setDebugLevel(int l)
Set the Debugging level. |
void |
setDefaultColWidth(int t)
set Default col width Note: only affects undefined Columns containing Cells |
void |
setDefaultRowHeight(int t)
set Default row height Note: only affects undefined Rows containing Cells |
void |
setDupeStringMode(int mode)
Set Duplicate String Handling Mode. |
void |
setFormulaCalculationMode(int CalcMode)
Set the calculation mode for the workbook. |
void |
setName(java.lang.String nm)
Sets the internal name of this WorkBookHandle. |
void |
setProperties(java.util.Map properties)
|
void |
setProtected(boolean b)
set the workbook to protected mode Note: the password cannot be decrypted or changed in Excel -- protection can only be set/removed using ExtenXLS |
void |
setStringEncodingMode(int mode)
Set Encoding mode of new Strings added to file. |
java.lang.String |
toString()
Returns the name of this Sheet. |
void |
write(java.io.OutputStream out)
Saves the WorkBookHandle to this opened OutputStream If original file is Excel2007 Format, the template will be written in Excel 2007 (XLSX) Format. |
void |
write(java.io.OutputStream out,
boolean Excel2007Format)
Saves the WorkBookHandle to this opened OutputStream if Excel2007Format, the template will be written in Excel 2007 (XLSX) Format. |
void |
write(java.lang.String fname)
Saves this WorkBookHandle to filename and path fname if the filename ends with ".xlsx" or ".xlsm", the template will be written in Excel 2007 (XLSX) Format. |
void |
write(java.lang.String fname,
boolean Excel2007Format)
saves this WorkBookHandle to filename and path fname if Excel2007 Format, the template will be written in Excel 2007 (XLSX) Format. |
java.lang.StringBuffer |
writeBytes(java.io.OutputStream bout)
Write the Spreadsheet bytes to an OutputStream. |
void |
writeXLSXBytes(java.io.OutputStream bout)
Explicitly write the Spreadsheet bytes to an OutputStream in Excel 2007 (XLSX) format. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static java.lang.String CONVERTMULBLANKS
| Constructor Detail |
|---|
public WorkBookHandle()
public WorkBookHandle(java.io.InputStream inx)
InputStream - contains the valid BIFF8 bytes for readingpublic WorkBookHandle(byte[] barray)
byte[] - byte array containing the valid XLS file for reading
public WorkBookHandle(java.net.URL u,
com.extentech.security.User user)
public WorkBookHandle(java.lang.String fname)
String - fname the name of the XLS file to read
public WorkBookHandle(java.lang.String fname,
int debug)
String - fname the name of the XLS file to readDebug - levelpublic WorkBookHandle(java.io.File fx)
File - the XLS file to readDebug - levelpublic WorkBookHandle(com.extentech.toolkit.ProgressListener pn)
ProgressListener - object which is monitoring progress of WorkBook read
public WorkBookHandle(java.lang.String fname,
com.extentech.toolkit.ProgressListener pn)
String - fname the name of the XLS file to readProgressListener - object which is monitoring progress of WorkBook read| Method Detail |
|---|
public int searchAndReplace(java.lang.String searchfor,
java.lang.String replacewith)
public boolean is1904()
public java.lang.String getXLSVersionString()
public java.lang.String getStats()
public java.lang.Object getProperty(java.lang.String name)
WorkBook
getProperty in interface WorkBook
public void addProperty(java.lang.String name,
java.lang.Object val)
WorkBook
addProperty in interface WorkBookproperties - The properties to set.public java.util.Map getProperties()
public void setProperties(java.util.Map properties)
properties - The properties to set.public void close()
Object.finalize()public void finalize()
finalize in class java.lang.ObjectObject.finalize()
public CellHandle getCell(java.lang.String address)
throws com.extentech.formats.XLS.CellNotFoundException,
com.extentech.formats.XLS.WorkSheetNotFoundException
getCell in interface WorkBookaddress -
com.extentech.formats.XLS.CellNotFoundException
com.extentech.formats.XLS.WorkSheetNotFoundExceptionpublic CellRange[] getCellRanges()
public PivotTableHandle getPivotTable(java.lang.String ptname)
throws com.extentech.formats.XLS.PivotTableNotFoundException
getPivotTable in interface WorkBookString - name of the PivotTable
com.extentech.formats.XLS.PivotTableNotFoundException
public PivotTableHandle[] getPivotTables()
throws com.extentech.formats.XLS.PivotTableNotFoundException
getPivotTables in interface WorkBookcom.extentech.formats.XLS.PivotTableNotFoundExceptionpublic void setFormulaCalculationMode(int CalcMode)
setFormulaCalculationMode in interface WorkBookCalcMode - Calculation mode to use in workbook.public int getFormulaCalculationMode()
getFormulaCalculationMode in interface WorkBookCalcMode - Calculation mode to use in workbook.public void setProtected(boolean b)
setProtected in interface WorkBookboolean - whether to protect the bookpublic void setDefaultRowHeight(int t)
setDefaultRowHeight in interface WorkBookint - Default Row Heightpublic void setDefaultColWidth(int t)
setDefaultColWidth in interface WorkBookint - Default Column widthpublic static java.lang.String getVersion()
public void setName(java.lang.String nm)
setName in interface WorkBookWorkBook - Namepublic void setDebugLevel(int l)
setDebugLevel in interface WorkBook
public FormulaHandle getFormulaHandle(java.lang.String celladdress)
throws com.extentech.formats.XLS.FormulaNotFoundException
com.extentech.formats.XLS.FormulaNotFoundExceptionpublic ImageHandle[] getImages()
public ImageHandle getImage(java.lang.String imagename)
throws com.extentech.formats.XLS.ImageNotFoundException
imagename -
com.extentech.formats.XLS.ImageNotFoundException
public NameHandle getNamedRange(java.lang.String rangename)
throws com.extentech.formats.XLS.CellNotFoundException
getNamedRange in interface WorkBookcom.extentech.formats.XLS.CellNotFoundException
public NameHandle createNamedRange(java.lang.String name,
java.lang.String rangeDef)
name - The name that should be used to reference this named rangerangeDef - Range of the cells for this named range, in excel syntax including sheet name, ie "Sheet1!A1:D1"
public ChartHandle getChart(java.lang.String chartname)
throws com.extentech.formats.XLS.ChartNotFoundException
getChart in interface WorkBookcom.extentech.formats.XLS.ChartNotFoundExceptionpublic ChartHandle[] getCharts()
getCharts in interface WorkBook
public ChartHandle getChartById(int id)
throws com.extentech.formats.XLS.ChartNotFoundException
id -
com.extentech.formats.XLS.ChartNotFoundExceptionpublic NameHandle[] getNamedRanges()
getNamedRanges in interface WorkBookpublic java.lang.String getName()
getName in interface WorkBookpublic CellHandle[] getCells()
getCells in interface WorkBookpublic int getNumCells()
getNumCells in interface WorkBookpublic byte[] getBytes()
getBytes in interface WorkBookWorkBook.getBytes()public void write(java.lang.String fname)
fname -
public void write(java.lang.String fname,
boolean Excel2007Format)
fname - Excel2007Format -
public void write(java.io.OutputStream out,
boolean Excel2007Format)
out - Excel2007Format - public void write(java.io.OutputStream out)
out - public void writeXLSXBytes(java.io.OutputStream bout)
FileOutputStream fileOutputStream = new FileOutputStream(fn);
BufferedOutputStream bout = new BufferedOutputStream(fileOutputStream);
bk.writeXLSXBytes(bout);
bout.flush();
bout.close();
bout - public boolean getIsExcel2007()
public java.lang.StringBuffer writeBytes(java.io.OutputStream bout)
FileOutputStream fileOutputStream = new FileOutputStream(fn);
BufferedOutputStream bout = new BufferedOutputStream(fileOutputStream);
bk.writeBytes(bout);
bout.flush();
bout.close();
to output a debugging stringbuffer, you must first set the
autolockdown setting:
props.put("com.extentech.ExtenXLS.autocreatelockdown","true");
writeBytes in interface WorkBookbout -
public java.lang.String getWorkingDirectory()
getWorkingDirectory in interface WorkBookpublic WorkSheetHandle[] getWorkSheets()
getWorkSheets in interface WorkBook
public WorkSheetHandle getWorkSheet(int sheetnum)
throws com.extentech.formats.XLS.WorkSheetNotFoundException
getWorkSheet in interface WorkBookindex - of worksheet (ie: 0)
com.extentech.formats.XLS.WorkSheetNotFoundException - if the specified WorkSheet is
not found in the WorkBook.
public WorkSheetHandle getWorkSheet(java.lang.String handstr)
throws com.extentech.formats.XLS.WorkSheetNotFoundException
getWorkSheet in interface WorkBookString - name of worksheet (ie: "Sheet1")
com.extentech.formats.XLS.WorkSheetNotFoundException - if the specified WorkSheet is
not found in the WorkBook.public com.extentech.formats.XLS.WorkBook getWorkBook()
getWorkBook in interface WorkBookpublic com.extentech.formats.XLS.WorkBookFactory getFactory()
public void reset()
reset in interface WorkBookpublic void setStringEncodingMode(int mode)
setStringEncodingMode in interface WorkBookint - String Encoding Modepublic void setDupeStringMode(int mode)
setDupeStringMode in interface WorkBookint - Duplicate String Handling Mode
public void copyChartToSheet(java.lang.String chartname,
java.lang.String sheetname)
throws com.extentech.formats.XLS.ChartNotFoundException,
com.extentech.formats.XLS.WorkSheetNotFoundException
copyChartToSheet in interface WorkBookchartname - sheetname -
com.extentech.formats.XLS.ChartNotFoundException
com.extentech.formats.XLS.WorkSheetNotFoundException
public void copyChartToSheet(ChartHandle chart,
WorkSheetHandle sheet)
throws com.extentech.formats.XLS.ChartNotFoundException,
com.extentech.formats.XLS.WorkSheetNotFoundException
copyChartToSheet in interface WorkBookchart - sheet -
com.extentech.formats.XLS.ChartNotFoundException
com.extentech.formats.XLS.WorkSheetNotFoundException
public WorkSheetHandle copyWorkSheet(java.lang.String SourceSheetName,
java.lang.String NewSheetName)
throws com.extentech.formats.XLS.WorkSheetNotFoundException
copyWorkSheet in interface WorkBookString - the Name of the source worksheet;String - the Name of the new (destination) worksheet;
com.extentech.formats.XLS.WorkSheetNotFoundException
public void calculateFormulas()
throws com.extentech.formats.XLS.FunctionNotSupportedException
calculateFormulas in interface WorkBookcom.extentech.formats.XLS.FunctionNotSupportedException
public void addWorkSheet(byte[] serialsheet,
java.lang.String NewSheetName,
java.lang.String origWorkBookName)
addWorkSheet in interface WorkBookbyte[] - the source WorkSheetHandle as a serialized byte Array;String - the Name of the new (destination) worksheet;String - of the original WorkBookNamepublic void removeAllWorkSheets()
removeAllWorkSheets in interface WorkBookpublic WorkBookHandle getNoSheetWorkBook()
getNoSheetWorkBook in interface WorkBookaddSheetFromWorkBook
public boolean addSheetFromWorkBook(WorkBookHandle sourceBook,
java.lang.String sourceSheetName,
java.lang.String destSheetName)
addSheetFromWorkBook in interface WorkBooksourceBook - - the WorkBook containing the sheet to copysourceSheetName - - the name of the sheet to copydestSheetName - - the name of the new sheet in this workbook
public boolean addSheetFromWorkBookWithFormatting(WorkBookHandle sourceBook,
java.lang.String sourceSheetName,
java.lang.String destSheetName)
sourceBook - - the WorkBook containing the sheet to copysourceSheetName - - the name of the sheet to copydestSheetName - - the name of the new sheet in this workbook
public void addWorkSheet(WorkSheetHandle sht,
java.lang.String NewSheetName)
addWorkSheet in interface WorkBookWorkSheetHandle - the source WorkSheetHandle;String - the Name of the new (destination) worksheet;
public ChartHandle createChart(java.lang.String name,
WorkSheetHandle wsh)
String - the Name of the newly created Chart
public void deleteChart(java.lang.String chartname,
WorkSheetHandle wsh)
throws com.extentech.formats.XLS.ChartNotFoundException
chartname -
com.extentech.formats.XLS.ChartNotFoundExceptionpublic int getNumWorkSheets()
public WorkSheetHandle createWorkSheet(java.lang.String name,
int sheetpos)
String - the Name of the newly created worksheetint - the position of the Sheet
public WorkSheetHandle createWorkSheet(java.lang.String name)
createWorkSheet in interface WorkBookString - the Name of the newly created worksheet
public java.lang.String toString()
toString in interface WorkBooktoString in class java.lang.ObjectObject.toString()public FormatHandle[] getFormats()
getFormats in interface WorkBook
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||