@david_marquez_f/zipcelx

1.6.7 • Public • Published

zipcelx

Generate XLSX files in the browser, with minimal footprint. The vision is to provide the smallest possible package for generating valid XLSX files in the browser.

If you're looking for advanced functionality, js-xlsx is a solid choice.

Table of contents

  1. How to use
  2. The config object
  3. Contributing

Dates

Format of dates based on this article, where it says that date in xlsx files is the number of days since 1/1/1900 (serial date). Datetime can be implemented by using the format ddddd.tttttt, where d is calculated as the date format and t is the fractional part of a 24h day. Time as far as I understand could be implemented by using 0.tttttt. .NET offers the toOADate which does exactly this.

This however has the constraint that dates before 1900 are not possible. That's why office 2010+ added support for the date type. For the broadest compatibility cell type number should be used (see this stack overflow issue). The "s" property defines the styleIndex of the cell. In order to use a style you also need to define it. There are 164 formats and then you can add your custom formats. This stack overflow explains how to achieve this.

In short:

Before Office 2010

<row r="1">
  <c r="A1" s="0">
    <v>42005</v>
  </c>
</row>

Office 2010+

<row>
  <c s="0" t="d">
    <v>2015-08-05T11:13:57</v>
  </c>
</row>

Finally for both of them we need the style:

<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" />

Number formats (incomplete list)

The rest of formats can be found here, part 4, 3.8.30 and 3.8.31

It's also good to know:

NumFmtId="14", it's not exactly "mm-dd-yy" : this will be interpreted differently in Windows Excel 2010 software, based on the user's regional and language settings (at Windows level) : it will be the "Short date" format i.e. dd/mm/yyyy in French, or mm/dd/yyyy in English (verified by switching from English (United States) to French (France) and vice versa)

0 = 'General';
1 = '0';
2 = '0.00';
3 = '#,##0';
4 = '#,##0.00';

9 = '0%';
10 = '0.00%';
11 = '0.00E+00';
12 = '# ?/?';
13 = '# ??/??';
14 = 'mm-dd-yy';
15 = 'd-mmm-yy';
16 = 'd-mmm';
17 = 'mmm-yy';
18 = 'h:mm AM/PM';
19 = 'h:mm:ss AM/PM';
20 = 'h:mm';
21 = 'h:mm:ss';
22 = 'm/d/yy h:mm';

37 = '#,##0 ;(#,##0)';
38 = '#,##0 ;[Red](#,##0)';
39 = '#,##0.00;(#,##0.00)';
40 = '#,##0.00;[Red](#,##0.00)';

44 = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
45 = 'mm:ss';
46 = '[h]:mm:ss';
47 = 'mmss.0';
48 = '##0.0E+0';
49 = '@';

27 = '[$-404]e/m/d';
30 = 'm/d/yy';
36 = '[$-404]e/m/d';
50 = '[$-404]e/m/d';
57 = '[$-404]e/m/d';

59 = 't0';
60 = 't0.00';
61 = 't#,##0';
62 = 't#,##0.00';
67 = 't0%';
68 = 't0.00%';
69 = 't# ?/?';
70 = 't# ??/??';

This fork adds support for the following:

  • [ ] Date: Use type "date". It uses the number
  • [ ] Datetime
  • [ ] Time

Issues

Should it happen that the tool broke down on you please head to our Issue tracker

  1. Search if the issue is already discussed or explained.
  2. If no luck feel free to open a new issue and we will get back to you as soon as possible.

Readme

Keywords

Package Sidebar

Install

npm i @david_marquez_f/zipcelx

Weekly Downloads

167

Version

1.6.7

License

MIT

Unpacked Size

197 kB

Total Files

38

Last publish

Collaborators

  • david_marquez_f