This topic describes the API operations that are related to the ActiveSheet object of table documents.
ActiveSheet
ActiveWorkbook.ActiveSheet
Obtains the active sheet in the active workbook.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveWorkbook.ActiveSheetexpression: 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 the active worksheet in an active workbook. const activeSheet = await activeWorkbook.ActiveSheet; }
Methods
ActiveWorkbook.ActiveSheet.Delete()
You can delete the active worksheet by using the Delete() method.
Syntax
expression.ActiveWorkbook.ActiveSheet.Delete()expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Delete the active worksheet. await activeSheet.Delete(); }
ActiveWorkbook.ActiveSheet.ExportAsFixedFormat()
By using the ExportAsFixedFormat() method, you can export the active worksheet as a PDF file or an IMG image and obtain the URL of the exported file.
Syntax
expression.ActiveWorkbook.ActiveSheet.ExportAsFixedFormat({ Type })expression: the document type application object.
Parameters
Property
Type
Required
Description
Type
Enum
Yes
The type of file format to export to. Only images and PDF files are supported. For more information, see XlFixedFormatType.
Return values
Returns 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.ActiveSheet.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 workbookPdfUrl = await app.ActiveWorkbook.ActiveSheet.ExportAsFixedFormat({ Type: app.Enum.XlFixedFormatType.xlTypeIMG, }); console.log(workbookPdfUrl); }
ActiveWorkbook.ActiveSheet.Protect()
By using the Protect() method, you can protect the active worksheet so that it cannot be modified.
Syntax
expression.ActiveWorkbook.ActiveSheet.Protect({ Password, DrawingObjects, Scenarios, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables })expression: the document type application object.
Parameters
Property
Type
Required
Description
Password
String
No
Specifies the password for the active worksheet. The password is a case-sensitive string.
If this argument is omitted, you can unprotect the active worksheet without using a password.
Otherwise, you must specify the password to unprotect the active worksheet.
ImportantPlease remember the password. If you forget the password, you cannot unprotect the active worksheet.
DrawingObjects
Boolean
No
Specifies whether to protect the shapes in the active worksheet. Valid values:
false (default value)
true
Scenarios
Boolean
No
Specifies whether to protect the scenarios in the active worksheet. Valid values:
true (default value)
false
AllowFormattingCells
Boolean
No
Specifies whether to allow the user to format the cells in the protected worksheet. Valid values:
false (default value)
true
AllowFormattingColumns
Boolean
No
Specifies whether to allow the user to format the columns in the protected worksheet. Valid values:
false (default value)
true
AllowFormattingRows
Boolean
No
Specifies whether to allow the user to format the rows in the protected worksheet. Valid values:
false (default value)
true
AllowInsertingColumns
Boolean
No
Specifies whether to allow the user to insert columns into the protected worksheet. Valid values:
false (default value)
true
AllowInsertingRows
Boolean
No
Specifies whether to allow the user to insert rows into the protected worksheet. Valid values:
false (default value)
true
AllowInsertingHyperlinks
Boolean
No
Specifies whether to allow the user to insert hyperlinks into the protected worksheet. Valid values:
false (default value)
true
AllowDeletingColumns
Boolean
No
Specifies whether to allow the user to delete columns from the protected worksheet. Valid values:
false (default value)
true Every cell in the column that you want to delete must be unlocked.
AllowDeletingRows
Boolean
No
Specifies whether to allow the user to delete rows from the protected worksheet. Valid values:
false (default value)
true Every cell in the row that you want to delete must be unlocked.
AllowSorting
Boolean
No
Specifies whether to allow the user to sort the protected worksheet. Valid values:
false (default value)
true Every cell in the sort range must be unlocked or unprotected.
AllowFiltering
Boolean
No
Specifies whether to allow the user to set filters in the protected worksheet. Valid values:
false (default value)
true Users can set filters or change filter criteria on an existing auto filter, but cannot enable or disable an auto filter.
AllowUsingPivotTables
Boolean
No
Specifies whether to allow the user to use PivotTable reports in the protected worksheet. Valid values:
false (default value)
true
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Specify a password. activeSheet.Protect('123456'); }
ActiveWorkbook.ActiveSheet.Unprotect()
You can remove protection from the active worksheet by using the Unprotect() method. If the active workbook is not protected, the method has no effect.
Syntax
expression.ActiveWorkbook.ActiveSheet.Unprotect({ Password })expression: the document type application object.
Parameters
Property
Type
Required
Description
Password
String
No
The password that you specify.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Remove protection. activeSheet.Unprotect('123456'); }
ActiveWorkbook.ActiveSheet.Move()
You can move the active workbook by using the Move() method.
Only JS-SDK V1.1.12 and later support this feature.
Syntax
expression.ActiveWorkbook.ActiveSheet.Move({ Before, After })expression: the document type application object.
Parameters
Property
Type
Required
Description
Before
number
No
The ID of the worksheet before which the active worksheet is moved. You cannot specify After if you specify Before.
After
number
No
The ID of the worksheet after which the active worksheet is moved. You cannot specify Before if you specify After.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Move the active worksheet after this worksheet. await app.ActiveWorkbook.Sheets(1).Move({ Before: null, After: await app.ActiveWorkbook.Sheets(2).Id, }
ActiveWorkbook.ResetClipBoard()
You can remove the marching ants around the cell that you copy by using the ResetClipBoard() method.
Syntax
expression.ActiveWorkbook.ResetClipBoard({ Range })expression: the document type application object.
Example
//@file=base.xlsx async function example() { await instance.ready(); const app = instance.Application; const range = await app.Selection; // Remove the marching ants. await app.ActiveWorkbook.ResetClipBoard() }
Properties
ActiveWorkbook.ActiveSheet.Cells
A Range object is returned for all cells in a worksheet.
You can obtain all cells in the active worksheet by using the Cells property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Cellsexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain all cells in the active worksheet. const cells = await activeSheet.Cells; }
ActiveWorkbook.ActiveSheet.Columns
A Range object is returned for all columns in a worksheet.
You can obtain all columns in the active worksheet by using the Columns property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Columnsexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain all columns in the active worksheet. const chartObjects = await activeSheet.Columns; }
ActiveWorkbook.ActiveSheet.Index
You can obtain the index number of the active worksheet by using the Index property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Indexexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain the index number of the active worksheet. const index = await activeSheet.Index; console.log(index); }
ActiveWorkbook.ActiveSheet.Name
You can obtain the name of the active worksheet by using the Name property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Nameexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain the name of the active worksheet. const name = await app.ActiveWorkbook.ActiveSheet.Name; console.log(name); }
ActiveWorkbook.ActiveSheet.Names
You can obtain all worksheet-specific names of the active worksheet by using the Names property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Namesexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain all worksheet-specific names of the active worksheet. const names = await activeSheet.Names; }
ActiveWorkbook.ActiveSheet.Range
You can obtain a cell, a row, a column, or a range of one or more continuous cells in the active worksheet by using the Range property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Rangeexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain a range of cells in the active worksheet. const range = await app.Range('A1'); }
ActiveWorkbook.ActiveSheet.Rows
You can obtain all rows in the active worksheet by using the Rows property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Rowsexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain all rows in the active worksheet. const chartObjects = await activeSheet.Rows; }
ActiveWorkbook.ActiveSheet.Shapes
You can obtain all Shape objects in the active worksheet by using the Shapes property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Shapesexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain all Shape objects in the active worksheet. const shapes = await activeSheet.Shapes; }
ActiveWorkbook.ActiveSheet.Visible
You can specify whether the active worksheet is visible by using the Visible property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Visibleexpression: the document type application object.
If you specify
trueforVisible, the active worksheet is visible. If you specifyfalse, the active worksheet is invisible.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Configure the active worksheet to be invisible. activeSheet.Visible = false; }
ActiveWorkbook.ActiveSheet.UsedRange
You can obtain the used range in the active worksheet by using the UsedRange property.
Syntax
expression.ActiveWorkbook.ActiveSheet.UsedRangeexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain the used range in the active worksheet. const UsedRange = await activeSheet.UsedRange; }
ActiveWorkbook.ActiveSheet.Type
You can obtain the type of the active worksheet by using the Type property. The active worksheet can be one of three types: xlWorksheet (normal worksheet), xlEtDataBaseSheet (blank data table), and xlEtDashBoardSheet (dashboard).
Syntax
expression.ActiveWorkbook.ActiveSheet.Typeexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain the type of the active worksheet. const type = await activeSheet.Type; console.log(type); }
ActiveWorkbook.ActiveSheet.Id
You can obtain the ID of the active worksheet by using the Id property.
Syntax
expression.ActiveWorkbook.ActiveSheet.Idexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain the ID of the active worksheet. const id = await activeSheet.Id; console.log(id); }
ActiveWorkbook.ActiveSheet.ChartObjects
You can obtain all charts in the worksheet by using the ChartObjects property.
Syntax
expression.ActiveWorkbook.ActiveSheet.ChartObjectsexpression: the document type application object.
Example
//@file=base.xlsx async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain all charts in the worksheet const chartObjects = await activeSheet.ChartObjects; }ActiveWorkbook.ActiveSheet.AllowEditRanges
Obtains the allow edit ranges in the active worksheet of the active workbook.
Syntax
expression.ActiveWorkbook.ActiveSheet.AllowEditRangesexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active worksheet in an active workbook. const activeSheet = await app.ActiveWorkbook.ActiveSheet; // Obtain the allow edit ranges in the active worksheet. const allowEditRanges = await activeSheet.AllowEditRanges; }