
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
xlsx-style-node
Advanced tools
此 api 是通过 node-xlsx 、xlsx-style、xlsx 三个 npm 组合使用的,来弥补 node-xlsx 不能设置颜色的问题,参数格式按照 node-xlsx 方式使用,设置样式参数按照 xlsx-style。
注意: 存在缺陷 设置不了行高(待完善)
npm i xlsx-style-node
在 js 中使用
const xlsx = require("xlsx-style-node").default;
在 ts 中使用
import * as xlsx from 'xlsx-style-node';
const fs = require("fs");
const data: any = [
["导表时间:2021-05-27 15:36:28"],
["用户Id: 288884"],
["用户名:test"],
[],
["对账公式:"],
["期末余额=期初余额+入金-出金"],
[],
["币种:USD"],
[
"*期初余额指本月度1号0点0分0秒余额",
null,
null,
"*期末余额指本月度最后一天23点59分59秒余额",
],
[
"期初余额(总计)",
"10000.01",
null,
"期末余额(总计)",
"20000.01",
null,
"入金(总计)",
"20000",
null,
"出金(总计)",
"10000",
],
[
"账户余额",
"8000",
null,
"账户余额",
"18000",
null,
"账户充值",
"19000",
null,
"账户转出",
"9000",
],
[
"储值卡总可用余额",
"99",
null,
"储值卡总可用余额",
"3232",
null,
"账户转入",
"999",
null,
"账户充值手续费",
"000",
],
[
"额度卡(预算)总可用余额",
"99",
null,
"额度卡(预算)总可用余额",
"33",
null,
"储值卡转入",
"44",
null,
"储值卡转出",
"500",
],
[
null,
null,
null,
null,
null,
null,
"储值卡退款",
"22",
null,
"储值卡消费(已完成)",
"111",
],
[
null,
null,
null,
null,
null,
null,
"额度卡转入",
"22",
null,
"储值卡消费(处理中)",
"111",
],
[
null,
null,
null,
null,
null,
null,
"额度卡退款",
"22",
null,
"储值卡退款手续费",
"111",
],
[null, null, null, null, null, null, null, null, null, "额度卡转出", "11"],
[
null,
null,
null,
null,
null,
null,
null,
null,
null,
"额度卡消费(已完成)",
"11",
],
[
null,
null,
null,
null,
null,
null,
null,
null,
null,
"额度卡消费(处理中)",
"11",
],
[
null,
null,
null,
null,
null,
null,
null,
null,
null,
"额度卡退款手续费",
"11",
],
[null, null, null, null, null, null, null, null, null, "开卡费", "11"],
];
// 设置样式
for (const index in data) {
if (Number(index) < 5) continue;
if (index === "7") continue; // 第八行不处理
if (!data[index].length) continue;
for (const index2 in data[index]) {
if (!data[index][index2]) continue;
const content = data[index][index2];
if (index === "5") {
data[index][index2] = {
v: content,
s: {
font: {
size: 24,
bold: true, // 加粗
},
},
};
} else {
data[index][index2] = {
v: content,
s: {
alignment: {
vertical: "center",
horizontal: "center",
},
font: {
size: 24,
...(index === "8" && { color: { rgb: "ff280c" } }), // 设置颜色
...(index === "9" && { bold: true }), // 字体加粗
},
},
};
}
}
}
// 单元格宽度
const options = {
"!cols": [
{ wpx: 260 },
{ wpx: 80 },
{ wpx: 30 },
{ wpx: 300 },
{ wpx: 80 },
{ wpx: 30 },
{ wpx: 160 },
{ wpx: 80 },
{ wpx: 30 },
{ wpx: 170 },
{ wpx: 80 },
],
};
const buffer = xlsx.build([{ name: "mySheetName", data: data, options }]);
fs.writeFileSync("test1.xlsx", buffer);
FAQs
node 生成xlsx 并且生成样式
The npm package xlsx-style-node receives a total of 4 weekly downloads. As such, xlsx-style-node popularity was classified as not popular.
We found that xlsx-style-node 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.