x-spreadsheet demo [ci skip] fixes #2656

This commit is contained in:
SheetJS 2022-04-15 19:06:45 -04:00
parent ed18acd63d
commit 79e2773b58
5 changed files with 32 additions and 19 deletions

@ -224,6 +224,14 @@ version and will refresh on each release.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-<version>.tgz`) for the desired version.

@ -36,7 +36,7 @@ a { text-decoration: none }
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
<textarea id="b64data">... or paste a base64-encoding here</textarea>
</pre>
<p><input type="submit" value="Export to XLSX!" id="xport" onclick="export_xlsx();" disabled="true"></p>
<p><input type="submit" value="Export to XLSX!" id="xport" onclick="export_xlsx();"></p>
<div id="htmlout"></div>
<br />
<script src="https://unpkg.com/x-data-spreadsheet/dist/xspreadsheet.js"></script>

@ -74,28 +74,18 @@ function xtos(sdata) {
sdata.forEach(function (xws) {
var ws = {};
var rowobj = xws.rows;
var minCoord = { r: 0, c: 0 }, maxCoord = { r: 0, c: 0 };
for (var ri = 0; ri < rowobj.len; ++ri) {
var row = rowobj[ri];
if (!row) continue;
var minCoord, maxCoord;
Object.keys(row.cells).forEach(function (k) {
var idx = +k;
if (isNaN(idx)) return;
var lastRef = XLSX.utils.encode_cell({ r: ri, c: idx });
if (minCoord == null) {
minCoord = { r: ri, c: idx };
} else {
if (ri < minCoord.r) minCoord.r = ri;
if (idx < minCoord.c) minCoord.c = idx;
}
if (maxCoord == undefined) {
maxCoord = { r: ri, c: idx };
} else {
if (ri > maxCoord.r) maxCoord.r = ri;
if (idx > maxCoord.c) maxCoord.c = idx;
}
if (ri > maxCoord.r) maxCoord.r = ri;
if (idx > maxCoord.c) maxCoord.c = idx;
var cellText = row.cells[k].text, type = "s";
if (!cellText) {
@ -127,12 +117,11 @@ function xtos(sdata) {
});
}
});
ws["!ref"] = XLSX.utils.encode_range({
s: { r: minCoord.r, c: minCoord.c },
e: { r: maxCoord.r, c: maxCoord.c }
});
}
ws["!ref"] = minCoord ? XLSX.utils.encode_range({
s: minCoord,
e: maxCoord
}) : "A1";
XLSX.utils.book_append_sheet(out, ws, xws.name);
});

@ -110,6 +110,14 @@ version and will refresh on each release.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-<version>.tgz`) for the desired version.

@ -217,6 +217,14 @@ version and will refresh on each release.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-<version>.tgz`) for the desired version.