sail-sail / ejsexcel Goto Github PK
View Code? Open in Web Editor NEWnodejs excel template engine. node export excel
Home Page: https://ejsexcel.com
License: Other
nodejs excel template engine. node export excel
Home Page: https://ejsexcel.com
License: Other
升级最新版后,发现无法进行 列数 运算了,结果总是为nan。
<%=_row - 1%>
--
<%=_col - 1%>
11
--
NaN
另外,灰常感谢作者的大作,用起来很爽。
作者您好
我在使用中 参考了你的例子
https://github.com/sail-sail/ejsExcel/blob/master/test/testExcel.js
但是const ejsexcel = require("../ejsExcel");可能会误导人
实际我们使用是const ejsexcel = require("ejsexcel");
由于没有注意 于事在windows环境中依然可以使用
但是在linux中 会找不到lib 花了半小时找问题
这个库蛮强大的,不过我想在excel中插入图片,不知是否可以?
in Chinese : 当前有没有类似的内建功能,可以对输出的某一列的每个单元格定制样式,例如,将字体标红?
定义中返回Buffer
export declare function renderExcel(exlBuf: Buffer, data: any): Buffer;
而实际返回的是Promise 对象。
导致会报以下错误:
(node:338628) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token ;
at Object. (excel_test\node_modules\ejsexcel\ejsExcel.js:1133:26)
at Generator.next ()
at step (excel_test\node_modules\ejsexcel\ejsExcel.js:1:129)
at excel_test\node_modules\ejsexcel\ejsExcel.js:1:306
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:338628) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:338628) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
js-xlsx提供一些api可以在浏览器中使用,所以技术上是否可行?感觉只有解压的部分用浏览器api替换掉nodejs的api就可以了,后续解析模板的代码是否用到了nodejs呢?
//'F:\\node-project\\infostation\\dist\\config\\export\\separation.xlsx'
fs.readFile("./separation.xlsx", function (err, exlBuf) {
if(err){
console.log('read excel template error:',err);
} else {
console.log(exlBuf);
ejsExcel.renderExcel(exlBuf, data).then(function(exlBuf2) {
fs.writeFileSync("./separation2.xlsx", exlBuf2);
console.log("生成separation.xlsx");
}).catch(function(err) {
console.error(err);
});
}
});
用第一个路径,报错
[2017-10-17 15:45:13.903] [ERROR] mongodb - renderExcel error: { ReferenceError: _data is not defined
at Object.anonymous (eval at <anonymous> (F:\node-project\infostation\dist\resources\node_modules\ejsExcel\ejsExcel.js:1133:26), <anonymous>:24:9874)
at next (native)
at onFulfilled (F:\node-project\infostation\dist\resources\node_modules\ejsExcel\lib\co\index.js:71:17)
at co (F:\node-project\infostation\dist\resources\node_modules\ejsExcel\lib\co\index.js:56:10)
at Object.<anonymous> (F:\node-project\infostation\dist\resources\node_modules\ejsExcel\ejsExcel.js:74:14)
at Object.<anonymous> (F:\node-project\infostation\dist\resources\node_modules\ejsExcel\ejsExcel.js:1134:35)
at next (native)
at step (F:\node-project\infostation\dist\resources\node_modules\ejsExcel\ejsExcel.js:1:270)
at F:\node-project\infostation\dist\resources\node_modules\ejsExcel\ejsExcel.js:1:447
at process._tickDomainCallback (internal/process/next_tick.js:129:7) is_out: true }
node 版本 v0.10.1 加载ejsExcel时报这个错误(Floating point exception) node 直接挂掉
我在内容里加了 \r\n, 生成的excel打开时显示没有换行, 双击单元格后才会换
第一次使用,出现如下报错
包已经是最新版本,使用的脚本和excel也都是官方提供的test文件。
{ ValidationError: "startElement" is not allowed. "endElement" is not allowed. "sanitizeFn" is not allowed at Object.exports.process (/Users/xiaoyun/gitlab/e2e-demo/node_modules/joi/lib/errors.js:154:19) at _validateWithOptions (/Users/xiaoyun/gitlab/e2e-demo/node_modules/joi/lib/any.js:601:31) at root.validate (/Users/xiaoyun/gitlab/e2e-demo/node_modules/joi/lib/index.js:105:23) at Object.module.exports [as toJson] (/Users/xiaoyun/gitlab/e2e-demo/node_modules/xml2json/lib/xml2json.js:152:26) at /Users/xiaoyun/gitlab/e2e-demo/node_modules/ejsexcel/ejsExcel.js:757:29 at next (native) at step (/Users/xiaoyun/gitlab/e2e-demo/node_modules/ejsexcel/ejsExcel.js:1:253) at /Users/xiaoyun/gitlab/e2e-demo/node_modules/ejsexcel/ejsExcel.js:1:430 at process._tickCallback (internal/process/next_tick.js:103:7)
npm info prepublish [email protected]
[email protected] node_modules\ejsexcel
npm info ok
mrlong@mrlong-win10 MINGW64 /c/code/ppms/src
$ node ppmsapp.js
C:\code\ppms\src\node_modules\ejsexcel\ejsExcel.js:190
sheetSufStr = Buffer.from("\n<%\nvar data = _args.data;\nvar charPlus = _args.charPlus;\n
var charToNum = _args.charToNum;\nvar str2Xml = _args.str2Xml;\nvar hid
eSheet = _args.hideSheet;\nvar showSheet = _args.showSheet;\nvar deleteS
heet = _args.deleteSheet;\nvar ps = _args.ps;\nvar pi = _args.pi;\nva
r pf = _args.pf;\nvar acVar = _args.acVar;\nvar _r = 0;\nvar _c = 0;\nva
r _row = 0;\nvar _col = "";\nvar _rc = "";\nvar img = _args.img;\nvar q
rcode = _args.qrcode;\nvar mergeCellArr = [];\nvar mergeCellFn = function
(mclStr) {\n mergeCellArr.push(mclStr);\n};\nvar hyperlinkArr = [];\nvar
outlineLevel = _args.outlineLevel;\n%>");
^
TypeError: this is not a typed array.
at Function.from (native)
at Object. (C:\code\ppms\src\node_modules\ejsexcel\ejsExcel.js:19
0:24)
at Object. (C:\code\ppms\src\node_modules\ejsexcel\ejsExcel.js:15
23:4)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (C:\code\ppms\src\controllers\budget\project\project-i
ndex.js:12:16)
How to set dynamic range for Chart ? like =SUM('H2;H'+(_row-1))
你好!刚开始使用这个ejs导出的时候,效果还是不错的,但是最后还是遇到一个不大不小的问题,就是在循环读取已经打印出来的数据,只读取了模板上的写好的行数据。也就是说如果我有一千多行的数据需要循环导出,模板上就写了三行ejs代码。然后我再次读这张数据的时候,只读取了三行。根据情况,我查找到了问题,在excel表中就已经体现,虽然可以在excel表中可以正常查看数据,但是在你打开该excel表的xml格式文档下,可以发现excel的ref下只有三行数据。也就导致ejsexcel再次读写的时候只有三行数据。在文档中并没有发现你们对row的参数下有相应的处理,所以也是提了个小建议。当然ejsexcel再打印各种复杂的报表是相当便捷好用的,所以也希望ejsexcel能够越来越完善与强大
这个能动态渲染图片吗
template
template.xlsx
data
const data = [{ name: '刘桂娟', mustIssue: 6000, realIssue: 4000, date: 'test', project: 'test', team: 'test', total: 'test', personType: 'test', bankAcc: 'test', bankName: 'test' }]
Some content in Excel has a problem, let us try to recover, if you trust the source of this workbook, click Yes.
有没有办法用一个表达式实现对sheet(工作表)的动态生成?
另外,sheet的名字怎么自定义?
请问ejsExcel需要的node版本是多少啊?
大哥,什么时候ejsExcel能支持xls文件呀?
希望null字段渲染Excel时为空白字段“”,而不是“NULL”。
https://github.com/sail-sail/ejsExcel/blob/master/ejsExcel.js#L228
str = "NULL"; → str = "";
能生成折线图么
请问,如何基于数据动态生成工作表
您好!请问setImmediate is not defined是什么错误?
如何根据一列中的数值等于某个值来设置整行的背景色?
是否有if语句来确定当前行要不要生成的方法?
我有这样一个需要:设置Sheet1中单元格A1 为<%=data.value1%>, 渲染出来的结果为1, 另一个Sheet2中的单元格A2为=Sheet1!A1, 实际上它是一个链接指向了Sheet1中单元格A1,结果也为1,但结果渲染出来的就是数字1,而不是=Sheet1!A1这个链接推算出来的1,我希望这个结果是由=Sheet1!A1这个链接推算出来,有什么办法吗?
楼主大神你好,
我的需求是:在javascript中current= new Date(), 在excel的单元格里的值是10/07/2019, 但显示成07-Oct 2019. 这种情况怎么做呢?
尝试一:
在javascript 里,时间是:current= new Date(), 写入Excel中时,使用<%~ data.current%>,然后将EXCEL的格式调成 07-Oct 2019,但结果显示 "Mon Oct 07 2019 16:16:41 GMT+0800 (China Standard Time)"
尝试二:
在javascript里,字符串是:current= ‘10/07/2019’, 写入Excel中时,使用<%~ data.current%>,然后将EXCEL的格式调成 07-Oct 2019, 但结果显示是字符串10/07/2019
两种尝试都不符合要求,求大神帮忙
/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /www/pf/Application/class/node_modules/ejsexcel/lib/node-expat/lib/node_expat.node_v50_linux_x64
centos下面报错
是否可以考虑能够在_data_中设置图片的buffer
就是像这样的用法
<%_img_({imgBuffer:_data_.imgBuffer,cellNumAdd:2,rowNumAdd:2})%>
如题,求教~~
_<不知道excel里到底能支持啥格式的语法,不熟啊~~~~~
例如:
<% forRow item,i in data.orderArr %> <% forRow goods,j in item.arr %><%= goods.name %>
会报错。正确的怎么写?
非常实用的库,希望以后能越做越好。
比如文档什么的。
另外,不做英文版不利于传播哦~
I want to be able to evaluate a property (or an if) and delete a column, in the same way that we can delete a sheet (<%_deleteSheet_()%>
). Is that possible?
@sail-sail 项目中实际需求是列名是根据数据动态生成的,目前是否支持,如果有,是否有demo?
感谢支持
Help~~~
Debug: internal, implementation, error
TypeError: Cannot read property 'cfile' of undefined
at Proxy. (/Users/..../node_modules/ejsexcel/ejsExcel.js:680:57)
at Generator.next ()
at step (/Users/..../node_modules/ejsexcel/ejsExcel.js:1:191)
请教下一个单元格放入多张图片怎么操作,
另外图片有宽高属性参数么,目前好像是充满整个单元格的
某一列想做成下拉列表怎么处理
template里边支持的格式都有哪些啊? 参照test里边那些模版在renderExcel的时候一直报错(如下),过不去啊
error: SyntaxError: Invalid or unexpected token
use case是这样的,我们想要弄一个模版是B:F循环显示一批数据, H:J循环显示另一批数据。 可以做到吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.