[]
        
立即试用
(Showing Draft Content)

Workbook

Class Workbook

java.lang.Object
com.grapecity.documents.excel.Workbook
All Implemented Interfaces:
IWorkbook

public final class Workbook extends Object implements IWorkbook
代表一个工作簿。
  • Field Details

    • FontsFolderPath

      public static String FontsFolderPath
      获取或设置导出PDF时将使用的字体文件的位置。
    • FontProvider

      public static IFontProvider FontProvider
      获取或设置在启用自动适应、PDF导出和图像导出时将使用的字体提供程序。
  • Constructor Details

    • Workbook

      public Workbook()
      创建工作簿。
    • Workbook

      public Workbook(WorkbookOptions options)
      创建工作簿。
      Parameters:
      options - 工作簿选项。
    • Workbook

      public Workbook(String licenseKey)
      创建一个工作簿并应用指定的许可证。

      重要:对于中国市场的许可证,请使用SetLicenseFile或在GCEXCEL_JAVA_DEPLOY_LICENSE_V7环境变量中设置许可证。

      Parameters:
      licenseKey - 许可证密钥
    • Workbook

      public Workbook(String licenseKey, WorkbookOptions options)
      创建一个工作簿并应用指定的许可证。

      重要:对于中国市场的许可证,请使用SetLicenseFile或在GCEXCEL_JAVA_DEPLOY_LICENSE_V7环境变量中设置许可证。

      Parameters:
      licenseKey - 许可证密钥
      options - 工作簿选项。
  • Method Details

    • getAllowDynamicArray

      @Deprecated public boolean getAllowDynamicArray()
      Deprecated.
      获取是否允许动态数组公式。此方法已过时,请使用 getFormula2() 来获取动态数组公式。
      Specified by:
      getAllowDynamicArray in interface IWorkbook
    • setAllowDynamicArray

      @Deprecated public void setAllowDynamicArray(boolean value)
      Deprecated.
      设置是否允许动态数组公式。此方法已过时,请使用 setFormula2() 来设置动态数组公式。
      Specified by:
      setAllowDynamicArray in interface IWorkbook
    • getDeferUpdateDirtyState

      public boolean getDeferUpdateDirtyState()
      获取当更改单元格值时是否立即更新公式单元格的脏状态。
      Specified by:
      getDeferUpdateDirtyState in interface IWorkbook
    • setDeferUpdateDirtyState

      public void setDeferUpdateDirtyState(boolean value)
      设置当更改单元格值时是否立即更新公式单元格的脏状态。
      Specified by:
      setDeferUpdateDirtyState in interface IWorkbook
    • getName

      public String getName()
      获取一个代表工作簿名称的字符串值。
      Specified by:
      getName in interface IWorkbook
    • setName

      public void setName(String name)
      设置一个代表工作簿名称的字符串值。
      Specified by:
      setName in interface IWorkbook
    • getFullName

      public String getFullName()
      返回工作簿的名称,包括其在磁盘上的路径。
      Specified by:
      getFullName in interface IWorkbook
    • getPath

      public String getPath()
      获取一个字符串,该字符串表示此工作簿对象所代表的工作簿文件的路径。
      Specified by:
      getPath in interface IWorkbook
    • setPath

      public void setPath(String path)
      设置一个字符串,该字符串表示此工作簿对象所代表的工作簿文件的路径。
      Specified by:
      setPath in interface IWorkbook
    • open

      public void open(String fileName)
      打开文件,使用默认选项。文件类型从文件扩展名推断。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileName - 指定的文件。
    • open

      public List<JsonError> open(String fileName, DeserializationOptions deserializationOptions)
      打开JSON文件。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileName - 指定的JSON文件。
      deserializationOptions - JSON反序列化选项。
      Returns:
      Json错误
    • open

      @Deprecated public void open(String fileName, String password)
      Deprecated.
      打开指定的Excel文件
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileName - Excel文件。
      password - 文件的密码。
    • open

      public void open(String fileName, OpenFileFormat fileFormat)
      打开具有指定文件格式的文件。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileName - 指定的文件。
      fileFormat - 文件的格式。
    • open

      public void open(String fileName, OpenOptionsBase options)
      打开具有指定选项的文件。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileName - Excel文件。
      options - 打开文件的选项。可能的类型:
    • open

      public final void open(InputStream fileStream)
      打开指定的Excel文件流。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileStream - 文件流。
    • open

      @Deprecated public void open(InputStream fileStream, String password)
      Deprecated.
      打开指定的Excel文件流。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileStream - 文件流。
      password - 文件的密码。
    • open

      public void open(InputStream fileStream, OpenFileFormat fileFormat)
      打开具有指定文件格式的流。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileStream - 指定的文件流。
      fileFormat - 文件流的格式。
    • open

      public void open(InputStream fileStream, OpenOptionsBase options)
      打开具有指定选项的流。
      Specified by:
      open in interface IWorkbook
      Parameters:
      fileStream - 文件流。
      options - 打开文件流的格式。可能的类型:
    • save

      public void save(String fileName)
      保存工作簿到磁盘。
      Specified by:
      save in interface IWorkbook
      Parameters:
      fileName - 文件名。
    • save

      @Deprecated public void save(String fileName, String password)
      Deprecated.
      保存数据到指定的Excel文件。
      Specified by:
      save in interface IWorkbook
      Parameters:
      fileName - Excel文件。
      password - 文件的密码。
    • save

      public void save(String fileName, SaveOptionsBase options)
      将工作簿保存到具有指定选项的文件。
      Specified by:
      save in interface IWorkbook
      Parameters:
      fileName - 指定的文件。
      options - 保存文件的选项。可能的类型:
    • save

      public void save(String fileName, SaveFileFormat fileFormat)
      保存工作簿到指定文件格式的文件。
      Specified by:
      save in interface IWorkbook
      Parameters:
      fileName - 指定的文件。
      fileFormat - 文件的格式。
    • save

      public void save(OutputStream outputStream)
      保存工作簿到流中。
      Specified by:
      save in interface IWorkbook
      Parameters:
      outputStream - 文件流。
    • save

      @Deprecated public void save(OutputStream outputStream, String password)
      Deprecated.
      将数据保存到指定的Excel文件流。
      Specified by:
      save in interface IWorkbook
      Parameters:
      outputStream - 文件流。
      password - 文件的密码。
    • save

      public void save(OutputStream fileStream, SaveOptionsBase options)
      将工作簿保存到具有指定选项的流中。
      Specified by:
      save in interface IWorkbook
      Parameters:
      fileStream - 指定的文件流。
      options - 保存文件流的选项。可能的类型:
    • save

      public void save(OutputStream fileStream, SaveFileFormat fileFormat)
      保存工作簿到指定文件格式的流中。
      Specified by:
      save in interface IWorkbook
      Parameters:
      fileStream - 指定的文件流。
      fileFormat - 文件流的格式。
    • getAfterSaveEvent

      public Event<EventHandler<EventArgs>> getAfterSaveEvent()
      发生在工作簿保存之后。
      Specified by:
      getAfterSaveEvent in interface IWorkbook
    • getBeforeSaveEvent

      public Event<EventHandler<EventArgs>> getBeforeSaveEvent()
      发生在工作簿保存之前。
      Specified by:
      getBeforeSaveEvent in interface IWorkbook
    • getNewSheetEvent

      public Event<EventHandler<SheetEventArgs>> getNewSheetEvent()
      当工作簿中创建新工作表时发生。
      Specified by:
      getNewSheetEvent in interface IWorkbook
    • getOpenedEvent

      public Event<EventHandler<EventArgs>> getOpenedEvent()
      当工作簿被打开时发生。
      Specified by:
      getOpenedEvent in interface IWorkbook
    • getSheetActivateEvent

      public Event<EventHandler<SheetEventArgs>> getSheetActivateEvent()
      当一张工作表被激活时发生。
      Specified by:
      getSheetActivateEvent in interface IWorkbook
    • getSheetBeforeDeleteEvent

      public Event<EventHandler<SheetEventArgs>> getSheetBeforeDeleteEvent()
      发生在删除工作表之前。
      Specified by:
      getSheetBeforeDeleteEvent in interface IWorkbook
    • getSheetChangeEvent

      public Event<EventHandler<RangeEventArgs>> getSheetChangeEvent()
      发生在一个工作表的单元格发生变化时。
      Specified by:
      getSheetChangeEvent in interface IWorkbook
    • getSheetDeactivateEvent

      public Event<EventHandler<SheetEventArgs>> getSheetDeactivateEvent()
      当工作表被停用时发生。
      Specified by:
      getSheetDeactivateEvent in interface IWorkbook
    • getSheetSelectionChange

      public Event<EventHandler<RangeEventArgs>> getSheetSelectionChange()
      当工作表上的选择更改时发生。
      Specified by:
      getSheetSelectionChange in interface IWorkbook
    • getOptions

      public IExcelOptions getOptions()
      返回代表控制工作簿行为的某些设置的 IExcelOptions 对象。
      Specified by:
      getOptions in interface IWorkbook
    • getBuiltInDocumentProperties

      public IBuiltInDocumentPropertyCollection getBuiltInDocumentProperties()
      获取一个代表工作簿所有内置文档属性的集合。
      Specified by:
      getBuiltInDocumentProperties in interface IWorkbook
    • getCustomDocumentProperties

      public ICustomDocumentPropertyCollection getCustomDocumentProperties()
      获取一个代表工作簿所有自定义文档属性的集合。
      Specified by:
      getCustomDocumentProperties in interface IWorkbook
    • getCustomViews

      public ICustomViews getCustomViews()
      获取一个表示工作簿所有自定义文档属性的集合。
      Specified by:
      getCustomViews in interface IWorkbook
    • getWriteProtection

      public WriteProtection getWriteProtection()
      提供访问工作簿写保护选项的权限。
      Specified by:
      getWriteProtection in interface IWorkbook
    • getSignatures

      public ISignatureSet getSignatures()
      获取与文档附带的数字签名对应的签名对象集合。
      Specified by:
      getSignatures in interface IWorkbook
    • getTagJsonSerializer

      public static IJsonSerializer getTagJsonSerializer()
      获取自定义类型的JSON序列化器
      Returns:
      标签自定义类型的JSON序列化器。
    • setTagJsonSerializer

      public static void setTagJsonSerializer(IJsonSerializer value)
      设置自定义类型在JSON之间转换的JSON序列化器。
      Parameters:
      value - 标签自定义类型的JSON序列化器。
    • getValueJsonSerializer

      public static IJsonSerializer getValueJsonSerializer()
      获取自定义类型的JSON序列化器
      Returns:
      自定义类型的JSON序列化器。
    • setValueJsonSerializer

      public static void setValueJsonSerializer(IJsonSerializer value)
      设置自定义类型在JSON序列化/反序列化中的JSON序列化器。
      Parameters:
      value - 自定义类型的JSON序列化器。
    • getAutoParse

      public boolean getAutoParse()
      确定在将范围值设置为字符串值时是否自动解析。
      Specified by:
      getAutoParse in interface IWorkbook
    • setAutoParse

      public void setAutoParse(boolean value)
      设置当将范围值设置为字符串值时是否自动解析。
      Specified by:
      setAutoParse in interface IWorkbook
    • getAutoRoundValue

      public boolean getAutoRoundValue()
      确定在获取值时是否将数字四舍五入到15位有效数字。
      Specified by:
      getAutoRoundValue in interface IWorkbook
    • setAutoRoundValue

      public void setAutoRoundValue(boolean value)
      设置当获取值时是否将数字四舍五入到15位有效数字。
      Specified by:
      setAutoRoundValue in interface IWorkbook
    • getBookView

      public IWorkbookView getBookView()
      返回一个代表此工作簿视图设置的对象。
      Specified by:
      getBookView in interface IWorkbook
    • getProtectStructure

      public boolean getProtectStructure()
      如果工作簿中的工作表顺序受到保护,则为true。只读布尔值。
      Specified by:
      getProtectStructure in interface IWorkbook
    • getProtectWindows

      public boolean getProtectWindows()
      如果工作簿的窗口受到保护,则为true。只读布尔值。
      Specified by:
      getProtectWindows in interface IWorkbook
    • getReferenceStyle

      public ReferenceStyle getReferenceStyle()
      获取引用样式。
      Specified by:
      getReferenceStyle in interface IWorkbook
    • setReferenceStyle

      public void setReferenceStyle(ReferenceStyle value)
      设置参考样式。
      Specified by:
      setReferenceStyle in interface IWorkbook
    • getWorksheets

      public IWorksheets getWorksheets()
      获取工作簿中包含的工作表集合。
      Specified by:
      getWorksheets in interface IWorkbook
    • getActiveSheet

      public IWorksheet getActiveSheet()
      获取活动工作表。
      Specified by:
      getActiveSheet in interface IWorkbook
    • getTheme

      public ITheme getTheme()
      返回一个ITheme实例,该实例提供对与工作簿关联的主题的访问。
      Specified by:
      getTheme in interface IWorkbook
    • setTheme

      public void setTheme(ITheme value)
      设置应用于当前工作簿的主题。
      Specified by:
      setTheme in interface IWorkbook
    • getIconSets

      public IIconSets getIconSets()
      基于图标集中的一个单元格图标,过滤工作簿中的数据。
      Specified by:
      getIconSets in interface IWorkbook
    • getDefaultTableStyle

      public String getDefaultTableStyle()
      指定作为默认 TableStyle 使用的表样式。
      Specified by:
      getDefaultTableStyle in interface IWorkbook
    • setDefaultTableStyle

      public void setDefaultTableStyle(String value)
      设置表样式名称,该名称从作为默认表样式使用的ITableStyleCollection集合中获取。
      Specified by:
      setDefaultTableStyle in interface IWorkbook
    • getCulture

      public Locale getCulture()
      获取工作簿的区域信息,默认为 Locale.getDefault().
      Specified by:
      getCulture in interface IWorkbook
    • setCulture

      public void setCulture(Locale value)
      为工作簿设置区域信息。这将影响到与文化相关的功能。区域信息必须同时包含国家/地区和语言。例如:

      区域信息必须同时包含国家和语言。例如:

      Specified by:
      setCulture in interface IWorkbook
      API Note:
      区域信息必须在工作簿实例的初始化代码中设置。
    • getEnableCalculation

      public boolean getEnableCalculation()
      指定计算引擎是否正在工作。
      Specified by:
      getEnableCalculation in interface IWorkbook
    • setEnableCalculation

      public void setEnableCalculation(boolean value)
      设置计算引擎是否有效。
      Specified by:
      setEnableCalculation in interface IWorkbook
    • AddCustomFunction

      public static void AddCustomFunction(CustomFunction func)
      添加自定义函数到函数集中。
      Parameters:
      func - 自定义函数实例。
    • AddCustomFunction

      public static void AddCustomFunction(CustomFunction func, boolean canOverride)
      添加自定义函数到函数集合中。
      Parameters:
      func - 自定义函数实例。
      canOverride - 是否覆盖现有函数。
    • getPivotCaches

      public IPivotCaches getPivotCaches()
      获取一个表示指定工作簿中所有数据透视表缓存的 PivotCaches 集合。
      Specified by:
      getPivotCaches in interface IWorkbook
    • getSlicerCaches

      public ISlicerCaches getSlicerCaches()
      获取与工作簿关联的 ISlicerCaches 对象。
      Specified by:
      getSlicerCaches in interface IWorkbook
    • getUsedFonts

      public List<FontInfo> getUsedFonts()
      获取工作簿上所使用的所有字体信息。
      Specified by:
      getUsedFonts in interface IWorkbook
    • calculate

      public void calculate()
      计算工作簿中所需公式。
      Specified by:
      calculate in interface IWorkbook
    • dirty

      public void dirty()
      指定当下次进行计算时,工作簿中的所有公式都要重新计算。
      Specified by:
      dirty in interface IWorkbook
    • getStyles

      public IStyleCollection getStyles()
      提供对当前工作簿中单元格样式的集合的访问。
      Specified by:
      getStyles in interface IWorkbook
    • getTableStyles

      public ITableStyleCollection getTableStyles()
      获取当前工作簿中使用的表格样式。
      Specified by:
      getTableStyles in interface IWorkbook
    • getNames

      public INames getNames()
      返回代表工作簿指定名称的INames集合。
      Specified by:
      getNames in interface IWorkbook
    • getAuthor

      public String getAuthor()
      获取作者。
      Specified by:
      getAuthor in interface IWorkbook
    • setAuthor

      public void setAuthor(String value)
      设置作者。
      Specified by:
      setAuthor in interface IWorkbook
    • isEncryptedFile

      public boolean isEncryptedFile(String fileName)
      指定文件是否受密码保护。
      Specified by:
      isEncryptedFile in interface IWorkbook
      Parameters:
      fileName - 文件名。
    • isEncryptedFile

      public boolean isEncryptedFile(InputStream fileStream)
      指定文件是否受密码保护。
      Specified by:
      isEncryptedFile in interface IWorkbook
      Parameters:
      fileStream - 文件流。
    • toJson

      public String toJson()
      从工作簿生成一个JSON字符串。
      Specified by:
      toJson in interface IWorkbook
      Returns:
      JSON字符串。
    • toJson

      public String toJson(SerializationOptions serializationOptions)
      生成一个由工作簿产生的JSON字符串。
      Specified by:
      toJson in interface IWorkbook
      Parameters:
      serializationOptions - SerializationOptions对象。
      Returns:
      JSON字符串。
    • toJson

      public void toJson(OutputStream stream)
      从工作簿生成压缩的JSON字符串。
      Specified by:
      toJson in interface IWorkbook
      Parameters:
      stream - 输出流。
    • toJson

      public void toJson(OutputStream stream, SerializationOptions serializationOptions)
      从工作簿生成一个JSON流。
      Specified by:
      toJson in interface IWorkbook
      Parameters:
      stream - 输出流。
      serializationOptions - SerializationOptions对象。
    • fromJson

      public List<JsonError> fromJson(String json)
      从JSON字符串生成一个工作簿。
      Specified by:
      fromJson in interface IWorkbook
      Parameters:
      json - 输入的JSON字符串。
      Returns:
      JSON中的错误。
    • fromJson

      public List<JsonError> fromJson(String json, DeserializationOptions deserializationOptions)
      从JSON字符串生成工作簿。
      Specified by:
      fromJson in interface IWorkbook
      Parameters:
      json - JSON字符串。
      deserializationOptions - DeserializationOptions 对象。
      Returns:
      JSON中的错误。
    • fromJson

      public List<JsonError> fromJson(InputStream stream)
      从JSON流生成一个工作簿。
      Specified by:
      fromJson in interface IWorkbook
      Parameters:
      stream - 输入流。
      Returns:
      JSON中的错误。
    • fromJson

      public List<JsonError> fromJson(InputStream stream, DeserializationOptions deserializationOptions)
      从JSON流生成工作簿。
      Specified by:
      fromJson in interface IWorkbook
      Parameters:
      stream - 流的参数
      deserializationOptions - DeserializationOptions对象。
      Returns:
      JSON中的错误。
    • fromSjsJson

      public void fromSjsJson(String json)
      从包含.sjs文件格式的内容的JSON字符串生成一个工作簿。
      Specified by:
      fromSjsJson in interface IWorkbook
      Parameters:
      json - JSON字符串。
    • fromSjsJson

      public void fromSjsJson(String json, SjsOpenOptions openOptions)
      从包含.sjs文件格式的内容的JSON字符串生成一个工作簿。
      Specified by:
      fromSjsJson in interface IWorkbook
      Parameters:
      json - JSON字符串。
      openOptions - 打开SpreadJS .sjs文件时的打开选项。
    • fromSjsJson

      public void fromSjsJson(InputStream stream)
      从包含.sjs文件格式的内容的JSON流生成一个工作簿。
      Specified by:
      fromSjsJson in interface IWorkbook
      Parameters:
      stream - JSON流。
    • waitForCalculationToFinish

      public void waitForCalculationToFinish()
      等待所有计算完成,包括异步计算。此方法将阻塞当前线程,直到所有计算完成。用户可以调用此方法以确保在执行任何依赖于计算结果的其它操作之前,所有必要的计算都已执行完毕。
      Specified by:
      waitForCalculationToFinish in interface IWorkbook
    • getWebRequestHandler

      public static IWebRequestHandler getWebRequestHandler()
      获取将用于处理网络请求的IWebRequestHandler实现的单例实例。此属性为访问应用程序的网络请求处理器提供了一种集中方式。
      Returns:
      IWebRequestHandler的单例实例
    • setWebRequestHandler

      public static void setWebRequestHandler(IWebRequestHandler webRequestHandler)
      设置将用于处理网络请求的IWebRequestHandler实现的单例实例。此属性提供了一种集中设置应用程序的网络请求处理程序的方法。
      Parameters:
      webRequestHandler - IWebRequestHandler的新单例实例
    • fromSjsJson

      public void fromSjsJson(InputStream stream, SjsOpenOptions openOptions)
      从包含.sjs文件格式的内容的JSON流生成一个工作簿。
      Specified by:
      fromSjsJson in interface IWorkbook
      Parameters:
      stream - JSON流。
      openOptions - 打开SpreadJS .sjs文件的打开选项。
    • protect

      public void protect()
      保护工作簿,使其不能被修改。
      Specified by:
      protect in interface IWorkbook
    • protect

      public void protect(boolean structure)
      保护工作簿,使其不能被修改。
      Specified by:
      protect in interface IWorkbook
      Parameters:
      structure - 如果设置为true,则保护工作簿的结构(防止其他用户查看隐藏的工作表、添加、移动、删除或隐藏工作表,以及重命名工作表)。
    • protect

      public void protect(boolean structure, boolean windows)
      保护工作簿,使其不能被修改。
      Specified by:
      protect in interface IWorkbook
      Parameters:
      structure - 如果为true,则保护工作簿的结构(防止其他用户查看隐藏的工作表、添加、移动、删除或隐藏工作表以及重命名工作表)。
      windows - 如果为true,则防止用户移动、调整大小或关闭工作簿窗口,或隐藏/显示窗口。此选项仅在Excel 2007、Excel 2010、Excel for Mac 2011和Excel 2016 for Mac中可用。
    • protect

      public void protect(String password)
      保护工作簿,使其不能被修改。
      Specified by:
      protect in interface IWorkbook
      Parameters:
      password - 用于保护工作簿的密码。
    • protect

      public void protect(String password, boolean structure)
      保护工作簿,使其不能被修改。
      Specified by:
      protect in interface IWorkbook
      Parameters:
      password - 保护工作簿的密码。
      structure - 如果设置为true,则保护工作簿的结构(防止其他用户查看隐藏的工作表、添加、移动、删除或隐藏工作表,以及重命名工作表)。
    • protect

      public void protect(String password, boolean structure, boolean windows)
      保护工作簿,使其无法被修改。
      Specified by:
      protect in interface IWorkbook
      Parameters:
      password - 用于保护工作簿的密码。
      structure - 如果设置为true,则保护工作簿的结构(防止其他用户查看隐藏的工作表、添加、移动、删除或隐藏工作表,以及重命名工作表)。
      windows - 如果设置为true,则防止用户移动、调整大小或关闭工作簿窗口,或隐藏/显示窗口。此选项仅在Excel 2007、Excel 2010、Excel for Mac 2011和Excel 2016 for Mac中可用。
    • unprotect

      public void unprotect()
      移除工作簿的保护。
      Specified by:
      unprotect in interface IWorkbook
    • unprotect

      public void unprotect(String password)
      移除工作簿的保护。
      Specified by:
      unprotect in interface IWorkbook
      Parameters:
      password - 用于保护工作簿的密码。
    • addDataSource

      public void addDataSource(String name, Object dataSource)
      添加模板的数据源
      Specified by:
      addDataSource in interface IWorkbook
      Parameters:
      name - :数据源的别名
      dataSource - :可以是ResultSet对象、自定义对象和变量。
    • processTemplate

      public void processTemplate()
      开始处理模板。
      Specified by:
      processTemplate in interface IWorkbook
    • processTemplate

      public void processTemplate(CancellationToken cancellationToken)
      开始使用全局选项和取消支持处理模板。
      Specified by:
      processTemplate in interface IWorkbook
      Parameters:
      cancellationToken - 用于监控取消请求的令牌。
      Throws:
      CancellationException - 当CancellationToken被取消时抛出。
      API Note:
      调用者必须决定是接受部分展开的模板还是恢复到之前的状态。如果调用者需要恢复到之前的状态,它必须在调用此方法之前序列化工作簿,然后在取消操作后反序列化工作簿。
    • generateReport

      public IWorkbook generateReport()
      处理模板并返回报告工作簿的实例。
      Specified by:
      generateReport in interface IWorkbook
      Returns:
      新的 IWorkbook 对象。
    • generateReport

      public IWorkbook generateReport(IWorksheet... worksheets)
      处理模板并返回报告工作簿的实例。@param worksheets 需要处理的工作表集合。
      Specified by:
      generateReport in interface IWorkbook
      Parameters:
      worksheets - 需要处理的工作表集合。
      Returns:
      新的 IWorkbook 对象。
    • getResetAdjacentRangeBorder

      public boolean getResetAdjacentRangeBorder()
      确定在为范围设置边框时是否重置相邻范围边框。此属性的默认值为 true。
      Specified by:
      getResetAdjacentRangeBorder in interface IWorkbook
    • setResetAdjacentRangeBorder

      public void setResetAdjacentRangeBorder(boolean value)
      确定在为某个范围设置边框时是否重置相邻范围的边框。此属性的默认值为 true。
      Specified by:
      setResetAdjacentRangeBorder in interface IWorkbook
      Parameters:
      value - True 表示重置相邻范围的边界,False 表示否。
    • SetLicenseKey

      public static void SetLicenseKey(String key)
      设置所有工作簿实例的许可证。

      重要:对于中国市场许可证,请使用SetLicenseFile或在GCEXCEL_JAVA_DEPLOY_LICENSE_V7环境变量中设置许可证。

      Parameters:
      key - 许可证密钥。
    • SetLicenseFile

      public static void SetLicenseFile(String licenseFilePath)
      对于中国市场许可证,从文件申请部署许可证或无限开发许可证。

      如果您的许可证是从其他市场购买的,则不应调用此方法。

      Parameters:
      licenseFilePath - 包含许可证键的文件
    • getGraphicsInfo

      public final IGraphicsInfo getGraphicsInfo()
      提供图形信息。如果此属性没有值,工作簿将使用内置的图形信息。
      Specified by:
      getGraphicsInfo in interface IWorkbook
    • setGraphicsInfo

      public final void setGraphicsInfo(IGraphicsInfo value)
      提供图形信息。如果此属性没有值,工作簿将使用内置的图形信息。
      Specified by:
      setGraphicsInfo in interface IWorkbook
    • getSelectedSheets

      public final IWorksheets getSelectedSheets()
      返回一个 IWorksheets 集合,该集合代表指定工作簿中所有选中的工作表。
      Specified by:
      getSelectedSheets in interface IWorkbook
    • getExcelLinkSources

      public List<String> getExcelLinkSources()
      返回关联的Excel文档的名称。
      Specified by:
      getExcelLinkSources in interface IWorkbook
    • public void updateExcelLinks()
      更新所有Excel链接。
      Specified by:
      updateExcelLinks in interface IWorkbook
    • public void updateExcelLink(String name)
      更新Excel链接。
      Specified by:
      updateExcelLink in interface IWorkbook
    • public void updateExcelLink(String name, IWorkbook sourceWorkbook)
      更新一个Excel链接。
      Specified by:
      updateExcelLink in interface IWorkbook
    • getNames

      public static String[] getNames(String fileName)
      获取所有将作为ImportData参数源的表格名称和表名称。
      如果名称是表名,则在工作表名称前加上限定词,例如"Sheet1!Table1"。
      Parameters:
      fileName - 文件的路径和名称。
      Returns:
      可能的导入名称数组。
    • getNames

      public static String[] getNames(InputStream fileStream)
      获取所有将作为ImportData参数源的表单名称和表格名称。
      如果名称是表名,则在工作表名称前加上限定词,例如"Sheet1!Table1"。
      Parameters:
      fileStream - 工作簿的文件流。
      Returns:
      可能的导入名称数组。
    • importData

      public static Object[][] importData(String fileName, String sourceName)
      导入指定文件源的所有数据。
      Parameters:
      fileName - 文件的路径和名称。
      sourceName - 数据源的名称。源名称可能是:
      工作表 "Sheet1"
      表格 "Sheet1!Table1"
      范围 "Sheet1!A1:C5"
      Returns:
      数据的数组。
    • importData

      public static Object[][] importData(String fileName, String worksheetName, int row, int column, int rowCount, int columnCount)
      从文件导入指定范围的数据。
      Parameters:
      fileName - 文件的路径和名称。
      worksheetName - 工作表名称。
      row - 范围的起始行。
      column - 范围的起始列。
      rowCount - 行数。
      columnCount - 列数。
    • importData

      public static Object[][] importData(InputStream fileStream, String sourceName)
      导入指定文件源的所有数据。
      Parameters:
      fileStream - 工作簿的fileStream。
      sourceName - 源数据的名称。源名称可能是:
      worksheet "Sheet1"
      table "Sheet1!Table1"
      range "Sheet1!A1:C5"
      Returns:
      数据的数组。
    • importData

      public static Object[][] importData(InputStream fileStream, String worksheetName, int row, int column, int rowCount, int columnCount)
      从文件流中导入指定范围的数据。
      Parameters:
      fileStream - 工作簿的文件流。
      worksheetName - 工作表名称。
      row - 范围的起始行。
      column - 范围的起始列。
      rowCount - 行的数量。
      columnCount - 列的数量。
    • toSjsJson

      public void toSjsJson(OutputStream stream)
      将SpreadJS .sjs文件中的所有JSON文件集成到一个字符串中,然后将该字符串放入流中。
      Specified by:
      toSjsJson in interface IWorkbook
      Parameters:
      stream - 指定的文件流。
    • toSjsJson

      public void toSjsJson(OutputStream stream, SjsSaveOptions options)
      将SpreadJS .sjs文件中的所有JSON文件集成到一个字符串中,然后将该字符串放入流中。
      Specified by:
      toSjsJson in interface IWorkbook
      Parameters:
      stream - 指定的文件流。
      options - 打开SpreadJS .sjs文件的选项。
    • toSjsJson

      public String toSjsJson()
      生成一个 JSON 字符串从工作簿。它将 SpreadJS .sjs 文件中的所有 JSON 文件集成到一个字符串中。
      Specified by:
      toSjsJson in interface IWorkbook
      Returns:
      Json 数据
    • toSjsJson

      public String toSjsJson(SjsSaveOptions options)
      从工作簿生成一个JSON字符串。它将SpreadJS .sjs文件中的所有JSON文件整合到一个字符串中。
      Specified by:
      toSjsJson in interface IWorkbook
      Parameters:
      options - 打开SpreadJS .sjs文件的选项。
      Returns:
      Json数据。
    • convertBarcodeToPicture

      public void convertBarcodeToPicture()
      将计算出的条形码转换为图片,并将它们放置在各自的位置。
      原始条形码公式将被清除。
      转换后的图片的 ImageTypeImageType.SVG
      Specified by:
      convertBarcodeToPicture in interface IWorkbook
    • convertBarcodeToPicture

      public void convertBarcodeToPicture(ImageType imageType)
      将计算出的条形码转换为图片,并将它们放置在各自的位置。
      原始条形码公式将被清除。
      不支持 ImageType.EMFImageType.WMF 图像类型。
      Specified by:
      convertBarcodeToPicture in interface IWorkbook
      Parameters:
      imageType - 指定转换后图像的 ImageType
      Throws:
      UnsupportedOperationException - 如果转换到 ImageType.EMFImageType.WMF 图像类型时。
    • getShowPivotTableFieldList

      public boolean getShowPivotTableFieldList()
      获取一个值,表示是否可以显示数据透视表字段列表。默认值为true。
      Specified by:
      getShowPivotTableFieldList in interface IWorkbook
    • setShowPivotTableFieldList

      public void setShowPivotTableFieldList(boolean value)
      设置一个值以指示是否可以显示数据透视表字段列表。
      Specified by:
      setShowPivotTableFieldList in interface IWorkbook
    • clone

      public Workbook clone()
      克隆当前工作簿并返回一个新的工作簿实例。
      Overrides:
      clone in class Object
      Returns:
      一个与当前工作簿完全相同的新工作簿实例。