想把数据存成excel文件,百度了说需要安装node-xlsl,但我这边一直安装失败。安装步骤如下:
1.新建一个node-js云函数excel2
2.在excel2右键点“内建终端打开”
3.在终端中运行:npm install node-xlsl,报错
PS D:\10-My Doc\06-微信小程序\00-我的小程序\05-自习室0328\cloud\excel2> npm install node-xlsl
npm WARN package.json excel2@1.0.0 No description
npm WARN package.json excel2@1.0.0 No repository field.
npm WARN package.json excel2@1.0.0 No README data
npm ERR! Windows_NT 10.0.19041
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-xlsl"
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code E404
npm ERR! 404 Not found : node-xlsl
npm ERR! 404
npm ERR! 404 'node-xlsl' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'excel2'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! D:\10-My Doc\06-微信小程序\00-我的小程序\05-自习室0328\cloud\excel2\npm-debug.log
折腾了一下午,重启了客户端,突然就安装上了,也是见了鬼了
没有问题啊,我也是用这个做的导出
excel failed: Error: cloud.callFunction:fail -404011 cloud function execution error. 云函数执行错误
1. 报错如下:云端堆栈信息(error stack)(requestId 2414f342-eba2-11eb-bdab-32a98484f02d, callid 1627036719606-0.12601751593543375):
Runtime.ImportModuleError: Error: Cannot find module 'node-xlsx'
2.node-xlsx的安装路径在云函数excel2\node-modules\node-xlsx
3.云函数excel2\index.js代码如下:
// 云函数入口文件
const cloud = require(”wx-server-sdk“)
cloud.init()
//操作excel用的类库
const xlsx = require(”node-xlsx&“)
// 云函数入口函数
exports.main = async (event, context) => {
try {
。。。
4.改成xlsx= require(”node/mudules/node-xlsx&“),也是同样报错
const xlsx = require('node-xlsx');
// 把数据保存到excel里
let buffer = await xlsx.build([{
name: title + timeUtil.timestamp2Time(this._timestamp, 'Y-M-D'),
data,
options
}]);