现在最大的问题是,调用xlsx文件要在云端,写入云端的参数过大就会报错
所以 需要一个分批写入xlsx的方法
后续开发中要导出图片到xlsx,所以求一个能解决这个两个问题的npm包
// 云函数入口文件
const cloud = require('wx-server-sdk')
const xlsx = require('node-xlsx');
cloud.init()
const db = cloud.database()
const _ = db.command
const $ = db.command.aggregate
// 云函数入口函数
var stepsArr=["未录","录入","已到","安装问题","安装待审","安装成功","连接问题","连接待审","连接成功","冲洗问题","冲洗待审","冲洗成功","调试问题","调试待审","调试成功"]
exports.main = async (event, context) => {
const rl = await cloud.downloadFile({
fileID:event.fileID
})
var res = wx.base64ToArrayBuffer(rl.fileContent)
console.log(res)
let alldata = []
let row = ['合同编号','身份证','姓名','手机号','城镇','状态','机器型号']
alldata.push(row);
for (let key in res) {
let arr = [];
arr.push(res[key].no);
arr.push(res[key].id);
arr.push(res[key].name);
arr.push(res[key].phone);
arr.push(res[key].countrys);
arr.push(stepsArr[res[key].steps]);
arr.push(res[key].mtype);
alldata.push(arr)
}
let dataCVS = event.ntime+".xlsx"
var buf = await xlsx.build([{name:"mysheet",data:alldata}])
return await cloud.uploadFile({
cloudPath:"xlsx/list/"+dataCVS,
fileContent:buf
})
}
我现在使用的是node-xlsx,但是它的API很不详细,我既不知道如何分批写入数据,也不知道他能不能写入img图片,求大佬解答