add-from-scratch

This commit is contained in:
SheetJS 2023-09-27 17:58:41 -04:00
parent 79aacab553
commit 06e7413d36
2 changed files with 31 additions and 12 deletions

@ -119,6 +119,9 @@ This demo was tested in the following environments:
| Windows 11 | ARM | `0.78.1` | 2023-09-27 |
| Linux (HoloOS) | x64 | `0.78.1` | 2023-09-27 |
There is no official Linux ARM64 release. The community release[^1] was tested
and verified on 2023-09-27.
:::
1) Create a `package.json` file that specifies the entry point:
@ -172,4 +175,6 @@ the file input element to select a spreadsheet and clicking the export button.
npx -p nw-builder nwbuild --mode=build --version=0.78.1 --glob=false --outDir=../out ./
```
This will generate the standalone app in the `..\out\` folder.
This will generate the standalone app in the `..\out\` folder.
[^1]: The [`nw60-arm64_2022-01-08` release](https://github.com/LeonardLaszlo/nw.js-armv7-binaries/releases/tag/nw60-arm64_2022-01-08) included an ARM64 version of `nw`.

@ -214,7 +214,9 @@ The [example worksheet](#example-sheet) can be built up in the following order:
</td><td>
1) `aoa_to_sheet` writes `A1:G1` (red)
0) `aoa_to_sheet([[]])` creates an empty worksheet
1) `sheet_add_aoa` writes `A1:G1` (red)
2) `sheet_add_aoa` writes `A2:B4` (blue)
@ -225,8 +227,11 @@ The [example worksheet](#example-sheet) can be built up in the following order:
</td></tr></tbody></table>
```js
/* Initial row */
var ws = XLSX.utils.aoa_to_sheet([ "SheetJS".split("") ]);
/* Start from an empty worksheet */
var ws = XLSX.utils.aoa_to_sheet([[]]);
/* First row */
XLSX.utils.sheet_add_aoa(ws, [ "SheetJS".split("") ], {origin: "A1"});
/* Write data starting at A2 */
XLSX.utils.sheet_add_aoa(ws, [[1,2], [2,3], [3,4]], {origin: "A2"});
@ -240,8 +245,11 @@ XLSX.utils.sheet_add_aoa(ws, [[4,5,6,7,8,9,0]], {origin: -1});
```jsx live
function SheetJSAddAOA() { return ( <button onClick={() => {
/* Initial row */
var ws = XLSX.utils.aoa_to_sheet([ "SheetJS".split("") ]);
/* Start from an empty worksheet */
var ws = XLSX.utils.aoa_to_sheet([[]]);
/* First row */
XLSX.utils.sheet_add_aoa(ws, [ "SheetJS".split("") ], {origin: "A1"});
/* Write data starting at A2 */
XLSX.utils.sheet_add_aoa(ws, [[1,2], [2,3], [3,4]], {origin: "A2"});
@ -410,25 +418,31 @@ an options argument:
This example worksheet can be built up in the order `A1:G1, A2:B4, E2:G4, A5:G5`:
```js
/* Initial row */
var ws = XLSX.utils.json_to_sheet([
/* Start from an empty worksheet */
var ws = XLSX.utils.aoa_to_sheet([[]]);
/* Header order */
var header = ["A", "B", "C", "D", "E", "F", "G"];
/* First row */
XLSX.utils.sheet_add_json(ws, [
{ A: "S", B: "h", C: "e", D: "e", E: "t", F: "J", G: "S" }
], {header: ["A", "B", "C", "D", "E", "F", "G"], skipHeader: true});
], {header: header, skipHeader: true});
/* Write data starting at A2 */
XLSX.utils.sheet_add_json(ws, [
{ A: 1, B: 2 }, { A: 2, B: 3 }, { A: 3, B: 4 }
], {skipHeader: true, origin: "A2"});
], {header: header, skipHeader: true, origin: "A2"});
/* Write data starting at E2 */
XLSX.utils.sheet_add_json(ws, [
{ A: 5, B: 6, C: 7 }, { A: 6, B: 7, C: 8 }, { A: 7, B: 8, C: 9 }
], {skipHeader: true, origin: { r: 1, c: 4 }, header: [ "A", "B", "C" ]});
], {header: ["A", "B", "C"], skipHeader: true, origin: { r: 1, c: 4 }});
/* Append row */
XLSX.utils.sheet_add_json(ws, [
{ A: 4, B: 5, C: 6, D: 7, E: 8, F: 9, G: 0 }
], {header: ["A", "B", "C", "D", "E", "F", "G"], skipHeader: true, origin: -1});
], {header: header, skipHeader: true, origin: -1});
```
:::note pass