类 Workbook

java.lang.Object
com.grapecity.documents.excel.Workbook
所有已实现的接口:
IWorkbook

public final class Workbook extends Object implements IWorkbook
Represents a workbook.
  • 构造器详细资料

    • Workbook

      public Workbook()
      Creates the workbook.
    • Workbook

      public Workbook(String licenseKey)
      Creates a workbook and apply the specified license.

      Important: For licenses of the Chinese market, use SetLicenseFile orset license in the GCEXCEL_JAVA_DEPLOY_LICENSE_V5 environment variable instead.

      参数:
      licenseKey - license key
  • 方法详细资料

    • getAllowDynamicArray

      @Deprecated public boolean getAllowDynamicArray()
      已过时。
      Gets whether allow dynamic array formula. This method is obsoleted, please use getFormula2() to get dynamic array formula.
      指定者:
      getAllowDynamicArray 在接口中 IWorkbook
    • setAllowDynamicArray

      @Deprecated public void setAllowDynamicArray(boolean value)
      已过时。
      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

      public String getName()
      Gets a string value that represents the name of the workbook.
      指定者:
      getName 在接口中 IWorkbook
    • setName

      public void setName(String name)
      Sets a string value that represents the name of the workbook.
      指定者:
      setName 在接口中 IWorkbook
    • getFullName

      public String getFullName()
      Returns the name of the workbook, including its path on disk.
      指定者:
      getFullName 在接口中 IWorkbook
    • getPath

      public String getPath()
      Gets a string that represents the path to the workbook file that this workbook object represents.
      指定者:
      getPath 在接口中 IWorkbook
    • setPath

      public void setPath(String path)
      Sets a string that represents the path to the workbook file that this workbook object represents.
      指定者:
      setPath 在接口中 IWorkbook
    • open

      public void open(String fileName)
      Opens the specified excel file
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileName - The excel file.
    • open

      @Deprecated public void open(String fileName, String password)
      已过时。
      Opens the specified excel file
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileName - The excel file.
      password - The password of the file.
    • open

      public void open(String fileName, OpenFileFormat fileFormat)
      Opens the file with specified file format.
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileName - The specified file.
      fileFormat - The format of the file.
    • open

      public void open(String fileName, OpenOptionsBase options)
      Opens the file with specified options, the open options can be XlsxOpenOptions, CsvOpenOptions.
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileName - The excel file.
      options - The options of opening the file.
    • open

      public final void open(InputStream fileStream)
      Opens the specified excel file stream.
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileStream - The file stream.
    • open

      @Deprecated public void open(InputStream fileStream, String password)
      已过时。
      Opens the specified excel file stream.
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileStream - The file stream.
      password - The password of the file.
    • open

      public void open(InputStream fileStream, OpenFileFormat fileFormat)
      Opens the stream with specified file format.
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileStream - The specified file stream.
      fileFormat - The format of the file stream.
    • open

      public void open(InputStream fileStream, OpenOptionsBase options)
      Opens the stream with specified options, the open options can be XlsxOpenOptions, CsvOpenOptions.
      指定者:
      open 在接口中 IWorkbook
      参数:
      fileStream - The file stream.
      options - The format of opening the file stream.
    • save

      public void save(String fileName)
      Saves the workbook to the disk.
      指定者:
      save 在接口中 IWorkbook
      参数:
      fileName - The file name.
    • save

      @Deprecated public void save(String fileName, String password)
      已过时。
      Saves data to the specified excel file.
      指定者:
      save 在接口中 IWorkbook
      参数:
      fileName - The excel file.
      password - The password of the file.
    • save

      public void save(String fileName, SaveOptionsBase options)
      Saves workbook to file with specified options, the option can be XlsxSaveOptions, CsvSaveOptions
      指定者:
      save 在接口中 IWorkbook
      参数:
      fileName - The specified file.
      options - The options of saving the file.
    • save

      public void save(String fileName, SaveFileFormat fileFormat)
      Saves workbook to file with specified file format.
      指定者:
      save 在接口中 IWorkbook
      参数:
      fileName - The specified file.
      fileFormat - The format of the file.
    • save

      public void save(OutputStream outputStream)
      Saves the workbook to the stream.
      指定者:
      save 在接口中 IWorkbook
      参数:
      outputStream - The file stream.
    • save

      @Deprecated public void save(OutputStream outputStream, String password)
      已过时。
      Saves data to the specified excel file stream.
      指定者:
      save 在接口中 IWorkbook
      参数:
      outputStream - The file stream.
      password - The password of the file.
    • save

      public void save(OutputStream fileStream, SaveOptionsBase options)
      Saves workbook to stream with specified options, the option can be XlsxSaveOptions, CsvSaveOptions
      指定者:
      save 在接口中 IWorkbook
      参数:
      fileStream - The specified file stream.
      options - The options of saving the file stream.
    • save

      public void save(OutputStream fileStream, SaveFileFormat fileFormat)
      Saves workbook to stream with specified file format.
      指定者:
      save 在接口中 IWorkbook
      参数:
      fileStream - The specified file stream.
      fileFormat - The format of the file stream.
    • getOptions

      public IExcelOptions getOptions()
      Returns the IExcelOptions object that represents some settings to control workbook behavior.
      指定者:
      getOptions 在接口中 IWorkbook
    • getBuiltInDocumentProperties

      public IBuiltInDocumentPropertyCollection getBuiltInDocumentProperties()
      Gets a collection that represents all the built-in document properties of the workbook.
      指定者:
      getBuiltInDocumentProperties 在接口中 IWorkbook
    • getCustomDocumentProperties

      public ICustomDocumentPropertyCollection getCustomDocumentProperties()
      Gets a collection that represents all the custom document properties of the workbook.
      指定者:
      getCustomDocumentProperties 在接口中 IWorkbook
    • getCustomViews

      public ICustomViews getCustomViews()
      Gets a collection that represents all the custom document properties of the workbook.
      指定者:
      getCustomViews 在接口中 IWorkbook
    • getWriteProtection

      public WriteProtection getWriteProtection()
      Provides access to the workbook write protection options.
      指定者:
      getWriteProtection 在接口中 IWorkbook
    • getSignatures

      public ISignatureSet getSignatures()
      Gets a collection of Signature objects that correspond to the digital signature attached to a document.
      指定者:
      getSignatures 在接口中 IWorkbook
    • getTagJsonSerializer

      public static IJsonSerializer getTagJsonSerializer()
      Gets JSON serializer for custom type
      返回:
    • setTagJsonSerializer

      public static void setTagJsonSerializer(IJsonSerializer value)
      Sets JSON serializer for custom type in from/to JSON.
      参数:
      value -
    • getValueJsonSerializer

      public static IJsonSerializer getValueJsonSerializer()
      Gets JSON serializer for custom type
      返回:
    • setValueJsonSerializer

      public static void setValueJsonSerializer(IJsonSerializer value)
      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

      public IWorkbookView 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

      public ReferenceStyle getReferenceStyle()
      Gets the reference style.
      指定者:
      getReferenceStyle 在接口中 IWorkbook
    • setReferenceStyle

      public void setReferenceStyle(ReferenceStyle value)
      Sets the reference style.
      指定者:
      setReferenceStyle 在接口中 IWorkbook
    • getWorksheets

      public IWorksheets getWorksheets()
      Gets a collection of worksheets contained in the workbook.
      指定者:
      getWorksheets 在接口中 IWorkbook
    • getActiveSheet

      public IWorksheet getActiveSheet()
      Gets the active sheet.
      指定者:
      getActiveSheet 在接口中 IWorkbook
    • getTheme

      public ITheme getTheme()
      Returns an instance of ITheme which provides access to the theme associated with a workbook.
      指定者:
      getTheme 在接口中 IWorkbook
    • setTheme

      public void setTheme(ITheme value)
      Sets the theme applied to the current workbook.
      指定者:
      setTheme 在接口中 IWorkbook
    • getIconSets

      public IIconSets getIconSets()
      Filters data in a workbook based on a cell icon from the IconSets collection.
      指定者:
      getIconSets 在接口中 IWorkbook
    • getDefaultTableStyle

      public String getDefaultTableStyle()
      Specifies the table style that is used as the default TableStyle.
      指定者:
      getDefaultTableStyle 在接口中 IWorkbook
    • setDefaultTableStyle

      public void setDefaultTableStyle(String value)
      Sets the table style name from the ITableStyleCollection collectionthat is used as the default TableStyle.
      指定者:
      setDefaultTableStyle 在接口中 IWorkbook
    • getCulture

      public Locale getCulture()
      Gets the culture info of workbook, default is Locale.getDefault().
      指定者:
      getCulture 在接口中 IWorkbook
    • setCulture

      public void setCulture(Locale value)
      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

      public static void AddCustomFunction(CustomFunction func)
      Add custom function into the function set.
      参数:
      func - the custom function instance.
    • AddCustomFunction

      public static void AddCustomFunction(CustomFunction func, boolean canOverride)
      Add custom function into the function set.
      参数:
      func - the custom function instance.
      canOverride - override the exist function.
    • getPivotCaches

      public IPivotCaches getPivotCaches()
      Gets a PivotCaches collection that represents all the PivotTable caches in the specified workbook.
      指定者:
      getPivotCaches 在接口中 IWorkbook
    • getSlicerCaches

      public ISlicerCaches getSlicerCaches()
      Gets the ISlicerCaches object associated with the workbook.
      指定者:
      getSlicerCaches 在接口中 IWorkbook
    • calculate

      public void calculate()
      Calculates formulas in the workbook as needed.
      指定者:
      calculate 在接口中 IWorkbook
    • dirty

      public void dirty()
      Designates all the formulas of the workbook to be recalculated when the next calculation occurs.
      指定者:
      dirty 在接口中 IWorkbook
    • getStyles

      public IStyleCollection getStyles()
      Provides access to the collection of cell styles in the current workbook.
      指定者:
      getStyles 在接口中 IWorkbook
    • getTableStyles

      public ITableStyleCollection getTableStyles()
      Gets the table styles used in the current workbook.
      指定者:
      getTableStyles 在接口中 IWorkbook
    • getNames

      public INames getNames()
      Returns the INames collection that represents all the names in thespecified workbook (including all worksheet-specific names).
      指定者:
      getNames 在接口中 IWorkbook
    • getAuthor

      public String getAuthor()
      Gets the author.
      指定者:
      getAuthor 在接口中 IWorkbook
    • setAuthor

      public void setAuthor(String value)
      Sets the author.
      指定者:
      setAuthor 在接口中 IWorkbook
    • isEncryptedFile

      public boolean isEncryptedFile(String fileName)
      Specifies whether the file is password protected.
      指定者:
      isEncryptedFile 在接口中 IWorkbook
      参数:
      fileName - The file name.
    • isEncryptedFile

      public boolean isEncryptedFile(InputStream fileStream)
      Specifies whether the file is password protected.
      指定者:
      isEncryptedFile 在接口中 IWorkbook
      参数:
      fileStream - The file stream.
    • toJson

      public String toJson()
      Generates a JSON string from the workbook.
      指定者:
      toJson 在接口中 IWorkbook
      返回:
      the json string.
    • toJson

      public String toJson(SerializationOptions serializationOptions)
      Generates a JSON string from the workbook.
      指定者:
      toJson 在接口中 IWorkbook
      参数:
      serializationOptions - the SerializationOptions object.
      返回:
      The JSON string
    • toJson

      public void toJson(OutputStream stream)
      Generates a zipped JSON string from the workbook.
      指定者:
      toJson 在接口中 IWorkbook
      参数:
      stream - the output stream.
    • toJson

      public void toJson(OutputStream stream, SerializationOptions serializationOptions)
      Generates a JSON stream from a workbook.
      指定者:
      toJson 在接口中 IWorkbook
      参数:
      stream - the output stream.
      serializationOptions - the SerializationOptions object.
    • protect

      public void protect()
      Protects a workbook so that it cannot be modified.
      指定者:
      protect 在接口中 IWorkbook
    • protect

      public void protect(boolean structure)
      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).
    • 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

      public void protect(String password)
      Protects a workbook so that it cannot be modified.
      指定者:
      protect 在接口中 IWorkbook
      参数:
      password - Password to protect the workbook.
    • protect

      public void protect(String password, boolean structure)
      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).
    • protect

      public void protect(String password, boolean structure, boolean windows)
      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 在接口中 IWorkbook
    • unprotect

      public void unprotect(String password)
      Removes protection from the workbook.
      指定者:
      unprotect 在接口中 IWorkbook
      参数:
      password - Password to protect the workbook.
    • addDataSource

      public void addDataSource(String name, Object dataSource)
      Add data source for template
      指定者:
      addDataSource 在接口中 IWorkbook
      参数:
      name - : the alias name of the data source
      dataSource - : Can be object of ResultSet, Custom object and variable
    • processTemplate

      public void processTemplate()
      Start to process the template
      指定者:
      processTemplate 在接口中 IWorkbook
    • generateReport

      public IWorkbook generateReport()
      Process the template and return the instance of report workbook.
      指定者:
      generateReport 在接口中 IWorkbook
      返回:
      The new IWorkbook object.
    • generateReport

      public IWorkbook generateReport(IWorksheet... worksheets)
      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

      public static void SetLicenseKey(String key)
      Sets license for all workbook instances.

      Important: For licenses of the Chinese market, use SetLicenseFile orset license in the GCEXCEL_JAVA_DEPLOY_LICENSE_V5 environment variable instead.

      参数:
      key - license key
    • SetLicenseFile

      public static void SetLicenseFile(String licenseFilePath)
      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

      public final IGraphicsInfo getGraphicsInfo()
      Provides graphics information. If this property doesn't have value, the workbook will use built-in graphic information.
      指定者:
      getGraphicsInfo 在接口中 IWorkbook
    • setGraphicsInfo

      public final void setGraphicsInfo(IGraphicsInfo value)
      Provides graphics information. If this property doesn't have value, the workbook will use built-in graphic information.
      指定者:
      setGraphicsInfo 在接口中 IWorkbook
    • getSelectedSheets

      public final IWorksheets 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

      public void updateExcelLink(String name)
      Updates a excel link.
      指定者:
      updateExcelLink 在接口中 IWorkbook
    • updateExcelLink

      public void updateExcelLink(String name, IWorkbook sourceWorkbook)
      Updates a excel link.
      指定者:
      updateExcelLink 在接口中 IWorkbook
    • getNames

      public static String[] getNames(String fileName)
      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

      public 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!Table1".
      参数:
      fileStream - The fileStream of a workbook.
      返回:
      An array of possible import names.
    • importData

      public static Object[][] importData(String fileName, String sourceName)
      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

      public static Object[][] importData(InputStream fileStream, String sourceName)
      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.