All Products
Search
Document Center

Intelligent Media Management:Workbook

Last Updated:Mar 31, 2025

This topic describes the API operations that are related to the Workbook object of table documents.

Workbook

Workbook

Obtains an active workbook in the active window.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the active workbook.
      const activeWorkbook = await app.ActiveWorkbook;
    }

Methods

ActiveWorkbook.CopySheetFromBook()

You can copy an active worksheet from an active workbook to the current workbook by using the CopySheetFromBook() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.CopySheetFromBook({ FromBookFileId, FromBookFileName, FromeSheetName, DestSheetName })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    FromBookFileId

    String

    Yes

    The ID of the target active workbook.

    FromBookFileName

    String

    No

    The name of the target active workbook.

    FromeSheetName

    String

    No

    The name of the active worksheet in the target active workbook.

    DestSheetName

    String

    No

    The name of the active worksheet to be copied to the current active workbook.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the active workbook.
      const activeWorkbook = await app.ActiveWorkbook;
    
      // Copy the active worksheet named "Sheet" in the active workbook with the ID "100161090439" and name "Workbook" to the active worksheet named "Sheet6" in the current active workbook.
      const result=await activeWorkbook.CopySheetFromBook('100161090439', 'Workbook', 'Sheet1', 'Sheet6');
      console.log(result);
    }

ActiveWorkbook.ExportAsFixedFormat()

By using the ExportAsFixedFormat() method, you can export the current active workbook as a PDF file or an IMG image and obtain the URL of the file.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.ExportAsFixedFormat({ Type })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Type

    Enum

    No

    The format of the exported file. Only image and PDF are supported. For more information, see XlFixedFormatType.

  • Return values

    Property

    Type

    Description

    url

    String

    The URL of the exported file.

  • Examples

    • Export as PDF

      async function example() {
        await instance.ready();
      
        const app = instance.Application;
        
        // Export as a PDF file and obtain the URL of the exported file.
        const workbookPdfUrl = await app.ActiveWorkbook.ExportAsFixedFormat();
        console.log(workbookPdfUrl);
      }
      
    • Export as image

      async function example() {
        await instance.ready();
      
        const app = instance.Application;
        
        // Export as an image and obtain the URL of the exported file.
        const workbookImgUrl = await app.ActiveWorkbook.ExportAsFixedFormat({
          Type: app.Enum.XlFixedFormatType.xlTypeIMG,
        });
        console.log(workbookImgUrl);
      }

ActiveWorkbook.GetOperatorsInfo()

You can obtain the information about the current operator by using the GetOperatorsInfo() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.GetOperatorsInfo()

    expression: the document type application object.

  • Return values

    • Object object

      Property

      Type

      Description

      type

      String

      The type of the request.

      response

      Object

      The information about the operator.

    • The structure of response

      Property

      Type

      Description

      id

      String

      The ID of the user.

      avatar_url

      String

      The profile picture of the user.

      logined

      String

      The logon status of the user.

      name

      String

      The name of the user.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the information about the current operator.
      const operatorsInfo = await app.ActiveWorkbook.GetOperatorsInfo();
      console.log(operatorsInfo);
    }

ActiveWorkbook.SetFilterShared()

You can enable or disable the multi-person synchronous filtering feature by using the SetFilterShared() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.SetFilterShared({ Checked })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Checked

    Boolean

    Yes

    Specifies whether to enable the multi-person synchronous filtering feature. Valid values:

    • true

    • false

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the active workbook.
      const activeWorkbook = await app.ActiveWorkbook;
    
      // Enable multi-person synchronous filtering.
      const result = await activeWorkbook.SetFilterShared(true);
    }

ActiveWorkbook.Save()

You can save changes to the active workbook by using the Save() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.Save()

    expression: the document type application object.

  • Return values

    Property

    Type

    Description

    result

    String

    The save status. Valid values:

    • ok: The version is saved. You can view the version in Version History.

    • nochange: No update to save.

    • SavedEmptyFile: You cannot save an empty file.

      Scenario: The file is empty after a kernel save.

    • SpaceFull: The space is full.

    • QueneFull: Do not perform frequent operations while saving.

      Scenario: The server processing and saving queue is full and the saving operation is enqueued.

    • fail: The file fails to be saved.

    size

    Number

    The size of the file. Unit: byte.

    version

    Number

    The version number.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Save the changes to the active workbook.
      const saveResult = await app.ActiveWorkbook.Save();
      console.log(saveResult);
    }

ActiveWorkbook.SwitchCardView()

You can open or close the card view panel by using the SwitchCardView() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.SwitchCardView()

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Status

    Boolean

    Yes

    Specifies whether to open or close the card view panel. Valid values:

    • true

    • false (not supported)

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Open the card view panel
      await app.ActiveWorkbook.SwitchCardView(true);
    }

ActiveWorkbook.QuitCellEdit()

You can exit the cell edit mode by using the QuitCellEdit() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.QuitCellEdit()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Exit the cell edit mode.
      await app.ActiveWorkbook.QuitCellEdit();
    }

ActiveWorkbook.CloseDropdownPanels()

You can close all drop-down panels by using the CloseDropdownPanels() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.CloseDropdownPanels()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Close all drop-down panels.
      await app.ActiveWorkbook.CloseDropdownPanels();
    }

ActiveWorkbook.CloseHyperLink()

You can disable a hyperlink by using the CloseHyperLink() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.CloseHyperLink()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Disable the hyperlink.
      await app.ActiveWorkbook.CloseHyperLink();
    }

ActiveWorkbook.CloseFilterTips()

You can close a filter hover tip by using the CloseFilterTips() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.CloseFilterTips()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Close a filter hover tip.
      await app.ActiveWorkbook.CloseFilterTips();
    }

ActiveWorkbook.SetCalcOptions()

You can configure iterative calculation by using the SetCalcOptions() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.SetCalcOptions()

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    EnableIterate

    Boolean

    No

    Specifies whether to enable iterative calculation. Valid values:

    • true

    • false (default value)

    IterateCount

    Number

    No

    The maximum number of iterations. Valid values: 1 to 32767. Default value: 100.

    IterateDelta

    Number

    No

    The maximum error. The value must be greater than or equal to 0. Default value: 0.001.

    FullPrecision

    Boolean

    No

    Specifies whether the calculation is based on precision as displayed. Valid values:

    • true

    • false (default value)

    CalcMode

    Enum

    No

    The mode of iterative calculation. For more information, see XlCalcModeType.

    Callback

    Function

    No

    The callback function.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Configure iterative calculation.
      await app.ActiveWorkbook.SetCalcOptions({
        EnableIterate: false, 
        IterateCount: 300,
        IterateDelta: 0.1, 
        FullPrecision: false, 
        CalcMode: 'automatic',
        Callback:(res)=>console.error ('Callback function',res)
      })
    }

ActiveWorkbook.ClearTransactions()

You can clear undo records by using the ClearTransactions() method.

Important

Only JS-SDK V1.1.12 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.ClearTransactions()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Clear undo records.
      await app.ActiveWorkbook.ClearTransactions()
    }

ActiveWorkbook.HasTransactions()

You can check whether undo records exist by using the HasTransactions() method.

Important

Only JS-SDK V1.1.12 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.HasTransactions()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Check whether undo records exist.
      await app.ActiveWorkbook.HasTransactions()
    }

ActiveWorkbook.GetComments()

You can obtain all comments from an active workbook by using the GetComments() method.

Important

Only JS-SDK V1.1.12 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.GetComments()

    expression: the document type application object.

  • Return values

    Property

    Type

    Description

    CellComments

    Array<Object>

    A collection of comment information.

    PosInfo

    String

    The cell information.

    SheetName

    String

    The name of the worksheet.

    UserIds

    Array<String>

    A collection of user IDs.

  • The collection of comment information includes

    Property

    Type

    Description

    DateTime

    String

    The timestamp that indicates the time the comment was made.

    Text

    String

    The text of the comment.

    Time

    String

    The time when the comment was made. The format of Time is converted.

    UserId

    String

    The ID of the user.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all comments from an active workbook.
      const comments = await app.ActiveWorkbook.GetComments();
      console.log(comments);
    }

ActiveWorkbook.SkipAtCell()

By using the SkipAtCell() method, you can jump to the cell that includes an at sign (@).

Important

Only JS-SDK V1.1.12 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.SkipAtCell()

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    AtId

    String

    Yes

    The ID of the at sign (@).

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Jump to the cell that includes an at sign (@).
      await app.ActiveWorkbook.SkipAtCell(AtId)
    }

ActiveWorkbook.SetWatermark()

You can add a watermark by using the SetWatermark() method.

  • Syntax

    expression.ActiveWorkbook.SetWatermark()

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Type

    Number

    Yes

    Specifies whether to add a watermark. Valid values:

    • 1: Yes.

    • 0: No.

    Value

    String

    Yes

    The text in the watermark.

    FillStyle

    String

    Yes

    The fill style.

    Font

    String

    Yes

    The font of the watermark.

    Rotate

    Number

    Yes

    The rotation angle.

    Horizontal

    Number

    Yes

    The horizontal margin

    Vertical

    Number

    Yes

    The vertical margin

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Add a watermark.
      await app.ActiveWorkbook.SetWatermark({
        Type: 1,
        Value: "Test watermark",
        FillStyle: 'rgba(192, 192, 192, 0.6)',
        Font: "bold 20px Serif",
        Rotate: -45 * Math.PI / 180,
        Horizontal: 50,
        Vertical: 100,
      });
    }

ActiveWorkbook.GetWatermark()

You can obtain watermarks by using the GetWatermark() method.

  • Syntax

    expression.ActiveWorkbook.GetWatermark()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain a watermark.
      await app.ActiveWorkbook.GetWatermark();
    }

ActiveWorkbook.BuiltinDocumentProperties()

You can obtain the built-in document properties for an active workbook by using the BuiltinDocumentProperties() method.

  • Syntax

    expression.ActiveWorkbook.BuiltinDocumentProperties({ Name })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Name

    String

    Yes

    The built-in document property names:

    • Title.

    • Security.

    • Size.

    • Author.

    • CorpId: The ID of the corporation.

    • Guid: The ID of the safe document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the built-in document properties for the active workbook.
      const title = await app.ActiveWorkbook.BuiltinDocumentProperties('Title').Value;
      console.log('title: ', title);
    }

ActiveWorkbook.CustomDocumentProperties()

You can obtain the custom document properties for an active workbook by using the CustomDocumentProperties() property.

  • Syntax

    expression.ActiveWorkbook.CustomDocumentProperties({ Name })

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the custom document properties for an active workbook.
      const txt = await app.ActiveWorkbook.CustomDocumentProperties('AT_txt').Value;
      console.log('txt: ', txt);
    }

Properties

ActiveWorkbook.Names

By using the Names property, you can obtain a collection that represents the names of active workbooks.

  • Syntax

    expression.ActiveWorkbook.Names

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the active workbook.
      const activeWorkbook = await app.ActiveWorkbook;
    
      // Obtain a collection of workbook names.
      const names = await activeWorkbook.Names;
    }

ActiveWorkbook.Sheets

You can obtain all worksheets in an active workbook by using the Sheets method.

  • Syntax

    expression.ActiveWorkbook.Sheets

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all worksheets.
      const sheets = await app.ActiveWorkbook.Sheets;
    }

ActiveWorkbook.ReadOnly

By using the ReadOnly property, you can check whether an active workbook is read-only.

Important

Only JS-SDK V1.1.12 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.ReadOnly

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Check whether an active workbook is read-only.
      const ReadOnly = await app.ActiveWorkbook.ReadOnly;
    }

ActiveWorkbook.ReadOnlyComment

You can check whether an active worksheet is read-only and commentable by using the ReadOnlyComment property.

Important

Only JS-SDK V1.1.15 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.ReadOnlyComment

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Check whether an active workbook is read-only and commentable.
      const ReadOnlyComment = await app.ActiveWorkbook.ReadOnlyComment;
    }

ActiveWorkbook.SupportReadOnlyComment

By using the SupportReadOnlyComment property, you can check whether an active workbook supports the read-only and commentable mode.

Important

Only JS-SDK V1.1.15 and later support this feature.

  • Syntax

    expression.ActiveWorkbook.SupportReadOnlyComment

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Check whether an active workbook supports the read-only and commentable mode.
      const SupportReadOnlyComment = await app.ActiveWorkbook.SupportReadOnlyComment;
    }