diff --git a/.github/workflows/asset-size.yml b/.github/workflows/asset-size.yml index 2ac84661d..f9c813146 100644 --- a/.github/workflows/asset-size.yml +++ b/.github/workflows/asset-size.yml @@ -4,6 +4,7 @@ on: [pull_request] jobs: compare: + timeout-minutes: 15 runs-on: ubuntu-latest steps: diff --git a/.github/workflows/exceljs.yml b/.github/workflows/tests.yml similarity index 66% rename from .github/workflows/exceljs.yml rename to .github/workflows/tests.yml index 876b57eae..7e696d799 100644 --- a/.github/workflows/exceljs.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: ExcelJS +name: Tests on: push: @@ -8,12 +8,12 @@ on: jobs: test: + timeout-minutes: 10 name: Node v${{ matrix.node-version }} on ${{ matrix.os }} strategy: fail-fast: false matrix: - # https://github.com/actions/setup-node/issues/27 - node-version: [8.17.0, 10.x, 12.x, 14.x, 16.x] + node-version: [10.x, 12.x, 14.x, 16.x, 17.x, 18.x, 19.x, 20.x] os: [ubuntu-latest, macOS-latest, windows-latest] runs-on: ${{ matrix.os }} @@ -24,15 +24,15 @@ jobs: git config --global core.autocrlf false git config --global core.symlinks true if: runner.os == 'Windows' - - uses: actions/checkout@v2 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest v3. TODO upgrade with: node-version: ${{ matrix.node-version }} - name: Create the npm cache directory run: mkdir npm-cache && npm config set cache ./npm-cache --global - name: Cache node modules - uses: actions/cache@v1 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade with: path: ./npm-cache key: v1-${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package.json') }} @@ -44,18 +44,19 @@ jobs: CI: true benchmark: + timeout-minutes: 15 name: Measure performance impact of changes runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade + - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest v3. TODO upgrade with: - node-version: 12.x + node-version: 18 - name: Create the npm cache directory run: mkdir npm-cache && npm config set cache ./npm-cache --global - name: Cache node modules - uses: actions/cache@v1 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade with: path: ./npm-cache key: v1-npm-${{ hashFiles('**/package.json') }} @@ -67,18 +68,19 @@ jobs: CI: true typescript: + timeout-minutes: 15 name: Ensure typescript compatibility runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #latest v4. TODO upgrade + - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #latest v3. TODO upgrade with: - node-version: 12.x + node-version: 18 - name: Create the npm cache directory run: mkdir npm-cache && npm config set cache ./npm-cache --global - name: Cache node modules - uses: actions/cache@v1 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #latest v3 TODO upgrade with: path: ./npm-cache key: v1-npm-${{ hashFiles('**/package.json') }} diff --git a/.gitignore b/.gitignore index b2e50bdae..8026a7080 100644 --- a/.gitignore +++ b/.gitignore @@ -65,4 +65,5 @@ _SpecRunner.html .DS_Store # Ignore xlsx files generated during testing -*.xlsx \ No newline at end of file +*.xlsx +enpm-lock.yaml \ No newline at end of file diff --git a/.prettier b/.prettier index 470c46807..cbd7f9818 100644 --- a/.prettier +++ b/.prettier @@ -2,6 +2,6 @@ "bracketSpacing": false, "printWidth": 100, "trailingComma": "all", - "bracketSpacing": false, - "arrowParens": "avoid" + "arrowParens": "avoid", + "singleQuote": true, } diff --git a/README.md b/README.md index 5b8d3a250..ccc780828 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # ExcelJS -[![Build status](https://github.com/exceljs/exceljs/workflows/ExcelJS/badge.svg)](https://github.com/exceljs/exceljs/actions?query=workflow%3AExcelJS) -[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/exceljs/exceljs.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/exceljs/exceljs/context:javascript) -[![Total Alerts](https://img.shields.io/lgtm/alerts/g/exceljs/exceljs.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/exceljs/exceljs/alerts) +[![Build Status](https://github.com/exceljs/exceljs/actions/workflows/tests.yml/badge.svg?branch=master&event=push)](https://github.com/exceljs/exceljs/actions/workflows/tests.yml) Read, manipulate and write spreadsheet data and styles to XLSX and JSON. @@ -20,59 +18,41 @@ npm install exceljs # New Features! - - - +* Merged [Add pivot table with limitations #2551](https://github.com/exceljs/exceljs/pull/2551).
Many thanks to Protobi and Michael for this contribution! +* Merged [fix: styles rendering in case when "numFmt" is present in conditional formatting rules (resolves #1814) #1815](https://github.com/exceljs/exceljs/pull/1815).
Many thanks to [@andreykrupskii](https://github.com/andreykrupskii) for this contribution! +* Merged [inlineStr cell type support #1575 #1576](https://github.com/exceljs/exceljs/pull/1576).
Many thanks to [@drdmitry](https://github.com/drdmitry) for this contribution! +* Merged [Fix parsing of boolean attributes #1849](https://github.com/exceljs/exceljs/pull/1849).
Many thanks to [@bno1](https://github.com/bno1) for this contribution! +* Merged [add optional custom auto-filter to table #1670](https://github.com/exceljs/exceljs/pull/1670).
Many thanks to [@thambley](https://github.com/thambley) for this contribution! +* Merged [Deep copy inherited style #1850](https://github.com/exceljs/exceljs/pull/1850).
Many thanks to [@ikzhr](https://github.com/ikzhr) for this contribution! +* Merged [Upgrade actions/cache and actions/setup-node #1846](https://github.com/exceljs/exceljs/pull/1846).
Many thanks to [@cclauss](https://github.com/cclauss) for this contribution! +* Merged [Check object keys in isEqual #1831](https://github.com/exceljs/exceljs/pull/1831).
Many thanks to [@bno1](https://github.com/bno1) for this contribution! +* Merged [Add v17 to testing workflow #1856](https://github.com/exceljs/exceljs/pull/1856).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [Upgrade jszip to its latest version to date. This version does not have any vulnerability found by Snyk so far #1895](https://github.com/exceljs/exceljs/pull/1895).
Many thanks to [@ValerioSevilla](https://github.com/ValerioSevilla) for this contribution! +* Merged [Update README.md #1677](https://github.com/exceljs/exceljs/pull/1677).
Many thanks to [@xjrcode](https://github.com/xjrcode) for this contribution! +* Merged [(docs): set prototype of RegExp correctly. #1700](https://github.com/exceljs/exceljs/pull/1700).
Many thanks to [@joeldenning](https://github.com/joeldenning) for this contribution! +* Merged [Added timeouts to github actions #1733](https://github.com/exceljs/exceljs/pull/1733).
Many thanks to [@alexbjorlig](https://github.com/alexbjorlig) for this contribution! +* Merged [fix issue 1676 #1701](https://github.com/exceljs/exceljs/pull/1701).
Many thanks to [@skypesky](https://github.com/skypesky) for this contribution! +* Merged [ExcelJS/ExcelJS#2237 : Update CI Tests, Drop support for Node v8 #2242](https://github.com/exceljs/exceljs/pull/2242).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [Fix types for getWorksheet() #2223](https://github.com/exceljs/exceljs/pull/2223).
Many thanks to [@hfhchan-plb](https://github.com/hfhchan-plb) for this contribution! +* Merged [add characters cannot be used for worksheet name #2126](https://github.com/exceljs/exceljs/pull/2126).
Many thanks to [@tkm-kj](https://github.com/tkm-kj) for this contribution! +* Merged [Fix issue #1753 Reject promise when workbook reader is writing to temporary file stream and error occurs #1756](https://github.com/exceljs/exceljs/pull/1756).
Many thanks to [@pauliusg](https://github.com/pauliusg) for this contribution! +* Merged [README.md to have correct link for Streaming XLSX #2186](https://github.com/exceljs/exceljs/pull/2186).
Many thanks to [@wulfsolter](https://github.com/wulfsolter) for this contribution! +* Merged [Added a polyfill of promise.finally to support lower versions of Firefox. #1982](https://github.com/exceljs/exceljs/pull/1982).
Many thanks to [@DemoJj](https://github.com/DemoJj) for this contribution! +* Merged [Fix read this.worksheet before assign it #1934](https://github.com/exceljs/exceljs/pull/1934).
Many thanks to [@ZyqGitHub1](https://github.com/ZyqGitHub1) for this contribution! +* Merged [chore: upgrade jszip to ^3.10.1 #2211](https://github.com/exceljs/exceljs/pull/2211).
Many thanks to [@jarrod-cocoon](https://github.com/jarrod-cocoon) for this contribution! +* Merged [fixed spelling error in README.md file #2208](https://github.com/exceljs/exceljs/pull/2208).
Many thanks to [@HugoP27](https://github.com/HugoP27) for this contribution! +* Merged [fix: Fix xlsx.writeFile() not catching error when error occurs #2244](https://github.com/exceljs/exceljs/pull/2244).
Many thanks to [@zurmokeeper](https://github.com/zurmokeeper) for this contribution! +* Merged [Improve worksheets' naming validation logic. #2257](https://github.com/exceljs/exceljs/pull/2257).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [fix issue 2125 - spliceRows remove last row #2140](https://github.com/exceljs/exceljs/pull/2140).
Many thanks to [@babu-ch](https://github.com/babu-ch) for this contribution! +* Merged [fix: fix the loss of column attributes due to incorrect column order #2222](https://github.com/exceljs/exceljs/pull/2222).
Many thanks to [@cpaiyueyue](https://github.com/cpaiyueyue) for this contribution! +* Merged [Fix: Sheet Properties Types #2327](https://github.com/exceljs/exceljs/pull/2327).
Many thanks to [@albeniraouf](https://github.com/albeniraouf) for this contribution! +* Merged [Use node 18 LTS for tsc, and benchmark. Add node 20. to test matrix. … #2354](https://github.com/exceljs/exceljs/pull/2354).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [Add missing tooltip attribute to CellHyperlinkValue index.d.ts #2350](https://github.com/exceljs/exceljs/pull/2350).
Many thanks to [@NiklasPor](https://github.com/NiklasPor) for this contribution! +* Merged [Increase resilience to generating large workbooks #2320](https://github.com/exceljs/exceljs/pull/2320).
Many thanks to [@hfhchan-plb](https://github.com/hfhchan-plb) for this contribution! +* Merged [repair all 'c2fo.io' links ('c2fo.github.io') #2324](https://github.com/exceljs/exceljs/pull/2324).
Many thanks to [@justintunev7](https://github.com/justintunev7) for this contribution! +* Merged [fix: fix type definitions about last column, formula values and protection #2309](https://github.com/exceljs/exceljs/pull/2309).
Many thanks to [@gltjk](https://github.com/gltjk) for this contribution! +* Merged [fix: add spinCount field for WorksheetProtection type #2284](https://github.com/exceljs/exceljs/pull/2284).
Many thanks to [@damingerdai](https://github.com/damingerdai) for this contribution! +* Merged [Add type definition for WorksheetModel.merges #2281](https://github.com/exceljs/exceljs/pull/2281).
Many thanks to [@ytjmt](https://github.com/ytjmt) for this contribution! # Contributions @@ -86,6 +66,10 @@ Versions are updated on release and any change will most likely result in merge To be clear, all contributions added to this library will be included in the library's MIT licence. +### Let's chat together: + +[![SiemaTeam](https://discordapp.com/api/guilds/976854442009825321/widget.png?style=banner2)](https://discord.gg/siema) + # Contents @@ -239,7 +223,7 @@ try { } return new RegExp(pattern, flags); }; - global.RegExp.prototype = RegExp; + global.RegExp.prototype = RegExp.prototype; } ``` @@ -373,7 +357,7 @@ workbook.worksheets[0]; //the first one; ``` It's important to know that `workbook.getWorksheet(1) != Workbook.worksheets[0]` and `workbook.getWorksheet(1) != Workbook.worksheets[1]`, -becouse `workbook.worksheets[0].id` may have any value. +because `workbook.worksheets[0].id` may have any value. ## Worksheet State[⬆](#contents) @@ -2157,6 +2141,12 @@ faster or more resilient. #### Reading XLSX[⬆](#contents) +Options supported when reading XLSX files. + +| Field | Required | Type |Description | +| ---------------- | ----------- | ----------- | ----------- | +| ignoreNodes | N | Array | A list of node names to ignore while loading the XLSX document. Improves performance in some situations.
Available: `sheetPr`, `dimension`, `sheetViews `, `sheetFormatPr`, `cols `, `sheetData`, `autoFilter `, `mergeCells `, `rowBreaks`, `hyperlinks `, `pageMargins`, `dataValidations`, `pageSetup`, `headerFooter `, `printOptions `, `picture`, `drawing`, `sheetProtection`, `tableParts `, `conditionalFormatting`, `extLst`,| + ```javascript // read from a file const workbook = new Excel.Workbook(); @@ -2174,6 +2164,16 @@ await workbook.xlsx.read(stream); const workbook = new Excel.Workbook(); await workbook.xlsx.load(data); // ... use workbook + + +// using additional options +const workbook = new Excel.Workbook(); +await workbook.xlsx.load(data, { + ignoreNodes: [ + 'dataValidations' // ignores the workbook's Data Validations + ], +}); +// ... use workbook ``` #### Writing XLSX[⬆](#contents) @@ -2201,7 +2201,7 @@ Options supported when reading CSV files. | dateFormats | N | Array | Specify the date encoding format of dayjs. | | map | N | Function | Custom Array.prototype.map() callback function for processing data. | | sheetName | N | String | Specify worksheet name. | -| parserOptions | N | Object | [parseOptions options](https://c2fo.io/fast-csv/docs/parsing/options) @fast-csv/format module to write csv data. | +| parserOptions | N | Object | [parseOptions options](https://c2fo.github.io/fast-csv/docs/parsing/options) @fast-csv/format module to write csv data. | ```javascript // read from a file @@ -2244,7 +2244,7 @@ const options = { return parseFloat(value); } }, - // https://c2fo.io/fast-csv/docs/parsing/options + // https://c2fo.github.io/fast-csv/docs/parsing/options parserOptions: { delimiter: '\t', quote: false, @@ -2280,7 +2280,7 @@ Options supported when writing to a CSV file. | map | N | Function | Custom Array.prototype.map() callback function for processing row values. | | sheetName | N | String | Specify worksheet name. | | sheetId | N | Number | Specify worksheet ID. | -| formatterOptions | N | Object | [formatterOptions options](https://c2fo.io/fast-csv/docs/formatting/options/) @fast-csv/format module to write csv data. | +| formatterOptions | N | Object | [formatterOptions options](https://c2fo.github.io/fast-csv/docs/formatting/options/) @fast-csv/format module to write csv data. | ```javascript @@ -2321,7 +2321,7 @@ const options = { return value; } }, - // https://c2fo.io/fast-csv/docs/formatting/options + // https://c2fo.github.io/fast-csv/docs/formatting/options formatterOptions: { delimiter: '\t', quote: false, @@ -2631,10 +2631,13 @@ An Excel formula for calculating values on the fly. Note that ExcelJS cannot process the formula to generate a result, it must be supplied. +Note that function semantic names must be in English and the separator must be a comma. + E.g. ```javascript worksheet.getCell('A3').value = { formula: 'A1+A2', result: 7 }; +worksheet.getCell('A3').value = { formula: 'SUM(A1,A2)', result: 7 }; ``` Cells also support convenience getters to access the formula and result: @@ -2875,7 +2878,7 @@ If any splice operation affects a merged cell, the merge group will not be moved # Release History[⬆](#contents) | Version | Changes | -| ------- | ------- | +|---------| ------- | | 0.0.9 | | | 0.1.0 | | | 0.1.1 | | @@ -3018,5 +3021,4 @@ If any splice operation affects a merged cell, the merge group will not be moved | 4.1.1 | | | 4.2.0 | | | 4.2.1 | | - - +| 4.3.0 | | diff --git a/README_zh.md b/README_zh.md index dc05bf49a..5f1100363 100644 --- a/README_zh.md +++ b/README_zh.md @@ -16,20 +16,40 @@ npm install exceljs # 新的功能! - +* Merged [fix: styles rendering in case when "numFmt" is present in conditional formatting rules (resolves #1814) #1815](https://github.com/exceljs/exceljs/pull/1815).
Many thanks to [@andreykrupskii](https://github.com/andreykrupskii) for this contribution! +* Merged [inlineStr cell type support #1575 #1576](https://github.com/exceljs/exceljs/pull/1576).
Many thanks to [@drdmitry](https://github.com/drdmitry) for this contribution! +* Merged [Fix parsing of boolean attributes #1849](https://github.com/exceljs/exceljs/pull/1849).
Many thanks to [@bno1](https://github.com/bno1) for this contribution! +* Merged [add optional custom auto-filter to table #1670](https://github.com/exceljs/exceljs/pull/1670).
Many thanks to [@thambley](https://github.com/thambley) for this contribution! +* Merged [Deep copy inherited style #1850](https://github.com/exceljs/exceljs/pull/1850).
Many thanks to [@ikzhr](https://github.com/ikzhr) for this contribution! +* Merged [Upgrade actions/cache and actions/setup-node #1846](https://github.com/exceljs/exceljs/pull/1846).
Many thanks to [@cclauss](https://github.com/cclauss) for this contribution! +* Merged [Check object keys in isEqual #1831](https://github.com/exceljs/exceljs/pull/1831).
Many thanks to [@bno1](https://github.com/bno1) for this contribution! +* Merged [Add v17 to testing workflow #1856](https://github.com/exceljs/exceljs/pull/1856).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [Upgrade jszip to its latest version to date. This version does not have any vulnerability found by Snyk so far #1895](https://github.com/exceljs/exceljs/pull/1895).
Many thanks to [@ValerioSevilla](https://github.com/ValerioSevilla) for this contribution! +* Merged [Update README.md #1677](https://github.com/exceljs/exceljs/pull/1677).
Many thanks to [@xjrcode](https://github.com/xjrcode) for this contribution! +* Merged [(docs): set prototype of RegExp correctly. #1700](https://github.com/exceljs/exceljs/pull/1700).
Many thanks to [@joeldenning](https://github.com/joeldenning) for this contribution! +* Merged [Added timeouts to github actions #1733](https://github.com/exceljs/exceljs/pull/1733).
Many thanks to [@alexbjorlig](https://github.com/alexbjorlig) for this contribution! +* Merged [fix issue 1676 #1701](https://github.com/exceljs/exceljs/pull/1701).
Many thanks to [@skypesky](https://github.com/skypesky) for this contribution! +* Merged [ExcelJS/ExcelJS#2237 : Update CI Tests, Drop support for Node v8 #2242](https://github.com/exceljs/exceljs/pull/2242).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [Fix types for getWorksheet() #2223](https://github.com/exceljs/exceljs/pull/2223).
Many thanks to [@hfhchan-plb](https://github.com/hfhchan-plb) for this contribution! +* Merged [add characters cannot be used for worksheet name #2126](https://github.com/exceljs/exceljs/pull/2126).
Many thanks to [@tkm-kj](https://github.com/tkm-kj) for this contribution! +* Merged [Fix issue #1753 Reject promise when workbook reader is writing to temporary file stream and error occurs #1756](https://github.com/exceljs/exceljs/pull/1756).
Many thanks to [@pauliusg](https://github.com/pauliusg) for this contribution! +* Merged [README.md to have correct link for Streaming XLSX #2186](https://github.com/exceljs/exceljs/pull/2186).
Many thanks to [@wulfsolter](https://github.com/wulfsolter) for this contribution! +* Merged [Added a polyfill of promise.finally to support lower versions of Firefox. #1982](https://github.com/exceljs/exceljs/pull/1982).
Many thanks to [@DemoJj](https://github.com/DemoJj) for this contribution! +* Merged [Fix read this.worksheet before assign it #1934](https://github.com/exceljs/exceljs/pull/1934).
Many thanks to [@ZyqGitHub1](https://github.com/ZyqGitHub1) for this contribution! +* Merged [chore: upgrade jszip to ^3.10.1 #2211](https://github.com/exceljs/exceljs/pull/2211).
Many thanks to [@jarrod-cocoon](https://github.com/jarrod-cocoon) for this contribution! +* Merged [fixed spelling error in README.md file #2208](https://github.com/exceljs/exceljs/pull/2208).
Many thanks to [@HugoP27](https://github.com/HugoP27) for this contribution! +* Merged [fix: Fix xlsx.writeFile() not catching error when error occurs #2244](https://github.com/exceljs/exceljs/pull/2244).
Many thanks to [@zurmokeeper](https://github.com/zurmokeeper) for this contribution! +* Merged [Improve worksheets' naming validation logic. #2257](https://github.com/exceljs/exceljs/pull/2257).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [fix issue 2125 - spliceRows remove last row #2140](https://github.com/exceljs/exceljs/pull/2140).
Many thanks to [@babu-ch](https://github.com/babu-ch) for this contribution! +* Merged [fix: fix the loss of column attributes due to incorrect column order #2222](https://github.com/exceljs/exceljs/pull/2222).
Many thanks to [@cpaiyueyue](https://github.com/cpaiyueyue) for this contribution! +* Merged [Fix: Sheet Properties Types #2327](https://github.com/exceljs/exceljs/pull/2327).
Many thanks to [@albeniraouf](https://github.com/albeniraouf) for this contribution! +* Merged [Use node 18 LTS for tsc, and benchmark. Add node 20. to test matrix. … #2354](https://github.com/exceljs/exceljs/pull/2354).
Many thanks to [@Siemienik](https://github.com/Siemienik) for this contribution! +* Merged [Add missing tooltip attribute to CellHyperlinkValue index.d.ts #2350](https://github.com/exceljs/exceljs/pull/2350).
Many thanks to [@NiklasPor](https://github.com/NiklasPor) for this contribution! +* Merged [Increase resilience to generating large workbooks #2320](https://github.com/exceljs/exceljs/pull/2320).
Many thanks to [@hfhchan-plb](https://github.com/hfhchan-plb) for this contribution! +* Merged [repair all 'c2fo.io' links ('c2fo.github.io') #2324](https://github.com/exceljs/exceljs/pull/2324).
Many thanks to [@justintunev7](https://github.com/justintunev7) for this contribution! +* Merged [fix: fix type definitions about last column, formula values and protection #2309](https://github.com/exceljs/exceljs/pull/2309).
Many thanks to [@gltjk](https://github.com/gltjk) for this contribution! +* Merged [fix: add spinCount field for WorksheetProtection type #2284](https://github.com/exceljs/exceljs/pull/2284).
Many thanks to [@damingerdai](https://github.com/damingerdai) for this contribution! +* Merged [Add type definition for WorksheetModel.merges #2281](https://github.com/exceljs/exceljs/pull/2281).
Many thanks to [@ytjmt](https://github.com/ytjmt) for this contribution! # 贡献 @@ -196,7 +216,7 @@ try { } return new RegExp(pattern, flags); }; - global.RegExp.prototype = RegExp; + global.RegExp.prototype = RegExp.prototype; } ``` @@ -2089,7 +2109,7 @@ const buffer = await workbook.xlsx.writeBuffer(); | dateFormats | N | Array | 指定 dayjs 的日期编码格式。 | | map | N | Function | 自定义`Array.prototype.map()` 回调函数,用于处理数据。 | | sheetName | N | String | 指定工作表名称。 | -| parserOptions | N | Object | [parseOptions 选项](https://c2fo.io/fast-csv/docs/parsing/options) @fast-csv/format 模块以写入 csv 数据。 | +| parserOptions | N | Object | [parseOptions 选项](https://c2fo.github.io/fast-csv/docs/parsing/options) @fast-csv/format 模块以写入 csv 数据。 | ```javascript // 从文件读取 @@ -2132,7 +2152,7 @@ const options = { return parseFloat(value); } }, - // https://c2fo.io/fast-csv/docs/parsing/options + // https://c2fo.github.io/fast-csv/docs/parsing/options parserOptions: { delimiter: '\t', quote: false, @@ -2165,7 +2185,7 @@ CSV 解析器使用 [fast-csv](https://www.npmjs.com/package/fast-csv) 读取CSV | map | N | Function | 自定义`Array.prototype.map()` 回调函数,用于处理行值。 | | sheetName | N | String | 指定工作表名称。 | | sheetId | N | Number | 指定工作表 ID。 | -| formatterOptions | N | Object | [formatterOptions 选项](https://c2fo.io/fast-csv/docs/formatting/options/) @fast-csv/format 模块写入csv 数据。 | +| formatterOptions | N | Object | [formatterOptions 选项](https://c2fo.github.io/fast-csv/docs/formatting/options/) @fast-csv/format 模块写入csv 数据。 | ```javascript @@ -2205,7 +2225,7 @@ const options = { return value; } }, - // https://c2fo.io/fast-csv/docs/formatting/options + // https://c2fo.github.io/fast-csv/docs/formatting/options formatterOptions: { delimiter: '\t', quote: false, @@ -2711,19 +2731,19 @@ sudo apt-get install libfontconfig # 发布历史[⬆](#目录) -| 版本 | 变化 | -| ------- | ------- | -| 0.0.9 | | -| 0.1.0 | | -| 0.1.1 | | -| 0.1.2 | | -| 0.1.3 | | -| 0.1.5 | | -| 0.1.6 | | -| 0.1.8 | | -| 0.1.9 | | -| 0.1.10 | | -| 0.1.11 | | +| Version | Changes | +|---------| ------- | +| 0.0.9 | | +| 0.1.0 | | +| 0.1.1 | | +| 0.1.2 | | +| 0.1.3 | | +| 0.1.5 | | +| 0.1.6 | | +| 0.1.8 | | +| 0.1.9 | | +| 0.1.10 | | +| 0.1.11 | | | 0.2.0 | | | 0.2.2 | | | 0.2.3 | | @@ -2848,3 +2868,11 @@ sudo apt-get install libfontconfig | 3.8.0 | | | 3.8.1 | | | 3.8.2 | | +| 3.9.0 | | +| 3.10.0 | | +| 4.0.1 | | +| 4.1.0 | | +| 4.1.1 | | +| 4.2.0 | | +| 4.2.1 | | +| 4.3.0 | | diff --git a/gruntfile.js b/gruntfile.js index cc1574170..384b04500 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -27,14 +27,17 @@ module.exports = function(grunt) { browserify: { options: { transform: [ - ['babelify', { - // enable babel transpile for node_modules - global: true, - presets: ['@babel/preset-env'], - // core-js should not be transpiled - // See https://github.com/zloirock/core-js/issues/514 - ignore: [/node_modules[\\/]core-js/], - }], + [ + 'babelify', + { + // enable babel transpile for node_modules + global: true, + presets: ['@babel/preset-env'], + // core-js should not be transpiled + // See https://github.com/zloirock/core-js/issues/514 + ignore: [/node_modules[\\/]core-js/], + }, + ], ], browserifyOptions: { // enable source map for browserify @@ -119,6 +122,10 @@ module.exports = function(grunt) { }, jasmine: { + options: { + version: '3.8.0', + noSandbox: true, + }, dev: { src: ['./dist/exceljs.js'], options: { diff --git a/index.d.ts b/index.d.ts index c5174c0d2..af7524ca7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -230,7 +230,7 @@ export interface Font { } export type BorderStyle = - | 'thin' | 'dotted' | 'hair' | 'medium' | 'double' | 'thick' | 'dashDot' + | 'thin' | 'dotted' | 'hair' | 'medium' | 'double' | 'thick' | 'dashed' | 'dashDot' | 'dashDotDot' | 'slantDashDot' | 'mediumDashed' | 'mediumDashDotDot' | 'mediumDashDot'; export interface Color { @@ -289,6 +289,7 @@ export interface Alignment { export interface Protection { locked: boolean; + hidden: boolean; } export interface Style { @@ -344,19 +345,20 @@ export interface CellRichTextValue { export interface CellHyperlinkValue { text: string; hyperlink: string; + tooltip?: string; } export interface CellFormulaValue { formula: string; - result?: number | string | Date | { error: CellErrorValue }; - date1904: boolean; + result?: number | string | boolean | Date | CellErrorValue; + date1904?: boolean; } export interface CellSharedFormulaValue { sharedFormula: string; readonly formula?: string; - result?: number | string | Date | { error: CellErrorValue }; - date1904: boolean; + result?: number | string | boolean | Date | CellErrorValue; + date1904?: boolean; } export declare enum ValueType { @@ -632,7 +634,7 @@ export interface Column { /** * The cell values in the column */ - values: ReadonlyArray; + values: CellValue; /** * Column letter key @@ -880,6 +882,7 @@ export interface WorksheetProtection { sort: boolean; autoFilter: boolean; pivotTables: boolean; + spinCount: number; } export interface Image { extension: 'jpeg' | 'png' | 'gif'; @@ -989,6 +992,7 @@ export interface WorksheetModel { views: WorksheetView[]; autoFilter: AutoFilter; media: Media[]; + merges: Range['range'][]; } export type WorksheetState = 'visible' | 'hidden' | 'veryHidden'; @@ -1139,7 +1143,7 @@ export interface Worksheet { /** * Get the last column in a worksheet */ - readonly lastColumn: Column; + readonly lastColumn: Column | undefined; /** * A count of the number of columns that have values. @@ -1401,6 +1405,13 @@ export interface WorksheetProperties { */ outlineLevelRow: number; + /** + * The outline properties which controls how it will summarize rows and columns + */ + outlineProperties: { + summaryBelow: boolean, + summaryRight: boolean, + }; /** * Default row height (default: 15) */ @@ -1446,6 +1457,13 @@ export interface JSZipGeneratorOptions { }; } +export interface XlsxReadOptions { + /** + * The list of XML node names to ignore while parsing an XLSX file + */ + ignoreNodes: string[]; +} + export interface XlsxWriteOptions extends stream.xlsx.WorkbookWriterOptions { /** * The option passed to JsZip#generateAsync(options) @@ -1457,19 +1475,19 @@ export interface Xlsx { /** * read from a file */ - readFile(path: string): Promise; + readFile(path: string, options?: Partial): Promise; /** * read from a stream * @param stream */ - read(stream: import('stream').Stream): Promise; + read(stream: import('stream').Stream, options?: Partial): Promise; /** * load from an array buffer * @param buffer */ - load(buffer: Buffer): Promise; + load(buffer: Buffer, options?: Partial): Promise; /** * write to a buffer @@ -1487,7 +1505,7 @@ export interface Xlsx { write(stream: import('stream').Stream, options?: Partial): Promise; } -// https://c2fo.io/fast-csv/docs/parsing/options +// https://c2fo.github.io/fast-csv/docs/parsing/options type HeaderArray = (string | undefined | null)[]; type HeaderTransformFunction = (headers: HeaderArray) => HeaderArray; @@ -1528,7 +1546,7 @@ interface RowTransformFunction { (row: Rows): Rows; } -// https://c2fo.io/fast-csv/docs/formatting/options/ +// https://c2fo.github.io/fast-csv/docs/formatting/options/ export interface FastCsvFormatterOptionsArgs { objectMode: boolean; delimiter: string; @@ -1743,7 +1761,7 @@ export class Workbook { /** * fetch sheet by name or id */ - getWorksheet(indexOrName: number | string): Worksheet; + getWorksheet(indexOrName?: number | string): Worksheet | undefined; /** * Iterate over all sheets. @@ -1814,6 +1832,11 @@ export interface TableColumnProperties { * Optional formula for custom functions */ totalsRowFormula?: string; + + /** + * Styles applied to the column + */ + style?: Partial