|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.spire.xls.Workbook
public final class Workbook
Represents the workbook object of excel.
Constructor Summary | |
---|---|
Workbook()
Create a new instance of workbook. |
Method Summary | |
---|---|
void |
addPivotTableStyle(PivotTableStyle pts)
|
static boolean |
bookIsPasswordProtected(java.lang.String fileName)
Check if the file is password protected. |
void |
calculateAllValue()
Caculate all formula for the workbook |
java.lang.Object |
calculateFormulaValue(java.lang.String text)
Calculates the string formula |
void |
changePaletteColor(java.awt.Color color,
int index)
Changes the palette for the spreadsheet in the specified index. |
double |
columnWidthToPixels(double columnWidth)
onverts column width in characters into column width in pixels. |
boolean |
containsFont(ExcelFont font)
Indicates whether the workbook contains specified font. |
void |
copyToClipboard()
Copies whole workbook to the clipboard. |
void |
copyToClipboard(Worksheet worksheet)
Copies the selected worksheet to clipboard. |
Worksheet |
createEmptySheet()
Create a new worksheet. |
Worksheet |
createEmptySheet(java.lang.String name)
Create a new worksheet. |
void |
createEmptySheets(int sheetCount)
Create workbook with specified number of worksheets. |
void |
createEmptySheets(java.lang.String[] sheetNames)
Create workbook with specified names of worksheets. |
ExcelFont |
createFont()
Creates a font object and adds it to the workbook. |
ExcelFont |
createFont(java.awt.Font font)
Creates a font object and add it to the workbook. |
PivotStyle |
createPivotStyle()
|
void |
dispose()
|
CellRange[] |
findAllBool(boolean boolValue)
Finds the cell with the input bool. |
CellRange[] |
findAllDateTime(java.util.Date dateTimeValue)
Finds the cell with the input datetime. |
CellRange[] |
findAllNumber(double doubleValue,
boolean formulaValue)
Finds the cell with the input double. |
CellRange[] |
findAllString(java.lang.String stringValue,
boolean formula,
boolean formulaValue)
Finds the cell with the input string. |
CellRange |
findBool(boolean boolValue)
Finds the cell with the input bool. |
CellRange |
findDateTime(java.util.Date dateTimeValue)
Finds the cell with the input datetime. |
CellRange |
findNumber(double doubleValue,
boolean formulaValue)
Finds the cell with the input number. |
CellRange |
findString(java.lang.String stringValue,
boolean formula,
boolean formulaValue)
Finds the cell with the input string. |
Worksheet |
getActiveSheet()
Returns an object that represents the active sheet (the sheet on top) in the active workbook or in the specified window or workbook. |
int |
getActiveSheetIndex()
Gets index of the active worksheet. |
AddInFunctionsCollection |
getAddInFunctions()
Returns collection of add-in functions. |
boolean |
getAllow3DRangesInDataValidation()
Indicates whether to allow usage of 3D ranges in DataValidation list property (MS Excel doesn't allow). |
ExcelCalculationMode |
getCalculationMode()
Get calculation mode. |
ChartsCollection |
getCharts()
Returns a Sheets collection that represents all the chart sheets in the specified workbook. |
ChartSheet |
getChartSheetByName(java.lang.String name)
|
java.util.ArrayList |
getChartsheets()
|
java.lang.String |
getCodeName()
Name which used by macros to access to workbook items. |
java.awt.Color[] |
getColors()
Returns colors in the palette for the workbook. |
ConverterSetting |
getConverterSetting()
Get converter setting |
ICustomDocumentProperties |
getCustomDocumentProperties()
Returns collection that represents all the custom document properties for the specified workbook. |
java.lang.String[] |
getCustomFontFilePaths()
Returns the custom path of font files. |
java.util.Hashtable |
getCustomFontParsedResult()
Get result that parse the custom path of font files |
java.util.Hashtable |
getCustomTableStyles()
|
DataSorter |
getDataSorter()
Gets data sorter to sort the data. |
boolean |
getDate1904()
True if the workbook uses the 1904 date system. |
java.nio.charset.Charset |
getDefaultCharset()
default Charset = utf-8 |
java.lang.String |
getDefaultFontName()
Returns the name of the default font. |
double |
getDefaultFontSize()
Returns the default font size. |
boolean |
getDisableMacrosStart()
Allows users to disable load of macros from document. |
BuiltInDocumentProperties |
getDocumentProperties()
Returns a BuiltInDocumentProperties collection that represents all the built-in document properties for the specified workbook. |
java.lang.String |
getFileName()
Gets file name. |
MarkerDesigner |
getMarkerDesigner()
|
ExcelColors |
getMatchingColor(java.awt.Color color)
Find best matching Color in workbook palette. |
ExcelColors |
getMatchingColor(int r,
int g,
int b)
Find best matching Color in workbook palette. |
int |
getMaxDigitWidth()
|
INameRanges |
getNameRanges()
Gets names collection that represents all the names in the specified workbook |
IXLSRange |
getOleSize()
get the size of the visible range of cells when this workbook is displyed as an embedded obect in another document; |
java.lang.String |
getOpenPassword()
Returns password to encrypt document. |
boolean |
getOptimizeImport()
Indicates whether to optimize Import data. |
java.awt.Color |
getPaletteColor(ExcelColors color)
Gets excel color from workbook palette. |
PivotCachesCollection |
getPivotCaches()
|
boolean |
getPrintUsingImageMode()
get print by using image mode |
boolean |
getReadOnly()
Indicates whether the workbook has been opened as Read-only. |
int |
getSelectedTab()
Gets tab index of selected. |
boolean |
getShowTabs()
Gets a value whether the Workbook tabs are displayed. |
java.util.List<java.util.Map<PageColRow>> |
getSplitPageInfo()
|
DataTable |
getSplitPageTable(Workbook wb)
|
StylesCollection |
getStyles()
Returns a styles collection that represents all the styles in the specified workbook. |
ExcelVersion |
getVersion()
|
WorksheetsCollection |
getWorksheets()
Returns a sheets collection that represents all the worksheets in the specified workbook. |
boolean |
hasMacros()
Indicates whether contains VBA macros. |
void |
hasMacros(boolean value)
Sets whether contains VBA macros. |
void |
initCalcEngine()
Initilize Calc engine |
boolean |
isCellProtection()
Indicates whether cells are protected. |
boolean |
isRightToLeft()
Indicates whether worksheet is displayed right to left. |
void |
isRightToLeft(boolean value)
Indicates whether worksheet is displayed right to left. |
boolean |
isSaved()
Indicates whether workbook changes have been saved. |
boolean |
isWindowProtection()
Indicates window is protected. |
void |
loadFromFile(java.lang.String fileName)
Loads a file and imports its data. |
void |
loadFromFile(java.lang.String fileName,
boolean preserveMode)
Loads a file and imports its data. |
void |
loadFromFile(java.lang.String fileName,
ExcelVersion version)
Loads a file and imports its data. |
void |
loadFromFile(java.lang.String fileName,
java.lang.String separator)
Loads text files stream with user defined separator. |
void |
loadFromFile(java.lang.String fileName,
java.lang.String separator,
int row,
int column)
Loads text files with user defined separator. |
void |
loadFromFile(java.lang.String fileName,
java.lang.String separator,
int row,
int column,
ExcelVersion version)
Loads text files with user defined separator. |
void |
loadFromStream(java.io.InputStream stream)
Loads workbook from the stream. |
void |
loadFromStream(java.io.InputStream stream,
boolean loadStyles)
Load workbook from the stream. |
void |
loadFromStream(java.io.InputStream stream,
ExcelVersion version)
Load workbook from the stream. |
void |
loadFromStream(java.io.InputStream stream,
java.lang.String separator,
int row,
int column)
Loads text files stream with user defined separator.max row 60000. |
void |
loadFromStream(java.io.InputStream stream,
java.lang.String separator,
int row,
int column,
ExcelVersion version)
Loads text files stream with user defined separator. |
void |
loadFromXml(java.io.InputStream stream)
Loads a xml file and imports its data. |
void |
loadFromXml(java.lang.String fileName)
Loads a xml file and imports its data. |
void |
pasteFromClipboard()
Copies workbook and all its worksheets from the clipboard. |
double |
pixelsToColumnWidth(double pixels)
Converts column width in pixels into column width in characters. |
void |
protect(java.lang.String passwordToOpen)
Protects file, also protects workbook window and structure. |
void |
protect(java.lang.String passwordToOpen,
boolean bIsProtectWindow,
boolean bIsProtectContent)
Protects file,also indicates whether protects workbook window and structure or not |
void |
protectWorkbook(boolean bIsProtectWindow,
boolean bIsProtectContent,
java.lang.String password)
Sets protection for workbook. |
void |
replace(java.lang.String oldValue,
DataColumn newValues,
boolean includeColumnName)
Replaces cell's value from data column values. |
void |
replace(java.lang.String oldValue,
DataTable newValues,
boolean includeColumnName)
Replaces cell's value from data table values. |
void |
replace(java.lang.String oldValue,
java.util.Date newValue)
Replaces cell's value by specified value. |
void |
replace(java.lang.String oldValue,
double newValue)
Replaces cell's value by specified value. |
void |
replace(java.lang.String oldValue,
double[] newValues,
boolean isVertical)
Replaces cell's value from array. |
void |
replace(java.lang.String oldValue,
int[] newValues,
boolean isVertical)
Replaces cell's value from array. |
void |
replace(java.lang.String oldValue,
java.lang.String newValue)
Replaces cell's value by specified value. |
void |
replace(java.lang.String oldValue,
java.lang.String[] newValues,
boolean isVertical)
Replaces cell's value from array. |
void |
resetPalette()
Resets the color palette to the default colors. |
void |
save()
Saves changes to the specified workbook |
java.awt.image.BufferedImage[] |
saveAsImage(float dpiX,
float dpiY)
Save workbook to image. |
java.awt.image.BufferedImage |
saveAsImage(int sheetIndex,
float dpiX,
float dpiY)
Save workbook to image. |
void |
saveAsTemplate(java.lang.String fileName)
Save workbook as template to file. |
void |
saveAsXml(java.io.InputStream stream)
Save workbook as XML format to stream. |
void |
saveAsXml(java.lang.String fileName)
Save workbook to an xml data file. |
java.awt.image.BufferedImage |
saveChartAsImage(ChartSheet chartSheet)
Save chart to image. |
java.awt.image.BufferedImage[] |
saveChartAsImage(Worksheet worksheet)
Save chart to images. |
java.awt.image.BufferedImage |
saveChartAsImage(Worksheet worksheet,
int chartIndex)
Saves chart to image. |
void |
saveToFile(java.lang.String fileName)
Saves changes to the workbook in a different file |
void |
saveToFile(java.lang.String fileName,
ExcelVersion version)
Saves changes to the workbook in a different file |
void |
saveToFile(java.lang.String fileName,
FileFormat fileFormat)
Saves changes to the workbook in a different file |
void |
saveToFile(java.lang.String fileName,
java.lang.String separator)
Saves changes to the workbook in a different file |
void |
saveToStream(java.io.OutputStream stream)
Saves workbook the stream |
void |
saveToStream(java.io.OutputStream stream,
FileFormat fileFormat)
Saves workbook to stream. |
void |
saveToStream(java.io.OutputStream stream,
java.lang.String separator)
Save workbook the stream. |
void |
setActiveSheetIndex(int value)
Sets index of the active worksheet. |
void |
setAllow3DRangesInDataValidation(boolean value)
Indicates whether to allow usage of 3D ranges in DataValidation list property (MS Excel doesn't allow). |
void |
setCalculationMode(ExcelCalculationMode value)
Set calculation mode. |
void |
setCodeName(java.lang.String value)
Name which used by macros to access to workbook items. |
void |
setConverterSetting(ConverterSetting value)
|
void |
setCustomFontFilePaths(java.lang.String[] value)
Sets the custom path of font files. |
void |
setDate1904(boolean value)
Set if the workbook uses the 1904 date system. |
void |
setDefaultCharset(java.nio.charset.Charset defaultCharset)
|
void |
setDefaultFontName(java.lang.String value)
Sets the name of the default font. |
void |
setDefaultFontSize(double value)
Sets the default font size. |
void |
setDisableMacrosStart(boolean value)
Allows users to disable load of macros from document. |
void |
setMaxDigitWidth(int w)
|
void |
setOleSize(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
set the size of the visible range of cells when this workbook is displyed as an embedded obect in another document; |
void |
setOpenPassword(java.lang.String openPassword)
Sets password to encrypt document. |
void |
setOptimizeImport(boolean value)
Indicates whether to optimize Import data. |
void |
setPrintUsingImageMode(boolean usingImageMode)
set print by using image mode |
void |
setSelectedTab(int value)
Sets tab index of selected. |
void |
setShowTabs(boolean value)
Sets a value whether the Workbook tabs are displayed. |
void |
setVersion(ExcelVersion version)
|
void |
setWriteProtectionPassword(java.lang.String password)
Sets write protection password. |
void |
unProtect()
Unprotects file also upprotect workbook window and structure |
void |
unProtect(java.lang.String bookWindowAndStructurePassword)
unprotect file also upprotect workbook window and structure |
void |
unProtectWorkbook(java.lang.String password)
unprotect workbook window and structure |
Constructor Detail |
---|
public Workbook()
Method Detail |
---|
public WorksheetsCollection getWorksheets()
public INameRanges getNameRanges()
public Worksheet getActiveSheet()
public boolean getAllow3DRangesInDataValidation()
public void setAllow3DRangesInDataValidation(boolean value)
value
- public int getActiveSheetIndex()
public void setActiveSheetIndex(int value)
value
- public AddInFunctionsCollection getAddInFunctions()
public ExcelCalculationMode getCalculationMode()
public void setCalculationMode(ExcelCalculationMode value)
value
- public DataSorter getDataSorter()
public java.lang.String getCodeName()
public void setCodeName(java.lang.String value)
public java.awt.Color[] getColors()
public ConverterSetting getConverterSetting()
public void setConverterSetting(ConverterSetting value)
public boolean getDate1904()
public void setDate1904(boolean value)
value
- public java.lang.String getDefaultFontName()
public void setDefaultFontName(java.lang.String value)
value
- public double getDefaultFontSize()
public void setDefaultFontSize(double value)
value
- public java.lang.String[] getCustomFontFilePaths()
public void setCustomFontFilePaths(java.lang.String[] value)
value
- public java.util.Hashtable getCustomFontParsedResult()
public boolean getDisableMacrosStart()
public void setDisableMacrosStart(boolean value)
value
- public java.lang.String getFileName()
public boolean hasMacros()
public void hasMacros(boolean value)
value
- public boolean isCellProtection()
public boolean isRightToLeft()
public void isRightToLeft(boolean value)
public boolean isSaved()
public boolean isWindowProtection()
public MarkerDesigner getMarkerDesigner()
public int getMaxDigitWidth()
public java.lang.String getOpenPassword()
public void setOpenPassword(java.lang.String openPassword)
openPassword
- public boolean getOptimizeImport()
public void setOptimizeImport(boolean value)
public PivotCachesCollection getPivotCaches()
public boolean getReadOnly()
public int getSelectedTab()
public void setSelectedTab(int value)
value
- public boolean getShowTabs()
public void setShowTabs(boolean value)
value
- public StylesCollection getStyles()
public ExcelVersion getVersion()
public void setVersion(ExcelVersion version)
public ChartsCollection getCharts()
public java.util.ArrayList getChartsheets()
public ICustomDocumentProperties getCustomDocumentProperties()
public java.util.Hashtable getCustomTableStyles()
public BuiltInDocumentProperties getDocumentProperties()
public void loadFromFile(java.lang.String fileName)
fileName
- File name.public void loadFromFile(java.lang.String fileName, boolean preserveMode)
fileName
- File namepreserveMode
- Preserve modepublic void loadFromFile(java.lang.String fileName, ExcelVersion version)
fileName
- File nameversion
- Excel versionpublic void loadFromFile(java.lang.String fileName, java.lang.String separator)
fileName
- File nameseparator
- Delimiter of text file.public void loadFromFile(java.lang.String fileName, java.lang.String separator, int row, int column)
fileName
- File name.separator
- Delimiter of text file.row
- Start row.column
- Start column.public void loadFromFile(java.lang.String fileName, java.lang.String separator, int row, int column, ExcelVersion version)
fileName
- File name.separator
- Delimiter of text file.row
- Start row.column
- Start column.version
- Workbook versionpublic void loadFromStream(java.io.InputStream stream)
stream
- Stream contains data.public void loadFromStream(java.io.InputStream stream, boolean loadStyles)
stream
- Stream contains data.loadStyles
- Indicates whether loads styles.public void loadFromStream(java.io.InputStream stream, ExcelVersion version)
stream
- Stream contains dataversion
- Excel versionpublic void loadFromStream(java.io.InputStream stream, java.lang.String separator, int row, int column)
stream
- File stream.separator
- Delimiter of text file.row
- Start row.column
- Start column.public void loadFromStream(java.io.InputStream stream, java.lang.String separator, int row, int column, ExcelVersion version)
stream
- File stream.separator
- Delimiter of text file.row
- Start row.column
- Start column.version
- Excel version.public void loadFromXml(java.lang.String fileName)
fileName
- File name.public void loadFromXml(java.io.InputStream stream)
stream
- Stream contains data.public void saveToFile(java.lang.String fileName)
fileName
- File name.public void saveToFile(java.lang.String fileName, FileFormat fileFormat)
fileName
- File namefileFormat
- File formatpublic void saveToFile(java.lang.String fileName, java.lang.String separator)
fileName
- File name.separator
- public void dispose()
public void saveToFile(java.lang.String fileName, ExcelVersion version)
fileName
- File nameversion
- Excel versionpublic void addPivotTableStyle(PivotTableStyle pts)
public java.lang.Object calculateFormulaValue(java.lang.String text)
text
-
public void calculateAllValue()
public void changePaletteColor(java.awt.Color color, int index)
color
- Color structureindex
- Palette index,Value should be from 0 to 55public double columnWidthToPixels(double columnWidth)
columnWidth
- Column width in characters.
public boolean containsFont(ExcelFont font)
font
-
public void copyToClipboard()
public void copyToClipboard(Worksheet worksheet)
worksheet
- public Worksheet createEmptySheet()
public Worksheet createEmptySheet(java.lang.String name)
name
- Sheet name.
public void createEmptySheets(int sheetCount)
sheetCount
- public void createEmptySheets(java.lang.String[] sheetNames)
sheetNames
- public ExcelFont createFont()
public ExcelFont createFont(java.awt.Font font)
font
- Font to add
public PivotStyle createPivotStyle()
public CellRange[] findAllBool(boolean boolValue)
boolValue
- Bool value to search for
public CellRange[] findAllNumber(double doubleValue, boolean formulaValue)
doubleValue
- Double value to search for.formulaValue
- Indicates whether includes formula value to search for.
public CellRange[] findAllString(java.lang.String stringValue, boolean formula, boolean formulaValue)
stringValue
- String value to search forformula
- Indicates whether includes formula to search for.formulaValue
- Indicates whether includes formula value to search for.
public CellRange[] findAllDateTime(java.util.Date dateTimeValue)
dateTimeValue
-
public CellRange findBool(boolean boolValue)
boolValue
- Bool value to search for.
public CellRange findNumber(double doubleValue, boolean formulaValue)
doubleValue
- Double value to search for.formulaValue
- Indicates whether includes formula value to search for.
public CellRange findString(java.lang.String stringValue, boolean formula, boolean formulaValue)
stringValue
- String value to search for.formula
- Indicates whether includes formula to search for.formulaValue
- Indicates whether includes formula value to search for.
public CellRange findDateTime(java.util.Date dateTimeValue)
dateTimeValue
- Datetime value to search for.
public ExcelColors getMatchingColor(java.awt.Color color)
color
- Color to search for.
public ExcelColors getMatchingColor(int r, int g, int b)
r
- Red color.g
- Green color.b
- Blue color.
public java.awt.Color getPaletteColor(ExcelColors color)
color
- Index from palette array.
public java.util.List<java.util.Map<PageColRow>> getSplitPageInfo()
public DataTable getSplitPageTable(Workbook wb)
public void initCalcEngine()
public static boolean bookIsPasswordProtected(java.lang.String fileName)
fileName
-
public void pasteFromClipboard()
public double pixelsToColumnWidth(double pixels)
pixels
- Column width in pixels.
public void protect(java.lang.String passwordToOpen)
passwordToOpen
- password to open file.public void protect(java.lang.String passwordToOpen, boolean bIsProtectWindow, boolean bIsProtectContent)
passwordToOpen
- password to open file.bIsProtectWindow
- Indicates if protect workbook window.bIsProtectContent
- Indicates if protect workbook content.public void protectWorkbook(boolean bIsProtectWindow, boolean bIsProtectContent, java.lang.String password)
bIsProtectWindow
- Indicates if protect workbook window.bIsProtectContent
- Indicates if protect workbook content.password
- passwordpublic void replace(java.lang.String oldValue, DataColumn newValues, boolean includeColumnName)
oldValue
- Value to replace.newValues
- New data.includeColumnName
- Indicates whether includes column name.public void replace(java.lang.String oldValue, DataTable newValues, boolean includeColumnName)
oldValue
- Value to replace.newValues
- New data.includeColumnName
- Indicates whether includes column name.public void replace(java.lang.String oldValue, java.util.Date newValue)
oldValue
- Value to replace.newValue
- New valuepublic void replace(java.lang.String oldValue, double newValue)
oldValue
- Value to replace.newValue
- New value.public void replace(java.lang.String oldValue, double[] newValues, boolean isVertical)
oldValue
- Value to replace.newValues
- New values.isVertical
- Indicates whether new values should be inserted vertically.public void replace(java.lang.String oldValue, int[] newValues, boolean isVertical)
oldValue
- Value to replace.newValues
- New values.isVertical
- Indicates whether new values should be inserted vertically.public void replace(java.lang.String oldValue, java.lang.String newValue)
oldValue
- Value to replace.newValue
- New valuepublic void replace(java.lang.String oldValue, java.lang.String[] newValues, boolean isVertical)
oldValue
- Value to replace.newValues
- New values.isVertical
- Indicates whether new values should be inserted vertically.public void resetPalette()
public void save()
public java.awt.image.BufferedImage[] saveAsImage(float dpiX, float dpiY)
dpiX
- Dpi XdpiY
- Dpi Y
public java.awt.image.BufferedImage saveAsImage(int sheetIndex, float dpiX, float dpiY)
sheetIndex
- sheet IndexdpiX
- Dpi XdpiY
- Dpi Y
public void saveAsXml(java.lang.String fileName)
fileName
- XML file name.public void saveAsXml(java.io.InputStream stream)
stream
- Stream object.public java.awt.image.BufferedImage saveChartAsImage(ChartSheet chartSheet)
chartSheet
- chart sheet
public java.awt.image.BufferedImage[] saveChartAsImage(Worksheet worksheet)
worksheet
- worksheet instance
public java.awt.image.BufferedImage saveChartAsImage(Worksheet worksheet, int chartIndex)
worksheet
- Work sheetchartIndex
- Chart index
public void saveAsTemplate(java.lang.String fileName)
fileName
- public void saveToStream(java.io.OutputStream stream)
stream
- Stream objectpublic void saveToStream(java.io.OutputStream stream, FileFormat fileFormat)
stream
- fileFormat
- public void saveToStream(java.io.OutputStream stream, java.lang.String separator)
stream
- Stream object.separator
- Separatorpublic void setMaxDigitWidth(int w)
public void setOleSize(int firstRow, int firstColumn, int lastRow, int lastColumn)
firstRow
- the visible range's first row indexfirstColumn
- the visible range's first column indexlastRow
- the visible range's last row indexlastColumn
- the visible range's last column indexpublic void setWriteProtectionPassword(java.lang.String password)
password
- Password to setpublic void unProtect()
public void unProtect(java.lang.String bookWindowAndStructurePassword)
bookWindowAndStructurePassword
- password for protect workbook window and structurepublic void unProtectWorkbook(java.lang.String password)
password
- passwordpublic ChartSheet getChartSheetByName(java.lang.String name)
public IXLSRange getOleSize()
public boolean getPrintUsingImageMode()
public void setPrintUsingImageMode(boolean usingImageMode)
public java.nio.charset.Charset getDefaultCharset()
public void setDefaultCharset(java.nio.charset.Charset defaultCharset)
defaultCharset
- charset
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |