SheetJS
216fe0459e
- zh-tw 56 ("上午/下午 "hh"時"mm"分"ss"秒 " currently hardcoded) - 65535 -> general (silly writers generating noncompliant formats) - more general handling of #/0-based formats (removed hardcoded cases) - more general fraction handling (up to 7 digit denominators) - date comma separators - mysterious LO -?? formats (really should be -##) |
||
---|---|---|
bin | ||
test | ||
.npmignore | ||
.travis.yml | ||
LICENSE | ||
Makefile | ||
package.json | ||
README.md | ||
ssf.js | ||
ssf.md |
SSF
SpreadSheet Format (SSF) is a pure-JS library to format data using ECMA-376 spreadsheet format codes (like those used in Microsoft Excel)
This is written in voc -- see ssf.md for code.
To build: voc ssf.md
Setup
In the browser:
<script src="ssf.js"></script>
In node:
var SSF = require('ssf');
The script will manipulate module.exports
if available (e.g. in a CommonJS
require
context). This is not always desirable. To prevent the behavior,
define DO_NOT_EXPORT_SSF
:
Usage
.load(fmt, idx)
sets custom formats (generally indices above 164
).
.format(fmt, val, opts)
formats val
using the format fmt
. If fmt
is of
type number
, the internal table (and custom formats) will be used. If fmt
is a literal format, then it will be parsed and evaluated.
.parse_date_code(val, opts)
parses val
as date code and returns object:
D,T
: Date ([val]
) Time ({val}
)y,m,d
: Year, Month, DayH,M,S,u
: (0-23)Hour, Minute, Second, Sub-secondq
: Day of Week (0=Sunday, 1=Monday, ..., 5=Friday, 6=Saturday)
.get_table()
gets the internal format table (number to format mapping).
.load_table(table)
sets the internal format table.
Notes
Format code 14 in the spec is broken; the correct format is 'mm/dd/yy' (dashes, not spaces)
License
Apache 2.0