# xlsx-js-style
## �對� About
SheetJS with Style! Create Excel spreadsheets with basic styling options using JavaScript.
<p align="center">
<a href="https://github.com/gitbrent/xlsx-js-style/">
<img alt="xlsx-js-style sheetjs styles" title="xlsx-js-style sheetjs styles" src="https://github.com/gitbrent/xlsx-js-style/blob/7664a045cd8f96b6b1b92ad563babebb8d6e0b4a/demos/browser/images/readme_banner.png"/>
</a>
</p>
<br/>
[![Known Vulnerabilities](https://snyk.io/test/npm/xlsx-js-style/badge.svg)](https://snyk.io/test/npm/xlsx-js-style) [![npm downloads](https://img.shields.io/npm/dm/xlsx-js-style.svg)](https://www.npmjs.com/package/xlsx-js-style)
[![typescripts definitions](https://img.shields.io/npm/types/xlsx-js-style)](https://img.shields.io/npm/types/xlsx-js-style)
## ��� Installation
Install [npm](https://www.npmjs.org/package/xlsx-js-style):
```sh
npm install xlsx-js-style
```
Install browser:
```html
<script src="dist/xlsx.bundle.js"></script>
```
## ��� Core API
- Refer to the [SheetJS](https://sheetjs.com/) documentation for core API reference
- Current version of sheetjs used: **0.18.5**
## ��� Style API
### Cell Style Example
```js
// STEP 1: Create a new workbook
const wb = XLSX.utils.book_new();
// STEP 2: Create data rows and styles
let row = [
{ v: "Courier: 24", t: "s", s: { font: { name: "Courier", sz: 24 } } },
{ v: "bold & color", t: "s", s: { font: { bold: true, color: { rgb: "FF0000" } } } },
{ v: "fill: color", t: "s", s: { fill: { fgColor: { rgb: "E9E9E9" } } } },
{ v: "line\nbreak", t: "s", s: { alignment: { wrapText: true } } },
];
// STEP 3: Create worksheet with rows; Add worksheet to workbook
const ws = XLSX.utils.aoa_to_sheet([row]);
XLSX.utils.book_append_sheet(wb, ws, "readme demo");
// STEP 4: Write Excel file to browser
XLSX.writeFile(wb, "xlsx-js-style-demo.xlsx");
```
### Cell Style Properties
- Cell styles are specified by a style object that roughly parallels the OpenXML structure.
- Style properties currently supported are: `alignment`, `border`, `fill`, `font`, `numFmt`.
| Style Prop | Sub Prop | Default | Description/Values |
| :---------- | :------------- | :---------- | ------------------------------------------------------------------------------------------------- |
| `alignment` | `vertical` | `bottom` | `"top"` or `"center"` or `"bottom"` |
| | `horizontal` | `left` | `"left"` or `"center"` or `"right"` |
| | `wrapText` | `false` | `true` or `false` |
| | `textRotation` | `0` | `0` to `180`, or `255` // `180` is rotated down 180 degrees, `255` is special, aligned vertically |
| `border` | `top` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
| | `bottom` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
| | `left` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
| | `right` | | `{ style: BORDER_STYLE, color: COLOR_STYLE }` |
| | `diagonal` | | `{ style: BORDER_STYLE, color: COLOR_STYLE, diagonalUp: true/false, diagonalDown: true/false }` |
| `fill` | `patternType` | `"none"` | `"solid"` or `"none"` |
| | `fgColor` | | foreground color: see `COLOR_STYLE` |
| | `bgColor` | | background color: see `COLOR_STYLE` |
| `font` | `bold` | `false` | font bold `true` or `false` |
| | `color` | | font color `COLOR_STYLE` |
| | `italic` | `false` | font italic `true` or `false` |
| | `name` | `"Calibri"` | font name |
| | `strike` | `false` | font strikethrough `true` or `false` |
| | `sz` | `"11"` | font size (points) |
| | `underline` | `false` | font underline `true` or `false` |
| | `vertAlign` | | `"superscript"` or `"subscript"` |
| `numFmt` | | `0` | Ex: `"0"` // integer index to built in formats, see StyleBuilder.SSF property |
| | | | Ex: `"0.00%"` // string matching a built-in format, see StyleBuilder.SSF |
| | | | Ex: `"0.0%"` // string specifying a custom format |
| | | | Ex: `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters |
| | | | Ex: `"m/dd/yy"` // string a date format using Excel's format notation |
### `COLOR_STYLE` {object} Properties
Colors for `border`, `fill`, `font` are specified as an name/value object - use one of the following:
| Color Prop | Description | Example |
| :--------- | ----------------- | --------------------------------------------------------------- |
| `rgb` | hex RGB value | `{rgb: "FFCC00"}` |
| `theme` | theme color index | `{theme: 4}` // (0-n) // Theme color index 4 ("Blue, Accent 1") |
| `tint` | tint by percent | `{theme: 1, tint: 0.4}` // ("Blue, Accent 1, Lighter 40%") |
### `BORDER_STYLE` {string} Properties
Border style property is one of the following values:
- `dashDotDot`
- `dashDot`
- `dashed`
- `dotted`
- `hair`
- `mediumDashDotDot`
- `mediumDashDot`
- `mediumDashed`
- `medium`
- `slantDashDot`
- `thick`
- `thin`
**Border Notes**
Borders for merged areas are specified for each cell within the merged area. For example, to apply a box border to a merged area of 3x3 cells, border styles would need to be specified for eight different cells:
- left borders (for the three cells on the left)
- right borders (for the cells on the right)
- top borders (for the cells on the top)
- bottom borders (for the cells on the left)
## ��� Thanks
This project is a fork of [SheetJS/sheetjs](https://github.com/sheetjs/sheetjs) combined with code from
[sheetjs-style](https://www.npmjs.com/package/sheetjs-style) (by [ShanaMaid](https://github.com/ShanaMaid/))
and [sheetjs-style-v2](https://www.npmjs.com/package/sheetjs-style-v2) (by [Raul Gonzalez](https://www.npmjs.com/~armandourbina)).
All projects are under the Apache 2.0 License
- [sheetjs](https://github.com/SheetJS/sheetjs)
- [js-xlsx](https://github.com/protobi/js-xlsx)
- [sheetjs-style](https://www.npmjs.com/package/sheetjs-style)
- [sheetjs-style-v2](
没有合适的资源?快使用搜索试试~ 我知道了~
xlsx-js-style导出Demo,纯前端带样式导出表格数据
共268个文件
js:119个
md:39个
map:29个
5星 · 超过95%的资源 需积分: 0 23 下载量 32 浏览量
2023-09-01
11:20:45
上传
评论
收藏 1.69MB ZIP 举报
温馨提示
内容概括:最近做的项目涉及到了excel的导出,在这块真的花了很多的时间,起初需求是不需要样式层面的修改的,所以选择了XLSX.JS,没有过多的去考虑样式的修改。但是随着项目进行,客户又提出了需要按照格式修改样式的需求,故而只能去查找相关修改excel样式的资料,本想直接用XLSX.js,但显然不行XLSX.js的基础版本只有宽高、合并单元格等比较基础的修改,要更加复杂样式的修改得升级pro版本,怎么说,在这上面花钱并不是咱的风格,在查找众多资料后,发现能导出xlsx文件且能满足需求中的样式修改的插件只有XLSX-STYLE了(或许还有合适的工具但我不知道的吧),但是XLSX-STYLE貌似已经许久不维护了,所以在上手使用 纯前端导出,xlsx.js只能导出不能携带样式,所以我们用了xlsx-js-style插件,可以实现带样式的前端导出表格,样式可自定义,表格背景颜色、字体颜色、表格行高、表格行宽等等都可以自行设置,导出速度快,实现可以自己规定样式的表格。而且可以支持多sheet表导出。并且方法简单易懂。 使用场景:表格的导出,纯前端实现 技术:前端+xlsx-js-style
资源推荐
资源详情
资源评论
收起资源包目录
xlsx-js-style导出Demo,纯前端带样式导出表格数据 (268个子文件)
.eslintrc 518B
.fossaignore 116B
.gitattributes 407B
.gitignore 463B
.gitignore 13B
.gitignore 7B
index.html 14KB
xlsx-js-style.html 8KB
index.html 7KB
module.html 268B
standalone.html 238B
parcel.html 33B
xlsx.js 832KB
cpexcel.js 461KB
xlsx.bundle.js 415KB
xlsx.min.js 415KB
jszip.js 358KB
77_parsetab.js 60KB
75_xlml.js 48KB
18_cfb.js 48KB
64_ftab.js 45KB
10_ssf.js 40KB
62_fxls.js 36KB
40_harb.js 36KB
76_xls.js 35KB
39_xlsbiff.js 31KB
68_wsbin.js 28KB
38_xlstypes.js 23KB
80_parseods.js 22KB
67_wsxml.js 22KB
47_styxml.js 15KB
49_theme.js 15KB
23_binutils.js 14KB
78_writebiff.js 13KB
44_offcrypto.js 12KB
22_xmlutils.js 11KB
48_stybin.js 11KB
30_ctype.js 10KB
41_lotus.js 10KB
85_parsezip.js 10KB
81_writeods.js 10KB
79_html.js 10KB
90_utils.js 9KB
73_wbbin.js 9KB
28_binstructs.js 9KB
29_xlsenum.js 9KB
72_wbxml.js 8KB
42_sstxml.js 7KB
27_csfutils.js 7KB
88_write.js 6KB
shim.min.js 6KB
20_jsutils.js 5KB
71_wbcommon.js 5KB
87_read.js 5KB
xlsxStyle.js 5KB
daochu.js 5KB
66_wscommon.js 4KB
86_writezip.js 4KB
63_fbin.js 4KB
97_node.js 4KB
34_extprops.js 4KB
46_stycommon.js 4KB
95_api.js 4KB
21_ziputils.js 4KB
74_xmlbin.js 3KB
02_codepage.js 3KB
70_csheet.js 3KB
11_ssfutils.js 3KB
36_xlsprops.js 3KB
32_odmanrdf.js 3KB
19_fsutils.js 3KB
31_rels.js 3KB
WorkbookDefinedNameCollection.js 3KB
58_cmntbin.js 3KB
33_coreprops.js 3KB
50_styxls.js 3KB
S.js 3KB
24_hoppers.js 2KB
57_cmntxml.js 2KB
05_buf.js 2KB
61_fcommon.js 2KB
35_custprops.js 2KB
WorkbookDefinedNameCollection.js 2KB
55_vml.js 2KB
45_rtf.js 2KB
53_externlink.js 2KB
69_chartxml.js 2KB
25_cellutils.js 2KB
84_defaults.js 1KB
gulpfile.js 1KB
demo.js 1KB
52_calcchain.js 1KB
Workbook.js 1KB
04_base64.js 1KB
43_sstbin.js 1KB
65_fods.js 1KB
82_sheeter.js 1KB
26_crypto.js 1KB
56_cmntcommon.js 1013B
54_drawing.js 849B
共 268 条
- 1
- 2
- 3
资源评论
- link800-coen2023-12-06如何设置单个单元格的宽度和高度AKA多个A2023-12-15可以看一下xlsx-js-style官网api
AKA多个A
- 粉丝: 46
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功