Skip to content

informat.excel Excel File Operations ​

Overview ​

Use the informat.excel object for Excel file read and write operations

Reference

File paths must be in the local sandbox path. For more information about file paths, refer to informat.file

openExistFile ​

Open an existing Excel file

Note

If the file does not exist, an exception will be thrown

javascript
informat.excel.openExistFile(file);
ParameterTypeDescription
fileStringFile path in the app's sandbox environment

Return Value

Returns a Workbook object

Example

javascript
informat.excel.openExistFile("gzb.xlsx");

openNewFile ​

Create a new Excel file

javascript
informat.excel.openNewFile(file);

TIP

If the file exists, its content will be overwritten when saved

ParameterTypeDescription
fileStringFile path in the app's sandbox environment

Return Value

Returns a Workbook object

Example

javascript
informat.excel.openNewFile("gzb2.xlsx");

openWithTemplate ​

Create a Workbook based on a template.

javascript
informat.excel.openWithTemplate(file, templateFile, data);
ParameterTypeDescription
fileStringThe generated Excel file
templateFileStringThe path to the template file
dataObjectVariables passed to the template file

Return Value

Returns a Workbook object


openWithTemplateWithSheets ​

Create a Workbook based on a multi-sheet template.

javascript
informat.excel.openWithTemplateWithSheets(file, templateFile, sheetNums, data);

TIP

If sheetNums is empty, all worksheets will be exported.

ParameterTypeDescription
fileStringThe generated Excel file
templateFileStringThe path to the template file
sheetNumsArray<Integer>Worksheet number list, starting from 0; to export only the 2nd and 3rd worksheets, enter [1,2]
dataObjectVariables passed to the template file

Return Value

Returns a Workbook object

Template Expressions

createTemplatePicture ​

Create a template picture object

javascript
informat.excel.createTemplatePicture(pic);
ParameterTypeDescription
imageExcelTamplatePicturePicture configuration

Return Value

Returns the picture used in the template

Example

javascript
informat.excel.createTemplatePicture({
  type: "file", // Local storage
  content: "pathto/img.jpg", // File path in local storage
  width: 100, // Width
  height: 100, // Height
});

informat.excel.createTemplatePicture({
  type: "storage", // Shared storage
  content: "pathto/img.jpg", // File path in shared storage
});
javascript
informat.excel.createTemplatePicture({
  type: "barcode", // Barcode
  content: "1234557", // Content
  width: 100, // Width
  height: 100, // Height
});
javascript
informat.excel.createTemplatePicture({
  type: "qrcode", // QR code
  content: "https://ainformat.com", // Content
  width: 100, // Width
  height: 100, // Height
});

createTemplateCell ​

Create a template cell

javascript
informat.excel.createTemplateCell(cell);
ParameterTypeDescription
cellExcelTamplateCellCell configuration

Return Value

Returns the cell used in the template

Example

js
const companyCell = informat.excel.createTemplateCell({
  content: "Shenzhen Jishi Collaboration Co., Ltd.", // Cell content
  rowspan: 2, // Number of row cells, default is 1
  colspan: 2, // Number of column cells, default is 1
});

Workbook ​

createSheet ​

Create a new Sheet

javascript
workbook.createSheet(sheetName);

TIP

sheetName cannot contain 0x0000 0x0003 : \ * ? / [``]

ParameterTypeDescription
sheetNameStringSheet name

Return Value

Returns a Sheet object

Example

js
workbook.createSheet("sheet1");

createSafeSheetName ​

Create a valid sheet name

javascript
workbook.createSafeSheetName(sheetName);

TIP

Some special characters are not allowed in sheet names. This method automatically filters out these disallowed special characters.

ParameterTypeDescription
sheetNameStringSheet name

Return Value

Returns a String, the sheet name with special characters filtered out

Example

js
workbook.createSafeSheetName("sheet1");

getSheet ​

Get a Sheet by name

javascript
workbook.getSheet(sheetName);
ParameterTypeDescription
sheetNameStringSheet name

Return Value

Returns a Sheet object, or null if sheetName does not exist

Example

js
workbook.getSheet("sheet1");

getSheetAt ​

Get a Sheet by position index

javascript
workbook.getSheetAt(sheetIdx);
ParameterTypeDescription
sheetIdxIntegerSheet index, starting from 0

Return Value

Returns a Sheet object, or null if the sheet does not exist

Example

js
workbook.getSheetAt(0);

getNumberOfSheets ​

Get the number of sheets

javascript
workbook.getNumberOfSheets();

Return Value Returns an Integer object, the number of sheets


write ​

Write content to file

javascript
workbook.write();

TIP

After calling write, the sheet content will be written to the file, and the workbook will be closed. The write method cannot be called repeatedly. If an error occurs during writing (such as insufficient disk space), an exception will be thrown


createFont ​

Create a font configuration

TIP

Used for setting cell formatting

javascript
workbook.createFont();

Return Value

Returns a Font object that describes the font


createCellStyle ​

Create a cell style configuration

javascript
workbook.createCellStyle();

TIP

Cell style configuration can set cell styles such as color, background color, borders, alignment, etc.

Return Value Returns a CellStyle object that describes the cell style

Sheet ​

getSheetName ​

Get the sheet name

javascript
sheet.getSheetName();

Return Value

Returns a String object, the sheet name


createRow ​

Create a row

javascript
sheet.createRow(row);
ParameterTypeDescription
rowIntegerRow index, starting from 0

Return Value

Returns a Row object

Example

js
sheet.createRow(0);

getRow ​

Get a row

javascript
sheet.getRow(row);
ParameterTypeDescription
rowIntegerRow index, starting from 0

Return Value

Returns a Row object

Example

js
sheet.getRow(0);

removeRow ​

Delete a row

javascript
sheet.removeRow(row);
ParameterTypeDescription
rowIntegerRow index, starting from 0

Example

js
sheet.removeRow(0);

getFirstRowNum ​

Get the index of the first row in the sheet

javascript
sheet.getFirstRowNum();

Return Value

Returns an Integer object, the index of the first row


getLastRowNum ​

Get the index of the last row in the sheet

javascript
sheet.getLastRowNum();

Return Value

Returns an Integer object, the index of the last row


getDefaultRowHeightInPoints ​

Get the default row height

javascript
sheet.getDefaultRowHeightInPoints();

Return Value Returns a Double object, the default row height


setDefaultRowHeightInPoints ​

Set the default row height

javascript
sheet.setDefaultRowHeightInPoints(height);
ParameterTypeDescription
heightDoubleDefault row height in pixels

getDefaultColumnWidth ​

Get the default column width

javascript
sheet.getDefaultColumnWidth();

Return Value

Returns an Integer object, the default column width


setDefaultColumnWidth ​

Set the default column width

javascript
sheet.setDefaultColumnWidth(width);
ParameterTypeDescription
widthIntegerDefault column width

setColumnWidth ​

Set the column width

javascript
sheet.setColumnWidth(colIdx, width);
ParameterTypeDescription
colIdxIntegerColumn index
widthIntegerColumn width

autoSizeColumn ​

Automatically set column width based on content

javascript
sheet.autoSizeColumn(colIdx);

TIP

Auto column width function only takes effect after data insertion is completed

ParameterTypeDescription
colIdxIntegerColumn index

setDefaultColumnStyle ​

Set the default cell style for a column

javascript
sheet.setDefaultColumnStyle(colIdx, cellStyle);
ParameterTypeDescription
colIdxIntegerColumn index, starting from 0
cellStyleCellStyleCell style

getColumnStyle ​

Get the default cell style for a column

javascript
sheet.getColumnStyle(colIdx);
ParameterTypeDescription
colIdxIntegerColumn index, starting from 0

Return Value

Returns a CellStyle object, the default cell style


addMergedRegion ​

Merge cells

javascript
sheet.addMergedRegion(firstRow, lastRow, firstColumn, lastColumn);
ParameterTypeDescription
firstRowIntegerFirst row, starting from 0
lastRowIntegerLast row, starting from 0
firstColumnIntegerFirst column, starting from 0
lastColumnIntegerLast column, starting from 0

addPicture ​

Insert a picture from the local sandbox into a cell

javascript
sheet.addPicture(col, row, filePath);
ParameterTypeDescription
colIntegerColumn to insert, starting from 0
rowIntegerRow to insert, starting from 0
filePathStringPath of the picture to insert, in the app's sandbox

Return Value

Returns a Picture object


addPictureStorage ​

Insert a picture from shared storage into a cell

javascript
sheet.addPictureStorage(col, row, filePath);
ParameterTypeDescription
colIntegerColumn to insert, starting from 0
rowIntegerRow to insert, starting from 0
filePathStringPath of the picture to insert, in shared storage

Return Value Returns a Picture object


addPictureBarcode ​

Insert a barcode picture into a cell

javascript
sheet.addPictureBarcode(col, row, setting);
ParameterTypeDescription
colIntegerColumn to insert, starting from 0
rowIntegerRow to insert, starting from 0
settingPictureSettingPicture configuration

Return Value

Returns a Picture object


addPictureQrcode ​

Insert a QR code picture into a cell

javascript
sheet.addPictureQrcode(col, row, setting);
ParameterTypeDescription
colIntegerColumn to insert, starting from 0
rowIntegerRow to insert, starting from 0
settingPictureSettingPicture configuration

Return Value

Returns a Picture object


getPictures ​

Get all pictures in the sheet

javascript
sheet.getPictures();

Return Value

Returns an Array<Picture> object


getObjectDatas ​

Get all attachments in the sheet

javascript
sheet.getObjectDatas();

Return Value Returns an Array<ExcelObjectData> object

Row ​


createCell ​

Create a cell

javascript
row.createCell(colIdx);
ParameterTypeDescription
colIdxIntegerColumn to insert, starting from 0

Return Value Returns a Cell object


createCellWithValue ​

Create a cell with a value

javascript
row.createCellWithValue(colIdx, value);
ParameterTypeDescription
colIdxIntegerColumn to insert, starting from 0
valueObjectValue to insert. Date, Boolean, and Number types are saved as their original types; other types are converted to strings

Return Value Returns a Cell object


getCell ​

Get a cell

javascript
row.getCell(colIdx);
ParameterTypeDescription
colIdxIntegerColumn to get, starting from 0

Return Value

Returns a Cell object, or null if the cell does not exist


removeCell ​

Remove a cell

javascript
row.removeCell(colIdx);
ParameterTypeDescription
colIdxIntegerColumn to remove, starting from 0

getFirstCellNum ​

Get the index of the first column

javascript
row.getFirstCellNum();

Return Value

Returns an Integer, the index of the first column


getLastCellNum ​

Get the index of the last column

javascript
row.getLastCellNum();

Return Value

Returns an Integer, the index of the last column


getRowNum ​

Get the row index

javascript
row.getRowNum();

Return Value

Returns an Integer, the row index


getHeightInPoints ​

Get row height

javascript
row.getHeightInPoints();

Return Value

Returns a Double, the row height


setHeightInPoints ​

Set row height

javascript
row.setHeightInPoints(height);
ParameterTypeDescription
heightDoubleRow height in pixels

setStyle ​

Set the cell style for the row

javascript
row.setStyle(cellStyle);
ParameterTypeDescription
cellStyleCellStyleCell style

getStyle ​

Get the cell style for the row

javascript
row.getStyle();

Return Value

Returns a CellStyle

Cell ​

setValue ​

Set cell value

javascript
cell.setValue(value);

TIP

Cells support String, Boolean, Double, and Date types. Values of other types will be converted to strings for storage.

ParameterTypeDescription
valueObjectCell value

getValue ​

Get cell value

javascript
cell.getValue();

getValueEvaluated ​

Get cell value after formula calculation

javascript
cell.getValueEvaluated();

setStyle ​

Set cell style

javascript
cell.setStyle(cs);
ParameterTypeDescription
cellStyleCellStyleCell style

getStyle ​

Get cell style

javascript
cell.getStyle();

Return Value

Returns a CellStyle


Set cell hyperlink

javascript
cell.setHyperlink(link);
ParameterTypeDescription
linkStringLink URL

Get cell hyperlink

javascript
cell.getHyperlink();

Return Value

Returns a String representing the hyperlink URL, or null if no hyperlink exists

Style ​


setAlignment ​

Set horizontal alignment

javascript
cellStyle.setAlignment(align);
ParameterTypeDescription
alignStringOptional values: CENTER, CENTER_SELECTION, DISTRIBUTED, FILL, GENERAL, JUSTIFY, LEFT, RIGHT

getAlignment ​

Get horizontal alignment

javascript
cellStyle.getAlignment();

Return Value

Type: String


setVerticalAlignment ​

Set vertical alignment

javascript
cellStyle.setVerticalAlignment(align);
ParameterTypeDescription
alignStringOptional values: BOTTOM, CENTER, DISTRIBUTED, JUSTIFY, TOP

getVerticalAlignment ​

Get vertical alignment

javascript
cellStyle.getVerticalAlignment();

Return Value

Type: String


getDataFormatString ​

Get cell data format

javascript
cellStyle.getDataFormatString();

Return Value

Type: String


setWrapText ​

Set whether cell text can wrap

javascript
cellStyle.setWrapText(wrap);
ParameterTypeDescription
wrapBooleanWhether text wraps

getWrapText ​

Get whether cell text wraps

javascript
cellStyle.getWrapText();

Return Value

Returns a String


setFont ​

Set cell text font

javascript
cellStyle.setFont(font);
ParameterTypeDescription
fontFontFont object

setFillForegroundColor ​

Set cell fill foreground color

javascript
cellStyle.setFillForegroundColor(color);
ParameterTypeDescription
colorStringHexadecimal color code, e.g., #ff0000 for red

setFillBackgroundColor ​

Set cell fill background color

javascript
cellStyle.setFillBackgroundColor(color);
ParameterTypeDescription
colorStringHexadecimal color code, e.g., #ff0000 for red

setFillPattern ​

Set fill pattern

javascript
cellStyle.setFillPattern(type);
ParameterTypeDescription
typeStringOptional values: ALT_BARS, BIG_SPOTS, BRICKS, DIAMONDS, FINE_DOTS, LEAST_DOTS, LESS_DOTS, NO_FILL, SOLID_FOREGROUND, SPARSE_DOTS, SQUARES, THICK_BACKWARD_DIAG, THICK_FORWARD_DIAG, THICK_HORZ_BANDS, THICK_VERT_BANDS, THIN_VERT_BANDS

setHidden ​

Set whether cell is hidden

javascript
cellStyle.setHidden(hidden);
ParameterTypeDescription
hiddenBooleanWhether to hide

setIndention ​

Set indentation

javascript
cellStyle.setIndention(indent);
ParameterTypeDescription
indentIntegerIndent value

setBorderTop ​

Set top border style

js
cellStyle.setBorderTop(borderStyle);
ParameterTypeDescription
borderStyleStringBorder style

Border style options:

  • NONE:No border
  • THIN:Thin border
  • MEDIUM:Medium border
  • DASHED:Dashed border
  • DOTTED:Dotted border
  • THICK:Thick border
  • DOUBLE:Double border
  • HAIR:Hairline border
  • MEDIUM_DASHED:Medium dashed border
  • DASH_DOT:Dash-dot border
  • MEDIUM_DASH_DOT:Medium dash-dot border
  • DASH_DOT_DOT:Dash-dot-dot border
  • MEDIUM_DASH_DOT_DOT:Medium dash-dot-dot border
  • SLANTED_DASH_DOT:Slanted dash-dot border

setBorderBottom ​

Set bottom border style

js
cellStyle.setBorderBottom(borderStyle);
ParameterTypeDescription
borderStyleStringBorder style

setBorderLeft ​

Set left border style

js
cellStyle.setBorderLeft(borderStyle);
ParameterTypeDescription
borderStyleStringBorder style

setBorderRight ​

Set right border style

js
cellStyle.setBorderRight(borderStyle);
ParameterTypeDescription
borderStyleStringBorder style

setLeftBorderColor ​

Set left border color

javascript
cellStyle.setLeftBorderColor(color);
ParameterTypeDescription
colorStringColor, e.g., #f0f0f0

setRightBorderColor ​

Set the right border color

javascript
cellStyle.setRightBorderColor(color);
ParameterTypeDescription
colorStringColor, e.g., #f0f0f0

setTopBorderColor ​

Set the top border color

javascript
cellStyle.setTopBorderColor(color);
ParameterTypeDescription
colorStringColor, e.g., #f0f0f0

setBottomBorderColor ​

Set the bottom border color

javascript
cellStyle.setBottomBorderColor(color);
ParameterTypeDescription
colorStringColor, e.g., #f0f0f0

setRotation ​

Set the text rotation angle

javascript
cellStyle.setRotation(rotation);
ParameterTypeDescription
rotationIntegerRotation angle, e.g., 90

setDataFormat ​

Set the cell format

javascript
cellStyle.setDataFormat(fmt);
ParameterTypeDescription
fmtStringCell format, e.g., #0.00

Font ​

setBold ​

Set whether the text is bold

javascript
font.setBold(bold);
ParameterTypeDescription
boldBooleanWhether bold

setItalic ​

Set whether the text is italic

javascript
font.setItalic(italic);
ParameterTypeDescription
italicBooleanWhether italic

setUnderline ​

Set whether the text has an underline

javascript
font.setUnderline(underline);
ParameterTypeDescription
underlineBooleanWhether underline

setFontHeightInPoints ​

Set the font size

javascript
font.setFontHeightInPoints(size);
ParameterTypeDescription
sizeIntegerFont size

setFontName ​

Set the font name

javascript
font.setFontName(name);
ParameterTypeDescription
nameStringFont name

Picture ​


getRow ​

Get the row number

javascript
picture.getRow();

Return Value

Returns Integer


getColumn ​

Get the column number

javascript
picture.getColumn();

Return Value

Returns Integer


save ​

Save the picture content to the local sandbox

javascript
picture.save(path);
ParameterTypeDescription
pathStringPath to save in the local sandbox

saveStorage ​

Save the picture content to shared storage

javascript
picture.saveStorage(path);
ParameterTypeDescription
pathStringPath to save in shared storage

saveAttachment ​

Save the picture content as an attachment field

javascript
picture.saveAttachment(tableId, fieldId);
ParameterTypeDescription
tableIdStringTable identifier
fieldIdStringAttachment field identifier

Return Value

Returns a TableAttachment object


setScale ​

Set the picture scale ratio

javascript
picture.setScale(wScale, hScale);
ParameterTypeDescription
wScaleDoubleWidth scale ratio
hScaleDoubleHeight scale ratio

setSize ​

Set the picture width and height

javascript
picture.setSize(width, height);
ParameterTypeDescription
widthIntegerPicture width
heightIntegerPicture height

fitWidth ​

Scale the picture to fit the cell width

javascript
picture.fitWidth();

TIP

After scaling, the picture width is less than or equal to the cell width, and the picture height scales proportionally with the width


fitHeight ​

Scale the picture to fit the cell height

javascript
picture.fitHeight();

TIP

After scaling, the picture height is less than or equal to the cell height, and the picture width scales proportionally with the height


resetSize ​

Set the picture size to its original dimensions

javascript
picture.resetSize();

ExcelObjectData ​

Excel Attachment


getRow ​

Get the attachment's row number

javascript
objectData.getRow();

Return Value

Returns Integer


getColumn ​

Get the attachment's column number

javascript
objectData.getColumn();

Return Value

Returns Integer


save ​

Save the file content to the local sandbox

javascript
objectData.save(path);
ParameterTypeDescription
pathStringPath to save in the local sandbox

saveStorage ​

Save the file content to shared storage

javascript
objectData.saveStorage(path);
ParameterTypeDescription
pathStringPath to save in shared storage

saveAttachment ​

Save the file content as an attachment field

javascript
objectData.saveAttachment(tableId, fieldId);
ParameterTypeDescription
tableIdStringTable identifier
fieldIdStringAttachment field identifier

Return Value

Returns a TableAttachment object


hasDirectoryEntry ​

Check if there is an associated POIFS directory entry

javascript
objectData.hasDirectoryEntry();

getOLE2ClassName ​

Get the name of the OLE2 class object

javascript
objectData.getOLE2ClassName();

getFileName ​

Get the file name

javascript
objectData.getFileName();

getContentType ​

Get the content type

javascript
objectData.getContentType();

Examples ​

Example 1: Read data from all cells in Excel ​

js
const workbook = informat.excel.openExistFile("test.xlsx");
for (var sheetIdx = 0; sheetIdx < workbook.getNumberOfSheets(); sheetIdx++) {
  const sheet = workbook.getSheetAt(sheetIdx);
  console.log("sheet name is " + sheet.getSheetName());
  // Return all cell data
  for (var rowIndex = sheet.getFirstRowNum(); rowIndex <= sheet.getLastRowNum(); rowIndex++) {
    const row = sheet.getRow(rowIndex);
    for (var colIndex = row.getFirstCellNum(); colIndex < row.getLastCellNum(); colIndex++) {
      const cell = row.getCell(colIndex);
      if (cell != null) {
        console.log(cell.getValueEvaluated());
      }
    }
  }
  // Return all pictures
  sheet.getPictures().forEach((p) => {
    console.log("picture " + p.getRow() + " " + p.getColumn());
  });
  // After reading pictures, you can use picture's save(localPath), saveStorage(path), or saveAttachment(tableKey, fieldKey, fieldName) to store the file content to the local sandbox or shared storage
}

Example 2: Write data to an Excel file ​

js
const workbook = informat.excel.openNewFile("test.xlsx");
const sheet = workbook.createSheet("sheet1");
const style = workbook.createCellStyle();
const font = workbook.createFont();
font.setBold(true);
font.setItalic(true);
font.setFontHeightInPoints(14);
//
style.setFont(font);
style.setFillBackgroundColor("#fafafa"); // Set gray background
style.setAlignment("CENTER"); // Horizontal center
style.setVerticalAlignment("CENTER"); // Vertical center
style.setFillPattern("SOLID_FOREGROUND");
//
for (var i = 0; i < 10; i++) {
  const row = sheet.createRow(i);
  const cell = row.createCellWithValue(0, "string");
  cell.setStyle(style);
  row.createCellWithValue(1, "https://ainformat.com/").setHyperlink("https:/ainformat.com");
  row.createCellWithValue(2, true);
  row.createCellWithValue(3, 3.14);
  row.createCellWithValue(4, new Date());
}
//
sheet.addMergedRegion(0, 2, 0, 3); // Merge cells
// The auto column width function only works after data insertion is complete
sheet.autoSizeColumn(0); // Auto-adjust width for columns 0 and 1
sheet.autoSizeColumn(1);
//
workbook.write();
//

Example 3: Generate Excel using a template file ​

js
const templateFilePath = "excel_template.xlsx";
const outputFilePath = "result.xlsx";
informat.website.download("website", "excel/excel_template.xlsx", templateFilePath);
const workbook = informat.excel.openWithTemplate(outputFilePath, templateFilePath, {
  orgName: "xxx",
  goodAtProduct: "xxx",
  addresss: "xxxxxxx",
  reviewUser: "xxx",
  reviewTime: new Date(),
  list: [
    { sort: 1, question: "project1", standard: "A", score: 95, realScore: 98, realTotalScore: 99 },
    { sort: 2, question: "project2", standard: "B", score: 78, realScore: 79, realTotalScore: 80 },
    { sort: 3, question: "project3", standard: "C", score: 65, realScore: 62, realTotalScore: 66 },
  ],
});
workbook.write();

TIP

Template Downloadexcel_template.xlsx

In the example, the template file export_muti_sheet_template.xlsx is uploaded to the excel folder of the resource and component designer module with identifier "website"

Example 4: Insert pictures ​

js
const workbook = informat.excel.openNewFile("test-pic.xlsx");
const sheet = workbook.createSheet("sheet1");
//
for (var i = 0; i < 5; i++) {
  const row = sheet.createRow(i);
  row.createCellWithValue(0, "column1");
  row.createCellWithValue(1, "column2");
}
//
sheet.addPicture(0, 0, "path/to/image.png").setSize(60, 60);
sheet.addPicture(1, 0, "path/to/image.png").setSize(60, 60);
//
workbook.write();
//

Example 5: Export using multiple Excel sheet templates ​

js
// Download template file
export function exportMutiSheetTemplate() {
  // Define template file path
  const templateFilePath = "mutiSheetTemplate.xlsx";
  const outputFilePath = "result.xlsx";
  informat.website.download("website", "excel/export_muti_sheet_template.xlsx", templateFilePath);

  // Define the list of sheet numbers to export, starting from 0. If empty, export all sheets
  const sheetNums = [0, 1, 2]; // Export first, second, and third sheets

  // Define data to be passed to the template
  const data = {
    orgName: "Company Name xxx",
    goodAtProduct: "Product xxx",
    addresss: "Company Address xxxxxxx",
    reviewUser: "Zhang San",
    reviewTime: new Date(),
    list: [
      { sort: 1, question: "project1", standard: "A", score: 95, realScore: 98, realTotalScore: 99 },
      { sort: 2, question: "project2", standard: "B", score: 78, realScore: 79, realTotalScore: 80 },
      { sort: 3, question: "project3", standard: "C", score: 65, realScore: 62, realTotalScore: 66 },
    ],
  };

  // Create a new Excel file using the template file and export the specified sheets
  const workbook = informat.excel.openWithTemplateWithSheets(outputFilePath, templateFilePath, sheetNums, data);

  // Write the file
  workbook.write();
  return outputFilePath;
}

TIP

Template Downloadexport_muti_sheet_template.xlsx In the example, the template file export_muti_sheet_template.xlsx is uploaded to the excel folder of the resource and component designer module with identifier "website"