类 Workbook
java.lang.Object
com.grapecity.documents.excel.Workbook
- 所有已实现的接口:
IWorkbook
Represents a workbook.
-
构造器概要
-
方法概要
修饰符和类型方法说明static void
Add custom function into the function set.static void
AddCustomFunction
(CustomFunction func, boolean canOverride) Add custom function into the function set.void
addDataSource
(String name, Object dataSource) Add data source for templatevoid
Calculates formulas in the workbook as needed.void
dirty()
Designates all the formulas of the workbook to be recalculated when the next calculation occurs.Process the template and return the instance of report workbook.generateReport
(IWorksheet... worksheets) Process the template and return the instance of report workbook.Gets the active sheet.boolean
已过时。Gets the author.boolean
Determines whether to parse automatically when setting range value to string value.boolean
Determines whether to round the number to 15 significant figures when getting the value.Returns an object that represents the view settings of this workbook.Gets a collection that represents all the built-in document properties of the workbook.Gets the culture info of workbook, default is Locale.getDefault().Gets a collection that represents all the custom document properties of the workbook.Gets a collection that represents all the custom document properties of the workbook.Specifies the table style that is used as the default TableStyle.boolean
Gets whether update the dirty state of the formula cells immediately when changing the value of a cell.boolean
Specifies whether the calculation engine is working.Returns the name of the workbook, including its path on disk.final IGraphicsInfo
Provides graphics information.Filters data in a workbook based on a cell icon from the IconSets collection.getName()
Gets a string value that represents the name of the workbook.getNames()
Returns theINames
collection that represents all the names in thespecified workbook (including all worksheet-specific names).static String[]
getNames
(InputStream fileStream) Gets all sheet names and tables names that will be used as the parameter source of ImportData.
If the name is a table name, the worksheet name is qualified before the table name, such as "Sheet1!static String[]
Gets all sheet names and tables names that will be used as the parameter source of ImportData.
If the name is a table name, the worksheet name is qualified before the table name, such as "Sheet1!Returns theIExcelOptions
object that represents some settings to control workbook behavior.getPath()
Gets a string that represents the path to the workbook file that this workbook object represents.Gets a PivotCaches collection that represents all the PivotTable caches in the specified workbook.boolean
True if the order of the sheets in the workbook is protected.boolean
True if the windows of the workbook are protected.Gets the reference style.boolean
Determines whether to reset adjacent range's border when setting border for a range.final IWorksheets
Returns a IWorksheets collection that represents all the selected sheets in the specified workbook.Gets a collection of Signature objects that correspond to the digital signature attached to a document.Gets theISlicerCaches
object associated with the workbook.Provides access to the collection of cell styles in the current workbook.Gets the table styles used in the current workbook.static IJsonSerializer
Gets JSON serializer for custom typegetTheme()
Returns an instance of ITheme which provides access to the theme associated with a workbook.static IJsonSerializer
Gets JSON serializer for custom typeGets a collection of worksheets contained in the workbook.Provides access to the workbook write protection options.static Object[][]
importData
(InputStream fileStream, String sourceName) Import all the data of the specified source of the file.static Object[][]
importData
(InputStream fileStream, String worksheetName, int row, int column, int rowCount, int columnCount) Import the data of a specified range from a fileStream.static Object[][]
importData
(String fileName, String sourceName) Import all the data of the specified source of the file.static Object[][]
importData
(String fileName, String worksheetName, int row, int column, int rowCount, int columnCount) Import the data of a specified range from a file.boolean
isEncryptedFile
(InputStream fileStream) Specifies whether the file is password protected.boolean
isEncryptedFile
(String fileName) Specifies whether the file is password protected.final void
open
(InputStream fileStream) Opens the specified excel file stream.void
open
(InputStream fileStream, OpenFileFormat fileFormat) Opens the stream with specified file format.void
open
(InputStream fileStream, OpenOptionsBase options) Opens the stream with specified options, the open options can be XlsxOpenOptions, CsvOpenOptions.void
open
(InputStream fileStream, String password) 已过时。void
Opens the specified excel filevoid
open
(String fileName, OpenFileFormat fileFormat) Opens the file with specified file format.void
open
(String fileName, OpenOptionsBase options) Opens the file with specified options, the open options can be XlsxOpenOptions, CsvOpenOptions.void
已过时。Useopen(String,OpenOptionsBase)
insteadvoid
Start to process the templatevoid
protect()
Protects a workbook so that it cannot be modified.void
protect
(boolean structure) Protects a workbook so that it cannot be modified.void
protect
(boolean structure, boolean windows) Protects a workbook so that it cannot be modified.void
Protects a workbook so that it cannot be modified.void
Protects a workbook so that it cannot be modified.void
Protects a workbook so that it cannot be modified.void
save
(OutputStream outputStream) Saves the workbook to the stream.void
save
(OutputStream fileStream, SaveFileFormat fileFormat) Saves workbook to stream with specified file format.void
save
(OutputStream fileStream, SaveOptionsBase options) Saves workbook to stream with specified options, the option can be XlsxSaveOptions, CsvSaveOptionsvoid
save
(OutputStream outputStream, String password) 已过时。Usesave(OutputStream,SaveOptionsBase)
insteadvoid
Saves the workbook to the disk.void
save
(String fileName, SaveFileFormat fileFormat) Saves workbook to file with specified file format.void
save
(String fileName, SaveOptionsBase options) Saves workbook to file with specified options, the option can be XlsxSaveOptions, CsvSaveOptionsvoid
已过时。Usesave(String,SaveOptionsBase)
insteadvoid
setAllowDynamicArray
(boolean value) 已过时。void
Sets the author.void
setAutoParse
(boolean value) Sets whether to automatically parse when setting a range value to a string value.void
setAutoRoundValue
(boolean value) Sets whether to round the number to 15 significant figures when getting the value.void
setCulture
(Locale value) Sets culture info for the workbook.void
setDefaultTableStyle
(String value) Sets the table style name from theITableStyleCollection
collectionthat is used as the default TableStyle.void
setDeferUpdateDirtyState
(boolean value) Sets whether update the dirty state of the formula cells immediately when changing the value of a cell.void
setEnableCalculation
(boolean value) Sets whether the calculation engine is valid.final void
setGraphicsInfo
(IGraphicsInfo value) Provides graphics information.static void
SetLicenseFile
(String licenseFilePath) For licenses of the Chinese market, apply deployment license or unlimited dev license from file.static void
SetLicenseKey
(String key) Sets license for all workbook instances.void
Sets a string value that represents the name of the workbook.void
Sets a string that represents the path to the workbook file that this workbook object represents.void
setReferenceStyle
(ReferenceStyle value) Sets the reference style.void
setResetAdjacentRangeBorder
(boolean value) Determines whether to reset adjacent range's border when setting border for a range.static void
Sets JSON serializer for custom type in from/to JSON.void
Sets the theme applied to the current workbook.static void
Sets JSON serializer for custom type in from/to JSON.toJson()
Generates a JSON string from the workbook.toJson
(SerializationOptions serializationOptions) Generates a JSON string from the workbook.void
toJson
(OutputStream stream) Generates a zipped JSON string from the workbook.void
toJson
(OutputStream stream, SerializationOptions serializationOptions) Generates a JSON stream from a workbook.void
Removes protection from the workbook.void
Removes protection from the workbook.void
updateExcelLink
(String name) Updates a excel link.void
updateExcelLink
(String name, IWorkbook sourceWorkbook) Updates a excel link.void
Updates all the excel links.
-
构造器详细资料
-
Workbook
public Workbook()Creates the workbook. -
Workbook
Creates a workbook and apply the specified license.Important: For licenses of the Chinese market, use
SetLicenseFile
orset license in theGCEXCEL_JAVA_DEPLOY_LICENSE_V5
environment variable instead.- 参数:
licenseKey
- license key
-
-
方法详细资料
-
getAllowDynamicArray
已过时。Gets whether allow dynamic array formula. This method is obsoleted, please use getFormula2() to get dynamic array formula.- 指定者:
getAllowDynamicArray
在接口中IWorkbook
-
setAllowDynamicArray
已过时。Sets whether allow dynamic array formula.This method is obsoleted, please use setFormula2() to set dynamic array formula.- 指定者:
setAllowDynamicArray
在接口中IWorkbook
-
getDeferUpdateDirtyState
public boolean getDeferUpdateDirtyState()Gets whether update the dirty state of the formula cells immediately when changing the value of a cell.- 指定者:
getDeferUpdateDirtyState
在接口中IWorkbook
-
setDeferUpdateDirtyState
public void setDeferUpdateDirtyState(boolean value) Sets whether update the dirty state of the formula cells immediately when changing the value of a cell.- 指定者:
setDeferUpdateDirtyState
在接口中IWorkbook
-
getName
Gets a string value that represents the name of the workbook. -
setName
Sets a string value that represents the name of the workbook. -
getFullName
Returns the name of the workbook, including its path on disk.- 指定者:
getFullName
在接口中IWorkbook
-
getPath
Gets a string that represents the path to the workbook file that this workbook object represents. -
setPath
Sets a string that represents the path to the workbook file that this workbook object represents. -
open
Opens the specified excel file -
open
已过时。Useopen(String,OpenOptionsBase)
insteadOpens the specified excel file -
open
Opens the file with specified file format. -
open
Opens the file with specified options, the open options can be XlsxOpenOptions, CsvOpenOptions. -
open
Opens the specified excel file stream. -
open
已过时。Useopen(InputStream,OpenOptionsBase)
insteadOpens the specified excel file stream. -
open
Opens the stream with specified file format. -
open
Opens the stream with specified options, the open options can be XlsxOpenOptions, CsvOpenOptions. -
save
Saves the workbook to the disk. -
save
已过时。Usesave(String,SaveOptionsBase)
insteadSaves data to the specified excel file. -
save
Saves workbook to file with specified options, the option can be XlsxSaveOptions, CsvSaveOptions -
save
Saves workbook to file with specified file format. -
save
Saves the workbook to the stream. -
save
已过时。Usesave(OutputStream,SaveOptionsBase)
insteadSaves data to the specified excel file stream. -
save
Saves workbook to stream with specified options, the option can be XlsxSaveOptions, CsvSaveOptions -
save
Saves workbook to stream with specified file format. -
getOptions
Returns theIExcelOptions
object that represents some settings to control workbook behavior.- 指定者:
getOptions
在接口中IWorkbook
-
getBuiltInDocumentProperties
Gets a collection that represents all the built-in document properties of the workbook.- 指定者:
getBuiltInDocumentProperties
在接口中IWorkbook
-
getCustomDocumentProperties
Gets a collection that represents all the custom document properties of the workbook.- 指定者:
getCustomDocumentProperties
在接口中IWorkbook
-
getCustomViews
Gets a collection that represents all the custom document properties of the workbook.- 指定者:
getCustomViews
在接口中IWorkbook
-
getWriteProtection
Provides access to the workbook write protection options.- 指定者:
getWriteProtection
在接口中IWorkbook
-
getSignatures
Gets a collection of Signature objects that correspond to the digital signature attached to a document.- 指定者:
getSignatures
在接口中IWorkbook
-
getTagJsonSerializer
Gets JSON serializer for custom type- 返回:
-
setTagJsonSerializer
Sets JSON serializer for custom type in from/to JSON.- 参数:
value
-
-
getValueJsonSerializer
Gets JSON serializer for custom type- 返回:
-
setValueJsonSerializer
Sets JSON serializer for custom type in from/to JSON.- 参数:
value
-
-
getAutoParse
public boolean getAutoParse()Determines whether to parse automatically when setting range value to string value.- 指定者:
getAutoParse
在接口中IWorkbook
-
setAutoParse
public void setAutoParse(boolean value) Sets whether to automatically parse when setting a range value to a string value.- 指定者:
setAutoParse
在接口中IWorkbook
-
getAutoRoundValue
public boolean getAutoRoundValue()Determines whether to round the number to 15 significant figures when getting the value.- 指定者:
getAutoRoundValue
在接口中IWorkbook
-
setAutoRoundValue
public void setAutoRoundValue(boolean value) Sets whether to round the number to 15 significant figures when getting the value.- 指定者:
setAutoRoundValue
在接口中IWorkbook
-
getBookView
Returns an object that represents the view settings of this workbook.- 指定者:
getBookView
在接口中IWorkbook
-
getProtectStructure
public boolean getProtectStructure()True if the order of the sheets in the workbook is protected. Read-only Boolean.- 指定者:
getProtectStructure
在接口中IWorkbook
-
getProtectWindows
public boolean getProtectWindows()True if the windows of the workbook are protected. Read-only Boolean.- 指定者:
getProtectWindows
在接口中IWorkbook
-
getReferenceStyle
Gets the reference style.- 指定者:
getReferenceStyle
在接口中IWorkbook
-
setReferenceStyle
Sets the reference style.- 指定者:
setReferenceStyle
在接口中IWorkbook
-
getWorksheets
Gets a collection of worksheets contained in the workbook.- 指定者:
getWorksheets
在接口中IWorkbook
-
getActiveSheet
Gets the active sheet.- 指定者:
getActiveSheet
在接口中IWorkbook
-
getTheme
Returns an instance of ITheme which provides access to the theme associated with a workbook. -
setTheme
Sets the theme applied to the current workbook. -
getIconSets
Filters data in a workbook based on a cell icon from the IconSets collection.- 指定者:
getIconSets
在接口中IWorkbook
-
getDefaultTableStyle
Specifies the table style that is used as the default TableStyle.- 指定者:
getDefaultTableStyle
在接口中IWorkbook
-
setDefaultTableStyle
Sets the table style name from theITableStyleCollection
collectionthat is used as the default TableStyle.- 指定者:
setDefaultTableStyle
在接口中IWorkbook
-
getCulture
Gets the culture info of workbook, default is Locale.getDefault().- 指定者:
getCulture
在接口中IWorkbook
-
setCulture
Sets culture info for the workbook. Which influences the feature related culture.- 指定者:
setCulture
在接口中IWorkbook
-
getEnableCalculation
public boolean getEnableCalculation()Specifies whether the calculation engine is working.- 指定者:
getEnableCalculation
在接口中IWorkbook
-
setEnableCalculation
public void setEnableCalculation(boolean value) Sets whether the calculation engine is valid.- 指定者:
setEnableCalculation
在接口中IWorkbook
-
AddCustomFunction
Add custom function into the function set.- 参数:
func
- the custom function instance.
-
AddCustomFunction
Add custom function into the function set.- 参数:
func
- the custom function instance.canOverride
- override the exist function.
-
getPivotCaches
Gets a PivotCaches collection that represents all the PivotTable caches in the specified workbook.- 指定者:
getPivotCaches
在接口中IWorkbook
-
getSlicerCaches
Gets theISlicerCaches
object associated with the workbook.- 指定者:
getSlicerCaches
在接口中IWorkbook
-
calculate
public void calculate()Calculates formulas in the workbook as needed. -
dirty
public void dirty()Designates all the formulas of the workbook to be recalculated when the next calculation occurs. -
getStyles
Provides access to the collection of cell styles in the current workbook. -
getTableStyles
Gets the table styles used in the current workbook.- 指定者:
getTableStyles
在接口中IWorkbook
-
getNames
Returns theINames
collection that represents all the names in thespecified workbook (including all worksheet-specific names). -
getAuthor
Gets the author. -
setAuthor
Sets the author. -
isEncryptedFile
Specifies whether the file is password protected.- 指定者:
isEncryptedFile
在接口中IWorkbook
- 参数:
fileName
- The file name.
-
isEncryptedFile
Specifies whether the file is password protected.- 指定者:
isEncryptedFile
在接口中IWorkbook
- 参数:
fileStream
- The file stream.
-
toJson
Generates a JSON string from the workbook. -
toJson
Generates a JSON string from the workbook.- 指定者:
toJson
在接口中IWorkbook
- 参数:
serializationOptions
- theSerializationOptions
object.- 返回:
- The JSON string
-
toJson
Generates a zipped JSON string from the workbook. -
toJson
Generates a JSON stream from a workbook.- 指定者:
toJson
在接口中IWorkbook
- 参数:
stream
- the output stream.serializationOptions
- theSerializationOptions
object.
-
protect
public void protect()Protects a workbook so that it cannot be modified. -
protect
public void protect(boolean structure) Protects a workbook so that it cannot be modified. -
protect
public void protect(boolean structure, boolean windows) Protects a workbook so that it cannot be modified.- 指定者:
protect
在接口中IWorkbook
- 参数:
structure
- True to protect the structure of the workbook (To prevent otherusers from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets).windows
- True to prevent users from moving, resizing, or closing theworkbook window, or hide/unhide windows. This option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac.
-
protect
Protects a workbook so that it cannot be modified. -
protect
Protects a workbook so that it cannot be modified. -
protect
Protects a workbook so that it cannot be modified.- 指定者:
protect
在接口中IWorkbook
- 参数:
password
- Password to protect the workbook.structure
- True to protect the structure of the workbook (To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets).windows
- True to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows. This option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac.
-
unprotect
public void unprotect()Removes protection from the workbook. -
unprotect
Removes protection from the workbook. -
addDataSource
Add data source for template- 指定者:
addDataSource
在接口中IWorkbook
- 参数:
name
- : the alias name of the data sourcedataSource
- : Can be object of ResultSet, Custom object and variable
-
processTemplate
public void processTemplate()Start to process the template- 指定者:
processTemplate
在接口中IWorkbook
-
generateReport
Process the template and return the instance of report workbook.- 指定者:
generateReport
在接口中IWorkbook
- 返回:
- The new
IWorkbook
object.
-
generateReport
Process the template and return the instance of report workbook.- 指定者:
generateReport
在接口中IWorkbook
- 参数:
worksheets
- IWorksheet collection that need to be processed.- 返回:
- The new
IWorkbook
object.
-
getResetAdjacentRangeBorder
public boolean getResetAdjacentRangeBorder()Determines whether to reset adjacent range's border when setting border for a range. The default value of this property is true- 指定者:
getResetAdjacentRangeBorder
在接口中IWorkbook
-
setResetAdjacentRangeBorder
public void setResetAdjacentRangeBorder(boolean value) Determines whether to reset adjacent range's border when setting border for a range. The default value of this property is true- 指定者:
setResetAdjacentRangeBorder
在接口中IWorkbook
- 参数:
value
-
-
SetLicenseKey
Sets license for all workbook instances.Important: For licenses of the Chinese market, use
SetLicenseFile
orset license in theGCEXCEL_JAVA_DEPLOY_LICENSE_V5
environment variable instead.- 参数:
key
- license key
-
SetLicenseFile
For licenses of the Chinese market, apply deployment license or unlimited dev license from file.This method shouldn't be called if your license was purchased from other markets.
- 参数:
licenseFilePath
- The file that contains license key
-
getGraphicsInfo
Provides graphics information. If this property doesn't have value, the workbook will use built-in graphic information.- 指定者:
getGraphicsInfo
在接口中IWorkbook
-
setGraphicsInfo
Provides graphics information. If this property doesn't have value, the workbook will use built-in graphic information.- 指定者:
setGraphicsInfo
在接口中IWorkbook
-
getSelectedSheets
Returns a IWorksheets collection that represents all the selected sheets in the specified workbook.- 指定者:
getSelectedSheets
在接口中IWorkbook
-
updateExcelLinks
public void updateExcelLinks()Updates all the excel links.- 指定者:
updateExcelLinks
在接口中IWorkbook
-
updateExcelLink
Updates a excel link.- 指定者:
updateExcelLink
在接口中IWorkbook
-
updateExcelLink
Updates a excel link.- 指定者:
updateExcelLink
在接口中IWorkbook
-
getNames
Gets all sheet names and tables names that will be used as the parameter source of ImportData.
If the name is a table name, the worksheet name is qualified before the table name, such as "Sheet1!Table1".- 参数:
fileName
- The path and name for the file.- 返回:
- An array of possible import names.
-
getNames
Gets all sheet names and tables names that will be used as the parameter source of ImportData.
If the name is a table name, the worksheet name is qualified before the table name, such as "Sheet1!Table1".- 参数:
fileStream
- The fileStream of a workbook.- 返回:
- An array of possible import names.
-
importData
Import all the data of the specified source of the file.- 参数:
fileName
- The path and name for the file.sourceName
- The name of the source data. The source name could be:
worksheet "Sheet1"
table "Sheet1!Table1"
range "Sheet1!A1:C5"- 返回:
- An array for the data.
-
importData
public static Object[][] importData(String fileName, String worksheetName, int row, int column, int rowCount, int columnCount) Import the data of a specified range from a file.- 参数:
fileName
- The path and name for the file.worksheetName
- The name of the worksheet.row
- The first row of the range.column
- The first column of the range.rowCount
- The count of the rows.columnCount
- The count of the columns.
-
importData
Import all the data of the specified source of the file.- 参数:
fileStream
- The fileStream of a workbook.sourceName
- The name of the source data. The source name could be:
worksheet "Sheet1"
table "Sheet1!Table1"
range "Sheet1!A1:C5"- 返回:
- An array for the data.
-
importData
public static Object[][] importData(InputStream fileStream, String worksheetName, int row, int column, int rowCount, int columnCount) Import the data of a specified range from a fileStream.- 参数:
fileStream
- The fileStream of a workbook.worksheetName
- The name of the worksheet.row
- The first row of the range.column
- The first column of the range.rowCount
- The count of the rows.columnCount
- The count of the columns.
-
open(InputStream,OpenOptionsBase)
instead