Socket
Socket
Sign inDemoInstall

ejsexcel

Package Overview
Dependencies
0
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ejsexcel

Intelligent report system, nodejs node export excel, ejsExcel


Version published
Weekly downloads
301
decreased by-6.81%
Maintainers
1
Install size
247 kB
Created
Weekly downloads
 

Readme

Source

ejsExcel

nodejs excel template engine. node export excel, ejsExcel

How to use?

npm install ejsexcel

How to test?

  • 执行 test/test.bat

    test/test.bat
    
  • test/test.xlsx 为完整示例 demo

  • e.g

     const ejsexcel = require("ejsexcel");
     const fs = require("fs");
     const util = require("util");
     const readFileAsync = util.promisify(fs.readFile);
     const writeFileAsync = util.promisify(fs.writeFile);
     
    (async function() {
      //获得Excel模板的buffer对象
      const exlBuf = await readFileAsync("./test.xlsx");
      //数据源
      const data = [];
      //用数据源(对象)data渲染Excel模板
      //cachePath 为编译缓存路径, 对于模板文件比较大的情况, 可显著提高运行效率, 绝对路径, 若不设置, 则无缓存
      const exlBuf2 = await ejsexcel.renderExcel(exlBuf, data, { cachePath: __dirname+"/cache/" });
      await writeFileAsync("./test2.xlsx", exlBuf2);
      console.log("生成test2.xlsx");
    })();
    

Syntax

SyntaxDescription
_data__data_ 为内置对象, 数据源
<%forRow循环一行
<%#输出动态公式
<%~输出数字类型格式
<%=输出字符串
<%forCell循环单元格
<%forRBegin循环多行
<%forCBegin循环多个单元格
<%_mergeCellFn_("C2:E2")%>合并单元格C2:E2
<%_dataValidation_({ sqref: "A1:A3", formula1: "序列1,序列2" })%>数据验证
<%_hideSheet_()%>隐藏所在工作表
<%_showSheet_()%>显示所在工作表
<%_deleteSheet_()%>删除所在工作表
<% %>内部可执行 任意 javascript,可以用 <%console.log(_data_)%> 打印临时变量到控制台,进行调试

Author

  • Author: Sail
    • QQ: 151263555
    • QQ群: 470988427
    • email: 151263555@qq.com

Templates

做一个这样的模版 模板

Result

加数据渲染之后,导出结果

导出结果

捐赠鼓励支持此项目,支付宝扫描:

捐赠鼓励支持此项目

项目贡献人列表

  • @Hello World ¥50
  • @德爾文 ¥50
  • @Explore® ¥50
  • @向左转 ¥50
  • @吴燕飞 ¥50
  • @strive-ming ¥10
  • @MR.P ¥16.66
  • @不求来生 ¥6.60
  • @羊刀 ¥6.66
  • @Leo ¥8.88
  • @不摇碧莲 ¥6.66
  • @天涯海角 ¥10
  • @刚刚好 ¥5
  • @Aptenodytes forsteri ¥15
  • @HHB ¥30
  • @Original ¥88.88
  • @半日 ¥10
  • @狗狗踏青去了 ¥50
  • @zzzzzzzz ¥50
  • @zzzzzzzz ¥30
  • @九尾之狐 ¥66.66
  • @小小青尘 ¥50
  • @亲眼 ¥6.66

Keywords

FAQs

Last updated on 30 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc