forked from sheetjs/sheetjs
Merge branch 'master' of https://github.com/protobi/js-xlsx
This commit is contained in:
commit
eef7da3099
49
README.md
49
README.md
@ -1,8 +1,20 @@
|
||||
# xlsx
|
||||
# xlsx-style
|
||||
|
||||
Parser and writer for various spreadsheet formats. Pure-JS cleanroom
|
||||
implementation from official specifications and related documents.
|
||||
|
||||
## About this fork
|
||||
[This project](https://github.com/SheetJS/js-xlsx/tree/beta) is a fork of the original (and awesome) [SheetJS/xlsx](https://github.com/SheetJS/js-xlsx) project.
|
||||
It is extended to enable cell formats to be read from and written to .xlsx workbooks.
|
||||
The intent is to provide a temporary means of using these features in practice, and ultimately to merge this into the primary project.
|
||||
Report any issues to https://github.com/protobi/js-xlsx/issues.
|
||||
|
||||
For those contributing to this fork:
|
||||
* `master` is the main branch, which follows the original repo to enable a future pull request.
|
||||
* `beta` branch is published to npm and bower to make this fork available for use.
|
||||
|
||||
## Supported formats
|
||||
|
||||
Supported read formats:
|
||||
|
||||
- Excel 2007+ XML Formats (XLSX/XLSM)
|
||||
@ -24,10 +36,10 @@ Source: <http://git.io/xlsx>
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://www.npmjs.org/package/xlsx):
|
||||
With [npm](https://www.npmjs.org/package/xlsx-style):
|
||||
|
||||
```sh
|
||||
npm install xlsx --save
|
||||
npm install xlsx-style --save
|
||||
```
|
||||
|
||||
In the browser:
|
||||
@ -39,7 +51,7 @@ In the browser:
|
||||
With [bower](http://bower.io/search/?q=js-xlsx):
|
||||
|
||||
```sh
|
||||
bower install js-xlsx
|
||||
bower install js-xlsx-style#beta
|
||||
```
|
||||
|
||||
CDNjs automatically pulls the latest version and makes all versions available at
|
||||
@ -246,7 +258,20 @@ XLSX.writeFile(workbook, 'out.xlsx');
|
||||
|
||||
```js
|
||||
/* bookType can be 'xlsx' or 'xlsm' or 'xlsb' */
|
||||
var wopts = { bookType:'xlsx', bookSST:false, type:'binary' };
|
||||
var wopts = {
|
||||
bookType:'xlsx',
|
||||
bookSST:false,
|
||||
type:'binary',
|
||||
showGridLines: false,
|
||||
defaultCellStyle: { font: { name: "Verdana", sz: 11, color: "FF00FF88"}, fill: {fgColor: {rgb: "FFFFAA00"}}},
|
||||
Props: {
|
||||
title: "Goldilocks",
|
||||
description: "Girl discovers mysterious cottage in forest ",
|
||||
creator:"Traditional folk tale",
|
||||
keywords: "Bears; porridge; property rights; iterative optimization",
|
||||
subject: "subject"
|
||||
}
|
||||
};
|
||||
|
||||
var wbout = XLSX.write(workbook,wopts);
|
||||
|
||||
@ -419,14 +444,21 @@ Special worksheet keys (accessible as `worksheet[key]`, each starting with `!`):
|
||||
will write all cells in the merge range if they exist, so be sure that only
|
||||
the first cell (upper-left) in the range is set.
|
||||
|
||||
The following properties are currently used when generating an XLSX file, but not yet parsed:
|
||||
|
||||
- `ws['!rowBreaks']`: array of row break points, e.g. `[16,32]`
|
||||
- `ws['!colBreaks']`: array of col break points, e.g. `[8,16]`
|
||||
- `ws['!pageSetup']`: `{scale: '100', orientation: 'portrait'||'landscape'}
|
||||
|
||||
|
||||
### Workbook Object
|
||||
|
||||
`workbook.SheetNames` is an ordered list of the sheets in the workbook
|
||||
|
||||
`wb.Sheets[sheetname]` returns an object representing the worksheet.
|
||||
|
||||
`wb.Props` is an object storing the standard properties. The following properties are written but not parsed:
|
||||
`wb.Props` is an object storing the standard properties. The following properties are currently used when
|
||||
generating an XLSX file, but not yet parsed:
|
||||
- `title`
|
||||
- `subject`
|
||||
- `description`
|
||||
@ -485,7 +517,7 @@ The exported `write` and `writeFile` functions accept an options argument:
|
||||
| cellDates | false | Store dates as type `d` (default is `n`) |
|
||||
| bookSST | false | Generate Shared String Table ** |
|
||||
| bookType | 'xlsx' | Type of Workbook ("xlsx" or "xlsm" or "xlsb") |
|
||||
| showGridLines | true | Show gridlines on all pages |
|
||||
| showGridLines | true | Show grid lines on all pages (note capital L) |
|
||||
| tabSelected | '1' | Initial tab selected |
|
||||
|
||||
- `bookSST` is slower and more memory intensive, but has better compatibility
|
||||
@ -496,6 +528,7 @@ The exported `write` and `writeFile` functions accept an options argument:
|
||||
- `cellDates` only applies to XLSX output and is not guaranteed to work with
|
||||
third-party readers. Excel itself does not usually write cells with type `d`
|
||||
so non-Excel tools may ignore the data or blow up in the presence of dates.
|
||||
- showGridLines and tabSelected are currently used when generating an XLSX file but not yet parse.
|
||||
|
||||
|
||||
## Cell Styles
|
||||
@ -525,7 +558,7 @@ top-level attributes: `fill`, `font`, `numFmt`, `alignment`, and `border`.
|
||||
| | | `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters
|
||||
| | | `"m/dd/yy"` // string a date format using Excel's format notation
|
||||
| alignment | vertical | `"bottom"||"center"||"top"`
|
||||
| | horizontal | `"bottom"||"center"||"top"`
|
||||
| | horizontal | `"left"||"center"||"right"`
|
||||
| | wrapText | `true || false`
|
||||
| | readingOrder | `2` // for right-to-left
|
||||
| | textRotation | Number from `0` to `180` or `255` (default is `0`)
|
||||
|
Loading…
Reference in New Issue
Block a user