EXCEL Writer
Create an XLSX format file. Copy the data from the specified Excel file, use the provided Low-Code API to add or modify data or styles, and generate a new Excel file named 'output.xlsx'
Last updated
Create an XLSX format file. Copy the data from the specified Excel file, use the provided Low-Code API to add or modify data or styles, and generate a new Excel file named 'output.xlsx'
Last updated
// List all the sheets in the Excel file
console.log(api.sheetNames())
// Add a new sheet
let rows = [{col1: 1, col2: '2'},{col1: 3, col2: '4'}]
api.addSheet(['col2','col1'], rows, 'new sheet')
// Merge Cells from B2 to C3
api.mergeCells('new sheet', 1, 1, 1, 2)
// Get the value of a specific cell (e.g., A1)
console.log(api.getCell('new sheet', 0, 0))
// Write a value to a specific cell (e.g., B2)
api.setCell('new sheet', 1, 1, 'hello')
// Set the height of the first row (row 0) to 50
api.setRowHeight('new sheet', 0, 50)
// Set the width of column C to 0 (hide the column)
api.setColWidth('new sheet', 2, 0)
// Delete sheet
api.delSheet('new sheet')// Style Object
const style = {
alignment: {
vertical: 'bottom', // 'top', 'center'
horizontal: 'left', // 'center', 'right'
wrapText: false, // true
},
font: {
name: 'Calibri', // font family name
sz: 12, // font size
color: { rgb: 'FF0000' },
bold: false, // true
italic: false, // true
underline: false, // true
strike: false, // true
},
fill: {
fgColor: { rgb: '00FF00' }
},
border: {
top: {
style: 'thin', // 'thick','dashed','dotted','hair','medium'
color: { rgb: '000000' }
},
bottom: {
style: 'thin',
color: { rgb: '000000' }
},
left: {
style: 'thin',
color: { rgb: '000000' }
},
right: {
style: 'thin',
color: { rgb: '000000' }
}
}
}
// Set the style of cell A1
api.setCell('sheet name', 0, 0, 'style demo', style)