Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
nodejs excel template engine. node export excel, ejsExcel
npm install ejsexcel
执行 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 | Description |
---|---|
data | data 为内置对象, 数据源 |
<%forRow | 循环一行 |
<%# | 输出动态公式 |
<%~ | 输出数字类型格式 |
<%= | 输出字符串 |
<%forCell | 循环单元格 |
<%forRBegin | 循环多行 |
<%forCBegin | 循环多个单元格 |
<%hideSheet()%> | 隐藏所在工作表 |
<%showSheet()%> | 显示所在工作表 |
<%deleteSheet()%> | 删除所在工作表 |
<% %> | 内部可执行 任意 javascript,可以用 <%console.log(data)%> 打印临时变量到控制台,进行调试 |
做一个这样的模版
加数据渲染之后,导出结果
FAQs
Intelligent report system, nodejs node export excel, ejsExcel
We found that ejsexcel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.