| java.lang.Object org.apache.poi.POIDocument org.apache.poi.hssf.usermodel.HSSFWorkbook
HSSFWorkbook | public class HSSFWorkbook extends POIDocument (Code) | | High level representation of a workbook. This is the first object most users
will construct whether they are reading or writing a workbook. It is also the
top level object for creating new sheets/etc.
See Also: org.apache.poi.hssf.model.Workbook See Also: org.apache.poi.hssf.usermodel.HSSFSheet author: Andrew C. Oliver (acoliver at apache dot org) author: Glen Stampoultzis (glens at apache.org) author: Shawn Laubach (slaubach at apache dot org) version: 2.0-pre |
Method Summary | |
public int | addPicture(byte[] pictureData, int format) Adds a picture to the workbook.
Parameters: pictureData - The bytes of the picture Parameters: format - The format of the picture. | public int | addSSTString(String string) | public HSSFSheet | cloneSheet(int sheetNum) create an HSSFSheet from an existing sheet in the HSSFWorkbook. | public HSSFCellStyle | createCellStyle() | public HSSFDataFormat | createDataFormat() Returns the instance of HSSFDataFormat for this workbook. | public HSSFFont | createFont() | public HSSFName | createName() | public HSSFSheet | createSheet() create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
the high level representation. | public HSSFSheet | createSheet(String sheetname) create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
the high level representation. | public void | dumpDrawingGroupRecords(boolean fat) Spits out a list of all the drawing records in the workbook. | public HSSFFont | findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) | public List | getAllEmbeddedObjects() Gets all embedded OLE2 objects from the Workbook. | public List | getAllPictures() Gets all pictures from the Workbook. | public boolean | getBackupFlag() determine whether the Excel GUI will backup the workbook when saving. | public byte[] | getBytes() Method getBytes - get the bytes of just the HSSF portions of the XLS file. | public HSSFCellStyle | getCellStyleAt(short idx) | public HSSFPalette | getCustomPalette() | public short | getDisplayedTab() sets the first tab that is displayed in the list of tabs
in excel. | public HSSFFont | getFontAt(short idx) | public HSSFName | getNameAt(int index) | public int | getNameIndex(String name) gets the named range index by his name
Note:Excel named ranges are case-insensitive and
this method performs a case-insensitive search. | public String | getNameName(int index) | public short | getNumCellStyles() | public short | getNumberOfFonts() | public int | getNumberOfNames() | public int | getNumberOfSheets() | public String | getPrintArea(int sheetIndex) Retrieves the reference for the printarea of the specified sheet, the sheet name is appended to the reference even if it was not specified. | public String | getSSTString(int index) | public short | getSelectedTab() gets the tab whose data is actually seen when the sheet is opened. | public HSSFSheet | getSheet(String name) | public HSSFSheet | getSheetAt(int index) Get the HSSFSheet object at the given index. | public int | getSheetIndex(String name) | public int | getSheetIndex(HSSFSheet sheet) | public String | getSheetName(int sheet) | protected Workbook | getWorkbook() | public void | insertChartRecord() Test only. | public void | removeName(int index) | public void | removeName(String name) | public void | removePrintArea(int sheetIndex) | public void | removeSheetAt(int index) | public void | setBackupFlag(boolean backupValue) determine whether the Excel GUI will backup the workbook when saving. | public void | setDisplayedTab(short index) sets the first tab that is displayed in the list of tabs
in excel. | public void | setPrintArea(int sheetIndex, String reference) Sets the printarea for the sheet provided
i.e. | public void | setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) For the Convenience of Java Programmers maintaining pointers. | public void | setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) Sets the repeating rows and columns for a sheet (as found in
File->PageSetup->Sheet). | public void | setSelectedTab(short index) sets the tab whose data is actually seen when the sheet is opened. | public void | setSheetName(int sheet, String name) set the sheet name. | public void | setSheetName(int sheet, String name, short encoding) set the sheet name forcing the encoding. | public void | setSheetOrder(String sheetname, int pos) sets the order of appearance for a given sheet. | public void | unwriteProtectWorkbook() | public void | write(OutputStream stream) Method write - write out this workbook to an Outputstream. | public void | writeProtectWorkbook(String password, String username) protect a workbook with a password (not encypted, just sets writeprotect
flags and the password. |
ENCODING_COMPRESSED_UNICODE | final public static byte ENCODING_COMPRESSED_UNICODE(Code) | | |
ENCODING_UTF_16 | final public static byte ENCODING_UTF_16(Code) | | |
INITIAL_CAPACITY | final public static int INITIAL_CAPACITY(Code) | | used for compile-time performance/memory optimization. This determines the
initial capacity for the sheet collection. Its currently set to 3.
Changing it in this release will decrease performance
since you're never allowed to have more or less than three sheets!
|
PICTURE_TYPE_DIB | final public static int PICTURE_TYPE_DIB(Code) | | Device independant bitmap
|
PICTURE_TYPE_EMF | final public static int PICTURE_TYPE_EMF(Code) | | Extended windows meta file
|
PICTURE_TYPE_JPEG | final public static int PICTURE_TYPE_JPEG(Code) | | JPEG format
|
PICTURE_TYPE_PICT | final public static int PICTURE_TYPE_PICT(Code) | | Mac PICT format
|
PICTURE_TYPE_PNG | final public static int PICTURE_TYPE_PNG(Code) | | PNG format
|
PICTURE_TYPE_WMF | final public static int PICTURE_TYPE_WMF(Code) | | Windows Meta File
|
sheets | protected ArrayList sheets(Code) | | this holds the HSSFSheet objects attached to this workbook
|
HSSFWorkbook | public HSSFWorkbook()(Code) | | Creates new HSSFWorkbook from scratch (start here!)
|
HSSFWorkbook | public HSSFWorkbook(POIFSFileSystem fs, boolean preserveNodes) throws IOException(Code) | | given a POI POIFSFileSystem object, read in its Workbook and populate the high and
low level models. If you're reading in a workbook...start here.
Parameters: fs - the POI filesystem that contains the Workbook stream. Parameters: preserveNodes - whether to preseve other nodes, such asmacros. This takes more memory, so only say yes if youneed to. If set, will store all of the POIFSFileSystemin memory See Also: org.apache.poi.poifs.filesystem.POIFSFileSystem exception: IOException - if the stream cannot be read |
addPicture | public int addPicture(byte[] pictureData, int format)(Code) | | Adds a picture to the workbook.
Parameters: pictureData - The bytes of the picture Parameters: format - The format of the picture. One of PICTURE_TYPE_* the index to this picture (1 based). |
cloneSheet | public HSSFSheet cloneSheet(int sheetNum)(Code) | | create an HSSFSheet from an existing sheet in the HSSFWorkbook.
HSSFSheet representing the cloned sheet. |
createCellStyle | public HSSFCellStyle createCellStyle()(Code) | | create a new Cell style and add it to the workbook's style table
the new Cell Style object |
createFont | public HSSFFont createFont()(Code) | | create a new Font and add it to the workbook's font table
new font object |
createName | public HSSFName createName()(Code) | | creates a new named range and add it to the model
named range high level |
createSheet | public HSSFSheet createSheet()(Code) | | create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
the high level representation. Use this to create new sheets.
HSSFSheet representing the new sheet. |
createSheet | public HSSFSheet createSheet(String sheetname)(Code) | | create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
the high level representation. Use this to create new sheets.
Parameters: sheetname - sheetname to set for the sheet. HSSFSheet representing the new sheet. |
dumpDrawingGroupRecords | public void dumpDrawingGroupRecords(boolean fat)(Code) | | Spits out a list of all the drawing records in the workbook.
|
findFont | public HSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)(Code) | | Finds a font that matches the one with the supplied attributes
|
getAllEmbeddedObjects | public List getAllEmbeddedObjects()(Code) | | Gets all embedded OLE2 objects from the Workbook.
the list of embedded objects (a list of HSSFObjectData objects.) |
getAllPictures | public List getAllPictures()(Code) | | Gets all pictures from the Workbook.
the list of pictures (a list of HSSFPictureData objects.) |
getBackupFlag | public boolean getBackupFlag()(Code) | | determine whether the Excel GUI will backup the workbook when saving.
the current setting for backups. |
getBytes | public byte[] getBytes()(Code) | | Method getBytes - get the bytes of just the HSSF portions of the XLS file.
Use this to construct a POI POIFSFileSystem yourself.
byte[] array containing the binary representation of this workbook and all containedsheets, rows, cells, etc. See Also: org.apache.poi.hssf.model.Workbook See Also: org.apache.poi.hssf.model.Sheet |
getCellStyleAt | public HSSFCellStyle getCellStyleAt(short idx)(Code) | | get the cell style object at the given index
Parameters: idx - index within the set of styles HSSFCellStyle object at the index |
getDisplayedTab | public short getDisplayedTab()(Code) | | sets the first tab that is displayed in the list of tabs
in excel.
|
getFontAt | public HSSFFont getFontAt(short idx)(Code) | | get the font at the given index number
Parameters: idx - index number HSSFFont at the index |
getNameAt | public HSSFName getNameAt(int index)(Code) | | gets the Named range
Parameters: index - position of the named range named range high level |
getNameIndex | public int getNameIndex(String name)(Code) | | gets the named range index by his name
Note:Excel named ranges are case-insensitive and
this method performs a case-insensitive search.
Parameters: name - named range name named range index |
getNameName | public String getNameName(int index)(Code) | | gets the named range name
Parameters: index - the named range index (0 based) named range name |
getNumCellStyles | public short getNumCellStyles()(Code) | | get the number of styles the workbook contains
count of cell styles |
getNumberOfFonts | public short getNumberOfFonts()(Code) | | get the number of fonts in the font table
number of fonts |
getNumberOfNames | public int getNumberOfNames()(Code) | | gets the total number of named ranges in the workboko
number of named ranges |
getNumberOfSheets | public int getNumberOfSheets()(Code) | | get the number of spreadsheets in the workbook (this will be three after serialization)
number of sheets |
getPrintArea | public String getPrintArea(int sheetIndex)(Code) | | Retrieves the reference for the printarea of the specified sheet, the sheet name is appended to the reference even if it was not specified.
Parameters: sheetIndex - Zero-based sheet index (0 Represents the first sheet to keep consistent with java) String Null if no print area has been defined |
getSelectedTab | public short getSelectedTab()(Code) | | gets the tab whose data is actually seen when the sheet is opened.
This may be different from the "selected sheet" since excel seems to
allow you to show the data of one sheet when another is seen "selected"
in the tabs (at the bottom).
See Also: org.apache.poi.hssf.usermodel.HSSFSheet.setSelected(boolean) |
getSheet | public HSSFSheet getSheet(String name)(Code) | | Get sheet with the given name
Parameters: name - of the sheet HSSFSheet with the name provided or null if it does not exist |
getSheetAt | public HSSFSheet getSheetAt(int index)(Code) | | Get the HSSFSheet object at the given index.
Parameters: index - of the sheet number (0-based physical & logical) HSSFSheet at the provided index |
getSheetIndex | public int getSheetIndex(String name)(Code) | | Returns the index of the sheet by his name
Parameters: name - the sheet name index of the sheet (0 based) |
getSheetIndex | public int getSheetIndex(HSSFSheet sheet)(Code) | | Returns the index of the given sheet
Parameters: sheet - the sheet to look up index of the sheet (0 based) |
getSheetName | public String getSheetName(int sheet)(Code) | | get the sheet name
Parameters: sheet - Number Sheet name |
insertChartRecord | public void insertChartRecord()(Code) | | Test only. Do not use
|
removeName | public void removeName(int index)(Code) | | remove the named range by his index
Parameters: index - named range index (0 based) |
removeName | public void removeName(String name)(Code) | | remove the named range by his name
Parameters: name - named range name |
removePrintArea | public void removePrintArea(int sheetIndex)(Code) | | Delete the printarea for the sheet specified
Parameters: sheetIndex - Zero-based sheet index (0 = First Sheet) |
removeSheetAt | public void removeSheetAt(int index)(Code) | | removes sheet at the given index
Parameters: index - of the sheet (0-based) |
setBackupFlag | public void setBackupFlag(boolean backupValue)(Code) | | determine whether the Excel GUI will backup the workbook when saving.
Parameters: backupValue - true to indicate a backup will be performed. |
setDisplayedTab | public void setDisplayedTab(short index)(Code) | | sets the first tab that is displayed in the list of tabs
in excel.
Parameters: index - |
setPrintArea | public void setPrintArea(int sheetIndex, String reference)(Code) | | Sets the printarea for the sheet provided
i.e. Reference = $A$1:$B$2
Parameters: sheetIndex - Zero-based sheet index (0 Represents the first sheet to keep consistent with java) Parameters: reference - Valid name Reference for the Print Area |
setPrintArea | public void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)(Code) | | For the Convenience of Java Programmers maintaining pointers.
See Also: HSSFWorkbook.setPrintArea(int,String) Parameters: sheetIndex - Zero-based sheet index (0 = First Sheet) Parameters: startColumn - Column to begin printarea Parameters: endColumn - Column to end the printarea Parameters: startRow - Row to begin the printarea Parameters: endRow - Row to end the printarea |
setRepeatingRowsAndColumns | public void setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)(Code) | | Sets the repeating rows and columns for a sheet (as found in
File->PageSetup->Sheet). This is function is included in the workbook
because it creates/modifies name records which are stored at the
workbook level.
To set just repeating columns:
workbook.setRepeatingRowsAndColumns(0,0,1,-1-1);
To set just repeating rows:
workbook.setRepeatingRowsAndColumns(0,-1,-1,0,4);
To remove all repeating rows and columns for a sheet.
workbook.setRepeatingRowsAndColumns(0,-1,-1,-1,-1);
Parameters: sheetIndex - 0 based index to sheet. Parameters: startColumn - 0 based start of repeating columns. Parameters: endColumn - 0 based end of repeating columns. Parameters: startRow - 0 based start of repeating rows. Parameters: endRow - 0 based end of repeating rows. |
setSelectedTab | public void setSelectedTab(short index)(Code) | | sets the tab whose data is actually seen when the sheet is opened.
This may be different from the "selected sheet" since excel seems to
allow you to show the data of one sheet when another is seen "selected"
in the tabs (at the bottom).
See Also: org.apache.poi.hssf.usermodel.HSSFSheet.setSelected(boolean) Parameters: index - |
setSheetName | public void setSheetName(int sheet, String name)(Code) | | set the sheet name.
Will throw IllegalArgumentException if the name is greater than 31 chars
or contains /\?*[]
Parameters: sheet - number (0 based) |
setSheetName | public void setSheetName(int sheet, String name, short encoding)(Code) | | set the sheet name forcing the encoding. Forcing the encoding IS A BAD IDEA!!!
throws: IllegalArgumentException - if the name is greater than 31 charsor contains /\?*[] Parameters: sheet - number (0 based) |
setSheetOrder | public void setSheetOrder(String sheetname, int pos)(Code) | | sets the order of appearance for a given sheet.
Parameters: sheetname - the name of the sheet to reorder Parameters: pos - the position that we want to insert the sheet into (0 based) |
unwriteProtectWorkbook | public void unwriteProtectWorkbook()(Code) | | removes the write protect flag
|
writeProtectWorkbook | public void writeProtectWorkbook(String password, String username)(Code) | | protect a workbook with a password (not encypted, just sets writeprotect
flags and the password.
Parameters: password - to set |
|
|