Skip to main content
Version: 9.0.0

Excel Actions

readExcelWorkBook

Description: Reads an Excel workbook based on the provided options.

ParameterTypeDescription
optionsReadExcelWorkBookOptionsReadExcelWorkBook Options.

ReadExcelWorkBookOptions

ParameterTypeDescription
filePathstringPath to the Excel file.
sheetnumber | stringSheet name or index to read from (optional, default: 0).
includeEmptyHeadersboolean (optional)Include empty headers in the result.
includeEmptyRowsboolean (optional)Include empty rows in the result.
includeEmptyColumnsboolean (optional)Include empty columns in the result.

Basic Usage

const options = {
filePath: './relative-file-path.xlsx',
sheet: 'Sheet1',
includeEmptyHeaders: true
};
const result = await Excel.readExcelWorkBook(options);
console.log(result);

deleteExcelWorkBook

Description: Deletes an Excel workbook based on the provided options.

ParameterTypeDescription
optionsDeleteExcelWorkBookOptionsDeleteExcelWorkBook Options.

DeleteExcelWorkBookOptions

ParameterTypeDescription
filePathstringPath to the Excel file to delete.

Basic Usage

await Excel.deleteExcelWorkBook({
filePath: './relative-file-path.xlsx'
});

editExcelWorkBook

Description: Edits an Excel workbook based on the provided options.

ParameterTypeDescription
filePathstringPath to the Excel file.
addobject (optional)Add new elements to the Excel workbook.
editobject (optional)Edit existing elements in the Excel workbook.
deleteobject (optional)Delete elements from the Excel workbook.

add

ParameterTypeDescription
sheetsstring[] (optional)Array of sheet names or numbers to add.
columns{ sheet, index, header, key, width? }[]Array of columns to add.
rows{ sheet, index, values[] }[]Array of rows to add.
cellsEditCellOptions[]Array of cells to add.

edit

ParameterTypeDescription
cellsEditCellOptions[]Array of cells to edit.

delete

ParameterTypeDescription
sheets(string | number)[]Array of sheet names or numbers to delete.
columns{ sheet, index }[]Array of columns to delete.
rows{ sheet, index }[]Array of rows to delete.
cellsOmit<EditCellOptions, 'value'>[]Array of cells to delete.

Basic Usage

const options: EditExcelWorkBookOptions = {
filePath: "./path/to/excel-file.xlsx",
add: {
sheets: ["Sheet1"],
columns: [{ sheet: "Sheet1", index: 1, header: "Column1", key: "key1", width: 100 }],
rows: [{ sheet: "Sheet1", index: 1, values: ["Value1", "Value2"] }],
cells: [{ sheet: "Sheet1", row: 1, column: 1, value: "New Value" }],
},
edit: {
cells: [{ sheet: "Sheet1", row: 1, column: 1, value: "Edited Value" }],
},
delete: {
sheets: ["Sheet1"],
columns: [{ sheet: "Sheet1", index: 1 }],
rows: [{ sheet: "Sheet1", index: 1 }],
cells: [{ sheet: "Sheet1", row: 1, column: 1 }],
},
};
await Excel.editExcelWorkBook(options);

getExcelWorkBookColumns

Description: Gets columns from an Excel workbook.

ParameterTypeDescription
filePathstringPath to the Excel file.
sheetnumber | string (optional)Sheet number or name.
columns(number | string)[]Columns to retrieve.

Basic Usage

// Example 1: Retrieve all columns from the default sheet
const columns1 = await Excel.getExcelWorkBookColumns({ filePath: "./path/to/excel-file.xlsx" });
console.log(columns1);

// Example 2: Retrieve columns from a specific sheet
const columns2 = await Excel.getExcelWorkBookColumns({ filePath: "./path/to/excel-file.xlsx", sheet: "Sheet1" });
console.log(columns2);

// Example 3: Retrieve specific columns from the default sheet
const columns3 = await Excel.getExcelWorkBookColumns({ filePath: "./path/to/excel-file.xlsx", columns: [1, "Column2"] });
console.log(columns3);

getExcelWorkBookRows

Description: Gets rows from an Excel workbook.

ParameterTypeDescription
filePathstringPath to the Excel file.
sheetnumber | string (optional)Sheet number or name.
rowsnumber[]Rows to retrieve.

Basic Usage

// Example 1: Retrieve all rows from the default sheet
const rows1 = await Excel.getExcelWorkBookRows({ filePath: "./path/to/excel-file.xlsx" });
console.log(rows1);

// Example 2: Retrieve rows from a specific sheet
const rows2 = await Excel.getExcelWorkBookRows({ filePath: "./path/to/excel-file.xlsx", sheet: "Sheet1" });
console.log(rows2);

// Example 3: Retrieve specific rows from the default sheet
const rows3 = await Excel.getExcelWorkBookRows({ filePath: "./path/to/excel-file.xlsx", rows: [1, 3, 5] });
console.log(rows3);

getExcelWorkBookCells

Description: Gets cells from an Excel workbook.

ParameterTypeDescription
filePathstringPath to the Excel file.
sheetnumber | string (optional)Sheet number or name.
cells{row?: number, column?: number, ref?: string}[]Cells to retrieve.

Basic Usage

const cells = await Excel.getExcelWorkBookCells(options);
console.log(cells);

getExcelWorkBookRange

Description: Gets a specific range from an Excel workbook.

ParameterTypeDescription
filePathstringPath to the Excel file.
sheetnumber / string (optional)Sheet number or name.
startColumnnumberStarting column index.
endColumnnumberEnding column index.
startRownumberStarting row index.
endRownumberEnding row index.

Basic Usage

const range = await Excel.getExcelWorkBookRange(options);
console.log(range);