Gathering detailed insights and metrics for xlsx-style-node
Gathering detailed insights and metrics for xlsx-style-node
Gathering detailed insights and metrics for xlsx-style-node
Gathering detailed insights and metrics for xlsx-style-node
js-xlsx-style-node
This is a package that processes xlsx through JS, while supporting processing styles(一个支持设置样式的 xlsx 插件)
node-xlsx-style
NodeJS Excel files parser & builder
@michaelray/style-xlsx
改进node生成excel,增加样式功能,修复行高问题。
style-node-xlsx
NodeJS Excel files parser & builder
npm install xlsx-style-node
Typescript
Module System
Node Version
NPM Version
39.4
Supply Chain
90.2
Quality
73.8
Maintenance
50
Vulnerability
99.3
License
Total Downloads
4,830
Last Day
1
Last Week
2
Last Month
97
Last Year
1,229
4 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
xlsx-style-node@1.0.1
Unpacked Size
23.58 kB
Size
7.23 kB
File Count
9
NPM Version
6.14.11
Node Version
14.16.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
-61.4%
97
Compared to previous month
Last year
107.6%
1,229
Compared to previous year
4
此 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';
1const fs = require("fs"); 2const data: any = [ 3 ["导表时间:2021-05-27 15:36:28"], 4 ["用户Id: 288884"], 5 ["用户名:test"], 6 [], 7 ["对账公式:"], 8 ["期末余额=期初余额+入金-出金"], 9 [], 10 ["币种:USD"], 11 [ 12 "*期初余额指本月度1号0点0分0秒余额", 13 null, 14 null, 15 "*期末余额指本月度最后一天23点59分59秒余额", 16 ], 17 [ 18 "期初余额(总计)", 19 "10000.01", 20 null, 21 "期末余额(总计)", 22 "20000.01", 23 null, 24 "入金(总计)", 25 "20000", 26 null, 27 "出金(总计)", 28 "10000", 29 ], 30 [ 31 "账户余额", 32 "8000", 33 null, 34 "账户余额", 35 "18000", 36 null, 37 "账户充值", 38 "19000", 39 null, 40 "账户转出", 41 "9000", 42 ], 43 [ 44 "储值卡总可用余额", 45 "99", 46 null, 47 "储值卡总可用余额", 48 "3232", 49 null, 50 "账户转入", 51 "999", 52 null, 53 "账户充值手续费", 54 "000", 55 ], 56 [ 57 "额度卡(预算)总可用余额", 58 "99", 59 null, 60 "额度卡(预算)总可用余额", 61 "33", 62 null, 63 "储值卡转入", 64 "44", 65 null, 66 "储值卡转出", 67 "500", 68 ], 69 [ 70 null, 71 null, 72 null, 73 null, 74 null, 75 null, 76 "储值卡退款", 77 "22", 78 null, 79 "储值卡消费(已完成)", 80 "111", 81 ], 82 [ 83 null, 84 null, 85 null, 86 null, 87 null, 88 null, 89 "额度卡转入", 90 "22", 91 null, 92 "储值卡消费(处理中)", 93 "111", 94 ], 95 [ 96 null, 97 null, 98 null, 99 null, 100 null, 101 null, 102 "额度卡退款", 103 "22", 104 null, 105 "储值卡退款手续费", 106 "111", 107 ], 108 [null, null, null, null, null, null, null, null, null, "额度卡转出", "11"], 109 [ 110 null, 111 null, 112 null, 113 null, 114 null, 115 null, 116 null, 117 null, 118 null, 119 "额度卡消费(已完成)", 120 "11", 121 ], 122 [ 123 null, 124 null, 125 null, 126 null, 127 null, 128 null, 129 null, 130 null, 131 null, 132 "额度卡消费(处理中)", 133 "11", 134 ], 135 [ 136 null, 137 null, 138 null, 139 null, 140 null, 141 null, 142 null, 143 null, 144 null, 145 "额度卡退款手续费", 146 "11", 147 ], 148 [null, null, null, null, null, null, null, null, null, "开卡费", "11"], 149]; 150 151// 设置样式 152for (const index in data) { 153 if (Number(index) < 5) continue; 154 if (index === "7") continue; // 第八行不处理 155 if (!data[index].length) continue; 156 for (const index2 in data[index]) { 157 if (!data[index][index2]) continue; 158 const content = data[index][index2]; 159 if (index === "5") { 160 data[index][index2] = { 161 v: content, 162 s: { 163 font: { 164 size: 24, 165 bold: true, // 加粗 166 }, 167 }, 168 }; 169 } else { 170 data[index][index2] = { 171 v: content, 172 s: { 173 alignment: { 174 vertical: "center", 175 horizontal: "center", 176 }, 177 font: { 178 size: 24, 179 ...(index === "8" && { color: { rgb: "ff280c" } }), // 设置颜色 180 ...(index === "9" && { bold: true }), // 字体加粗 181 }, 182 }, 183 }; 184 } 185 } 186} 187 188// 单元格宽度 189const options = { 190 "!cols": [ 191 { wpx: 260 }, 192 { wpx: 80 }, 193 { wpx: 30 }, 194 { wpx: 300 }, 195 { wpx: 80 }, 196 { wpx: 30 }, 197 { wpx: 160 }, 198 { wpx: 80 }, 199 { wpx: 30 }, 200 { wpx: 170 }, 201 { wpx: 80 }, 202 ], 203}; 204 205const buffer = xlsx.build([{ name: "mySheetName", data: data, options }]); 206fs.writeFileSync("test1.xlsx", buffer);
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
7 existing vulnerabilities detected
Details
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More