EXCEL Writer
建立 XLSX 格式檔案。複製指定EXCEL檔案的資料內容,以Low-Code提供的api增修資料或樣式,產生新的EXCEL檔案 output.xlsx
最后更新于
这有帮助吗?
建立 XLSX 格式檔案。複製指定EXCEL檔案的資料內容,以Low-Code提供的api增修資料或樣式,產生新的EXCEL檔案 output.xlsx
最后更新于
这有帮助吗?
这有帮助吗?
// 列出EXCEL檔的所有sheet
console.log(api.sheetNames())
// 加入新一頁 sheet
let rows = [{col1: 1, col2: '2'},{col1: 3, col2: '4'}]
api.addSheet(['col2','col1'], rows, 'new sheet')
// 合併儲存格:B2:C3
api.mergeCells('new sheet', 1, 1, 1, 2)
// 取得A1儲存格的值
console.log(api.getCell('new sheet', 0, 0))
// 寫入B2儲存格的值
api.setCell('new sheet', 1, 1, 'hello')
// 設定第1列(row為0)高度50
api.setRowHeight('new sheet', 0, 50)
// 設定C欄寬度為0(隱藏)
api.setColWidth('new sheet', 2, 0)
// 刪除 sheet
api.delSheet('new sheet')// 樣式物件
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' }
}
}
}
// 設定儲存格A1樣式
api.setCell('sheet name', 0, 0, 'style demo', style)