版博士V2.0程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

README.md 4.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # [SheetJS SSF](http://sheetjs.com)
  2. ssf (SpreadSheet Format) is a pure JS library to format data using ECMA-376
  3. spreadsheet format codes (used in popular spreadsheet software packages).
  4. This is the community version. We also offer a pro version with additional
  5. features like international support as well as dedicated support.
  6. ## Installation
  7. With [npm](https://www.npmjs.org/package/ssf):
  8. ```bash
  9. $ npm install ssf
  10. ```
  11. In the browser:
  12. ```html
  13. <script src="ssf.js"></script>
  14. ```
  15. The browser exposes a variable `SSF`
  16. When installed globally, npm installs a script `ssf` that renders the format
  17. string with the given arguments. Running the script with `-h` displays help.
  18. The script will manipulate `module.exports` if available . This is not always
  19. desirable. To prevent the behavior, define `DO_NOT_EXPORT_SSF`.
  20. ## Usage
  21. `SSF.format(fmt, val, opts)` formats `val` using the format `fmt`.
  22. If `fmt` is a string, it will be parsed and evaluated. If `fmt` is a `number`,
  23. the actual format will be the corresponding entry in the internal format table.
  24. For a raw numeric format like `000`, the value should be passed as a string.
  25. Date arguments are interpreted in the local time of the JS client.
  26. The options argument may contain the following keys:
  27. | Option Name | Default | Description |
  28. | :---------- | :-----: | :--------------------------------------------------- |
  29. | `date1904` | false | Use 1904 date system if true, 1900 system if false |
  30. ### Manipulating the Internal Format Table
  31. Binary spreadsheet formats store cell formats in a table and reference by index.
  32. This library uses a global table:
  33. `SSF._table` is the underlying object, mapping numeric keys to format strings.
  34. `SSF.load(fmt:string, idx:?number):number` assigns the format to the specified
  35. index and returns the index. If the index is not specified, SSF will search the
  36. space for an available format slot pick an unused slot. For compatibility with
  37. the XLS and XLSB file formats, custom indices should be in the valid ranges
  38. `5-8`, `23-26`, `41-44`, `63-66`, `164-382` (see `[MS-XLSB] 2.4.655 BrtFmt`)
  39. `SSF.get_table()` gets the internal format table (number to format mapping).
  40. `SSF.load_table(table)` sets the internal format table.
  41. ### Other Utilities
  42. `SSF.parse_date_code(val:number, opts:?any)` parses `val`, returning an object:
  43. ```typescript
  44. type SSFDate = {
  45. D:number; /* number of whole days since relevant epoch, 0 <= D */
  46. y:number; /* integral year portion, epoch_year <= y */
  47. m:number; /* integral month portion, 1 <= m <= 12 */
  48. d:number; /* integral day portion, subject to gregorian YMD constraints */
  49. q:number; /* integral day of week (0=Sunday .. 6=Saturday) 0 <= q <= 6 */
  50. T:number; /* number of seconds since midnight, 0 <= T < 86400 */
  51. H:number; /* integral number of hours since midnight, 0 <= H < 24 */
  52. M:number; /* integral number of minutes since the last hour, 0 <= M < 60 */
  53. S:number; /* integral number of seconds since the last minute, 0 <= S < 60 */
  54. u:number; /* sub-second part of time, 0 <= u < 1 */
  55. }
  56. ```
  57. `SSF.is_date(fmt:string):boolean` returns `true` if `fmt` encodes a date format.
  58. ## Examples
  59. - [Basic Demo](http://oss.sheetjs.com/ssf/)
  60. - [Custom Formats Builder](https://customformats.com)
  61. ## Related Packages
  62. [`ssf-cli`](https://www.npmjs.com/package/ssf-cli) is a simple NodeJS command
  63. line tool for formatting numbers.
  64. ## License
  65. Please consult the attached LICENSE file for details. All rights not explicitly
  66. granted by the Apache 2.0 license are reserved by the Original Author.
  67. ## References
  68. - `ECMA-376`: Office Open XML File Formats
  69. - `MS-XLS`: Excel Binary File Format (.xls) Structure Specification
  70. - `MS-XLSB`: Excel (.xlsb) Binary File Format
  71. ## Badges
  72. [![Sauce Test Status](https://saucelabs.com/browser-matrix/ssfjs.svg)](https://saucelabs.com/u/ssfjs)
  73. [![Build Status](https://travis-ci.org/SheetJS/ssf.svg?branch=master)](https://travis-ci.org/SheetJS/ssf)
  74. [![Coverage Status](http://img.shields.io/coveralls/SheetJS/ssf/master.svg)](https://coveralls.io/r/SheetJS/ssf?branch=master)
  75. [![NPM Downloads](https://img.shields.io/npm/dt/ssf.svg)](https://npmjs.org/package/ssf)
  76. [![Dependencies Status](https://david-dm.org/sheetjs/ssf/status.svg)](https://david-dm.org/sheetjs/ssf)
  77. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/ssf?pixel)](https://github.com/SheetJS/ssf)