我跟着
basic usage tutorial for excel4node
包裹。
对于运行代码,我有一个https函数,它将创建一个
Excel.xlsx
文件在同一目录中
index.js
在我的本地系统上。
但是,问题是每次调用函数时,都是一个零字节
Excel.xls
文件已创建。
函数体如下:
const createXlxsFile = (req, res) => {
const xl = require('excel4node');
// Create a new instance of a Workbook class
const workbook = new xl.Workbook();
// Add Worksheets to the workbook
const worksheet = workbook.addWorksheet('Sheet 1');
const worksheet2 = workbook.addWorksheet('Sheet 2');
// Create a reusable style
const style = workbook.createStyle({
font: {
color: '#FF0800',
size: 12
},
numberFormat: '$#,##0.00; ($#,##0.00); -'
});
// Set value of cell A1 to 100 as a number type styled with paramaters of style
worksheet.cell(1, 1).number(100).style(style);
// Set value of cell B1 to 300 as a number type styled with paramaters of style
worksheet.cell(1, 2).number(200).style(style);
// Set value of cell C1 to a formula styled with paramaters of style
worksheet.cell(1, 3).formula('A1 + B1').style(style);
// Set value of cell A2 to 'string' styled with paramaters of style
worksheet.cell(2, 1).string('string').style(style);
// Set value of cell A3 to true as a boolean type styled with paramaters of style but with an adjustment to the font size.
worksheet.cell(3, 1).bool(true).style(style).style({ font: { size: 14 } });
workbook.write('Excel.xlsx');
res.end('DOC CREATED');
};
此代码在标准node.js中运行良好,但在FireBase云函数中不起作用。使用函数写入文件是否有限制?
即使在使用
Xlsx-populate package
.