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
informat.excel.openExistFile(file);| Parameter | Type | Description |
|---|---|---|
| file | String | File path in the app's sandbox environment |
Return Value
Returns a Workbook object
Example
informat.excel.openExistFile("gzb.xlsx");openNewFile
Create a new Excel file
informat.excel.openNewFile(file);TIP
If the file exists, its content will be overwritten when saved
| Parameter | Type | Description |
|---|---|---|
| file | String | File path in the app's sandbox environment |
Return Value
Returns a Workbook object
Example
informat.excel.openNewFile("gzb2.xlsx");openWithTemplate
Create a Workbook based on a template.
informat.excel.openWithTemplate(file, templateFile, data);| Parameter | Type | Description |
|---|---|---|
| file | String | The generated Excel file |
| templateFile | String | The path to the template file |
| data | Object | Variables passed to the template file |
Return Value
Returns a Workbook object
openWithTemplateWithSheets
Create a Workbook based on a multi-sheet template.
informat.excel.openWithTemplateWithSheets(file, templateFile, sheetNums, data);TIP
If sheetNums is empty, all worksheets will be exported.
| Parameter | Type | Description |
|---|---|---|
| file | String | The generated Excel file |
| templateFile | String | The path to the template file |
| sheetNums | Array<Integer> | Worksheet number list, starting from 0; to export only the 2nd and 3rd worksheets, enter [1,2] |
| data | Object | Variables passed to the template file |
Return Value
Returns a Workbook object
createTemplatePicture
Create a template picture object
informat.excel.createTemplatePicture(pic);| Parameter | Type | Description |
|---|---|---|
| image | ExcelTamplatePicture | Picture configuration |
Return Value
Returns the picture used in the template
Example
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
});informat.excel.createTemplatePicture({
type: "barcode", // Barcode
content: "1234557", // Content
width: 100, // Width
height: 100, // Height
});informat.excel.createTemplatePicture({
type: "qrcode", // QR code
content: "https://informat.cn", // Content
width: 100, // Width
height: 100, // Height
});createTemplateCell
Create a template cell
informat.excel.createTemplateCell(cell);| Parameter | Type | Description |
|---|---|---|
| cell | ExcelTamplateCell | Cell configuration |
Return Value
Returns the cell used in the template
Example
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
workbook.createSheet(sheetName);TIP
sheetName cannot contain 0x0000 0x0003 : \ * ? / [``]
| Parameter | Type | Description |
|---|---|---|
| sheetName | String | Sheet name |
Return Value
Returns a Sheet object
Example
workbook.createSheet("sheet1");createSafeSheetName
Create a valid sheet name
workbook.createSafeSheetName(sheetName);TIP
Some special characters are not allowed in sheet names. This method automatically filters out these disallowed special characters.
| Parameter | Type | Description |
|---|---|---|
| sheetName | String | Sheet name |
Return Value
Returns a String, the sheet name with special characters filtered out
Example
workbook.createSafeSheetName("sheet1");getSheet
Get a Sheet by name
workbook.getSheet(sheetName);| Parameter | Type | Description |
|---|---|---|
| sheetName | String | Sheet name |
Return Value
Returns a Sheet object, or null if sheetName does not exist
Example
workbook.getSheet("sheet1");getSheetAt
Get a Sheet by position index
workbook.getSheetAt(sheetIdx);| Parameter | Type | Description |
|---|---|---|
| sheetIdx | Integer | Sheet index, starting from 0 |
Return Value
Returns a Sheet object, or null if the sheet does not exist
Example
workbook.getSheetAt(0);getNumberOfSheets
Get the number of sheets
workbook.getNumberOfSheets();Return Value Returns an Integer object, the number of sheets
write
Write content to file
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
workbook.createFont();Return Value
Returns a Font object that describes the font
createCellStyle
Create a cell style configuration
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
sheet.getSheetName();Return Value
Returns a String object, the sheet name
createRow
Create a row
sheet.createRow(row);| Parameter | Type | Description |
|---|---|---|
| row | Integer | Row index, starting from 0 |
Return Value
Returns a Row object
Example
sheet.createRow(0);getRow
Get a row
sheet.getRow(row);| Parameter | Type | Description |
|---|---|---|
| row | Integer | Row index, starting from 0 |
Return Value
Returns a Row object
Example
sheet.getRow(0);removeRow
Delete a row
sheet.removeRow(row);| Parameter | Type | Description |
|---|---|---|
| row | Integer | Row index, starting from 0 |
Example
sheet.removeRow(0);getFirstRowNum
Get the index of the first row in the sheet
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
sheet.getLastRowNum();Return Value
Returns an Integer object, the index of the last row
getDefaultRowHeightInPoints
Get the default row height
sheet.getDefaultRowHeightInPoints();Return Value Returns a Double object, the default row height
setDefaultRowHeightInPoints
Set the default row height
sheet.setDefaultRowHeightInPoints(height);| Parameter | Type | Description |
|---|---|---|
| height | Double | Default row height in pixels |
getDefaultColumnWidth
Get the default column width
sheet.getDefaultColumnWidth();Return Value
Returns an Integer object, the default column width
setDefaultColumnWidth
Set the default column width
sheet.setDefaultColumnWidth(width);| Parameter | Type | Description |
|---|---|---|
| width | Integer | Default column width |
setColumnWidth
Set the column width
sheet.setColumnWidth(colIdx, width);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column index |
| width | Integer | Column width |
autoSizeColumn
Automatically set column width based on content
sheet.autoSizeColumn(colIdx);TIP
Auto column width function only takes effect after data insertion is completed
| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column index |
setDefaultColumnStyle
Set the default cell style for a column
sheet.setDefaultColumnStyle(colIdx, cellStyle);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column index, starting from 0 |
| cellStyle | CellStyle | Cell style |
getColumnStyle
Get the default cell style for a column
sheet.getColumnStyle(colIdx);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column index, starting from 0 |
Return Value
Returns a CellStyle object, the default cell style
addMergedRegion
Merge cells
sheet.addMergedRegion(firstRow, lastRow, firstColumn, lastColumn);| Parameter | Type | Description |
|---|---|---|
| firstRow | Integer | First row, starting from 0 |
| lastRow | Integer | Last row, starting from 0 |
| firstColumn | Integer | First column, starting from 0 |
| lastColumn | Integer | Last column, starting from 0 |
addPicture
Insert a picture from the local sandbox into a cell
sheet.addPicture(col, row, filePath);| Parameter | Type | Description |
|---|---|---|
| col | Integer | Column to insert, starting from 0 |
| row | Integer | Row to insert, starting from 0 |
| filePath | String | Path 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
sheet.addPictureStorage(col, row, filePath);| Parameter | Type | Description |
|---|---|---|
| col | Integer | Column to insert, starting from 0 |
| row | Integer | Row to insert, starting from 0 |
| filePath | String | Path of the picture to insert, in shared storage |
Return Value Returns a Picture object
addPictureBarcode
Insert a barcode picture into a cell
sheet.addPictureBarcode(col, row, setting);| Parameter | Type | Description |
|---|---|---|
| col | Integer | Column to insert, starting from 0 |
| row | Integer | Row to insert, starting from 0 |
| setting | PictureSetting | Picture configuration |
Return Value
Returns a Picture object
addPictureQrcode
Insert a QR code picture into a cell
sheet.addPictureQrcode(col, row, setting);| Parameter | Type | Description |
|---|---|---|
| col | Integer | Column to insert, starting from 0 |
| row | Integer | Row to insert, starting from 0 |
| setting | PictureSetting | Picture configuration |
Return Value
Returns a Picture object
getPictures
Get all pictures in the sheet
sheet.getPictures();Return Value
Returns an Array<Picture> object
getObjectDatas
Get all attachments in the sheet
sheet.getObjectDatas();Return Value Returns an Array<ExcelObjectData> object
Row
createCell
Create a cell
row.createCell(colIdx);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column to insert, starting from 0 |
Return Value Returns a Cell object
createCellWithValue
Create a cell with a value
row.createCellWithValue(colIdx, value);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column to insert, starting from 0 |
| value | Object | Value 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
row.getCell(colIdx);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column to get, starting from 0 |
Return Value
Returns a Cell object, or null if the cell does not exist
removeCell
Remove a cell
row.removeCell(colIdx);| Parameter | Type | Description |
|---|---|---|
| colIdx | Integer | Column to remove, starting from 0 |
getFirstCellNum
Get the index of the first column
row.getFirstCellNum();Return Value
Returns an Integer, the index of the first column
getLastCellNum
Get the index of the last column
row.getLastCellNum();Return Value
Returns an Integer, the index of the last column
getRowNum
Get the row index
row.getRowNum();Return Value
Returns an Integer, the row index
getHeightInPoints
Get row height
row.getHeightInPoints();Return Value
Returns a Double, the row height
setHeightInPoints
Set row height
row.setHeightInPoints(height);| Parameter | Type | Description |
|---|---|---|
| height | Double | Row height in pixels |
setStyle
Set the cell style for the row
row.setStyle(cellStyle);| Parameter | Type | Description |
|---|---|---|
| cellStyle | CellStyle | Cell style |
getStyle
Get the cell style for the row
row.getStyle();Return Value
Returns a CellStyle
Cell
setValue
Set cell value
cell.setValue(value);TIP
Cells support String, Boolean, Double, and Date types. Values of other types will be converted to strings for storage.
| Parameter | Type | Description |
|---|---|---|
| value | Object | Cell value |
getValue
Get cell value
cell.getValue();getValueEvaluated
Get cell value after formula calculation
cell.getValueEvaluated();setStyle
Set cell style
cell.setStyle(cs);| Parameter | Type | Description |
|---|---|---|
| cellStyle | CellStyle | Cell style |
getStyle
Get cell style
cell.getStyle();Return Value
Returns a CellStyle
setHyperlink
Set cell hyperlink
cell.setHyperlink(link);| Parameter | Type | Description |
|---|---|---|
| link | String | Link URL |
getHyperlink
Get cell hyperlink
cell.getHyperlink();Return Value
Returns a String representing the hyperlink URL, or null if no hyperlink exists
Style
setAlignment
Set horizontal alignment
cellStyle.setAlignment(align);| Parameter | Type | Description |
|---|---|---|
| align | String | Optional values: CENTER, CENTER_SELECTION, DISTRIBUTED, FILL, GENERAL, JUSTIFY, LEFT, RIGHT |
getAlignment
Get horizontal alignment
cellStyle.getAlignment();Return Value
Type: String
setVerticalAlignment
Set vertical alignment
cellStyle.setVerticalAlignment(align);| Parameter | Type | Description |
|---|---|---|
| align | String | Optional values: BOTTOM, CENTER, DISTRIBUTED, JUSTIFY, TOP |
getVerticalAlignment
Get vertical alignment
cellStyle.getVerticalAlignment();Return Value
Type: String
getDataFormatString
Get cell data format
cellStyle.getDataFormatString();Return Value
Type: String
setWrapText
Set whether cell text can wrap
cellStyle.setWrapText(wrap);| Parameter | Type | Description |
|---|---|---|
| wrap | Boolean | Whether text wraps |
getWrapText
Get whether cell text wraps
cellStyle.getWrapText();Return Value
Returns a String
setFont
Set cell text font
cellStyle.setFont(font);| Parameter | Type | Description |
|---|---|---|
| font | Font | Font object |
setFillForegroundColor
Set cell fill foreground color
cellStyle.setFillForegroundColor(color);| Parameter | Type | Description |
|---|---|---|
| color | String | Hexadecimal color code, e.g., #ff0000 for red |
setFillBackgroundColor
Set cell fill background color
cellStyle.setFillBackgroundColor(color);| Parameter | Type | Description |
|---|---|---|
| color | String | Hexadecimal color code, e.g., #ff0000 for red |
setFillPattern
Set fill pattern
cellStyle.setFillPattern(type);| Parameter | Type | Description |
|---|---|---|
| type | String | Optional 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
cellStyle.setHidden(hidden);| Parameter | Type | Description |
|---|---|---|
| hidden | Boolean | Whether to hide |
setIndention
Set indentation
cellStyle.setIndention(indent);| Parameter | Type | Description |
|---|---|---|
| indent | Integer | Indent value |
setBorderTop
Set top border style
cellStyle.setBorderTop(borderStyle);| Parameter | Type | Description |
|---|---|---|
| borderStyle | String | Border 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
cellStyle.setBorderBottom(borderStyle);| Parameter | Type | Description |
|---|---|---|
| borderStyle | String | Border style |
setBorderLeft
Set left border style
cellStyle.setBorderLeft(borderStyle);| Parameter | Type | Description |
|---|---|---|
| borderStyle | String | Border style |
setBorderRight
Set right border style
cellStyle.setBorderRight(borderStyle);| Parameter | Type | Description |
|---|---|---|
| borderStyle | String | Border style |
setLeftBorderColor
Set left border color
cellStyle.setLeftBorderColor(color);| Parameter | Type | Description |
|---|---|---|
| color | String | Color, e.g., #f0f0f0 |
setRightBorderColor
Set the right border color
cellStyle.setRightBorderColor(color);| Parameter | Type | Description |
|---|---|---|
| color | String | Color, e.g., #f0f0f0 |
setTopBorderColor
Set the top border color
cellStyle.setTopBorderColor(color);| Parameter | Type | Description |
|---|---|---|
| color | String | Color, e.g., #f0f0f0 |
setBottomBorderColor
Set the bottom border color
cellStyle.setBottomBorderColor(color);| Parameter | Type | Description |
|---|---|---|
| color | String | Color, e.g., #f0f0f0 |
setRotation
Set the text rotation angle
cellStyle.setRotation(rotation);| Parameter | Type | Description |
|---|---|---|
| rotation | Integer | Rotation angle, e.g., 90 |
setDataFormat
Set the cell format
cellStyle.setDataFormat(fmt);| Parameter | Type | Description |
|---|---|---|
| fmt | String | Cell format, e.g., #0.00 |
Font
setBold
Set whether the text is bold
font.setBold(bold);| Parameter | Type | Description |
|---|---|---|
| bold | Boolean | Whether bold |
setItalic
Set whether the text is italic
font.setItalic(italic);| Parameter | Type | Description |
|---|---|---|
| italic | Boolean | Whether italic |
setUnderline
Set whether the text has an underline
font.setUnderline(underline);| Parameter | Type | Description |
|---|---|---|
| underline | Boolean | Whether underline |
setFontHeightInPoints
Set the font size
font.setFontHeightInPoints(size);| Parameter | Type | Description |
|---|---|---|
| size | Integer | Font size |
setFontName
Set the font name
font.setFontName(name);| Parameter | Type | Description |
|---|---|---|
| name | String | Font name |
Picture
getRow
Get the row number
picture.getRow();Return Value
Returns Integer
getColumn
Get the column number
picture.getColumn();Return Value
Returns Integer
save
Save the picture content to the local sandbox
picture.save(path);| Parameter | Type | Description |
|---|---|---|
| path | String | Path to save in the local sandbox |
saveStorage
Save the picture content to shared storage
picture.saveStorage(path);| Parameter | Type | Description |
|---|---|---|
| path | String | Path to save in shared storage |
saveAttachment
Save the picture content as an attachment field
picture.saveAttachment(tableId, fieldId);| Parameter | Type | Description |
|---|---|---|
| tableId | String | Table identifier |
| fieldId | String | Attachment field identifier |
Return Value
Returns a TableAttachment object
setScale
Set the picture scale ratio
picture.setScale(wScale, hScale);| Parameter | Type | Description |
|---|---|---|
| wScale | Double | Width scale ratio |
| hScale | Double | Height scale ratio |
setSize
Set the picture width and height
picture.setSize(width, height);| Parameter | Type | Description |
|---|---|---|
| width | Integer | Picture width |
| height | Integer | Picture height |
fitWidth
Scale the picture to fit the cell width
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
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
picture.resetSize();ExcelObjectData
Excel Attachment
getRow
Get the attachment's row number
objectData.getRow();Return Value
Returns Integer
getColumn
Get the attachment's column number
objectData.getColumn();Return Value
Returns Integer
save
Save the file content to the local sandbox
objectData.save(path);| Parameter | Type | Description |
|---|---|---|
| path | String | Path to save in the local sandbox |
saveStorage
Save the file content to shared storage
objectData.saveStorage(path);| Parameter | Type | Description |
|---|---|---|
| path | String | Path to save in shared storage |
saveAttachment
Save the file content as an attachment field
objectData.saveAttachment(tableId, fieldId);| Parameter | Type | Description |
|---|---|---|
| tableId | String | Table identifier |
| fieldId | String | Attachment field identifier |
Return Value
Returns a TableAttachment object
hasDirectoryEntry
Check if there is an associated POIFS directory entry
objectData.hasDirectoryEntry();getOLE2ClassName
Get the name of the OLE2 class object
objectData.getOLE2ClassName();getFileName
Get the file name
objectData.getFileName();getContentType
Get the content type
objectData.getContentType();Examples
Example 1: Read data from all cells in Excel
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
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://informat.cn/").setHyperlink("https:/informat.cn");
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
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
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
// 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"

