Fixed functions demos #2025
17
README.md
17
README.md
@ -2140,14 +2140,15 @@ For the example sheet:
|
||||
As an alternative to the `writeFile` CSV type, `XLSX.utils.sheet_to_csv` also
|
||||
produces CSV output. The function takes an options argument:
|
||||
|
||||
| Option Name | Default | Description |
|
||||
| :---------- | :------: | :-------------------------------------------------- |
|
||||
|`FS` | `","` | "Field Separator" delimiter between fields |
|
||||
|`RS` | `"\n"` | "Record Separator" delimiter between rows |
|
||||
|`dateNF` | FMT 14 | Use specified date format in string output |
|
||||
|`strip` | false | Remove trailing field separators in each record ** |
|
||||
|`blankrows` | true | Include blank lines in the CSV output |
|
||||
|`skipHidden` | false | Skips hidden rows/columns in the CSV output |
|
||||
| Option Name | Default | Description |
|
||||
| :----------- | :------: | :-------------------------------------------------- |
|
||||
|`FS` | `","` | "Field Separator" delimiter between fields |
|
||||
|`RS` | `"\n"` | "Record Separator" delimiter between rows |
|
||||
|`dateNF` | FMT 14 | Use specified date format in string output |
|
||||
|`strip` | false | Remove trailing field separators in each record ** |
|
||||
|`blankrows` | true | Include blank lines in the CSV output |
|
||||
|`skipHidden` | false | Skips hidden rows/columns in the CSV output |
|
||||
|`forceQuotes` | false | Force quotes around fields |
|
||||
|
||||
- `strip` will remove trailing commas from each line under default `FS/RS`
|
||||
- `blankrows` must be set to `false` to skip blank lines.
|
||||
|
@ -55,6 +55,7 @@ var dbf_reverse_map = evert({
|
||||
/*::[*/0xCA/*::]*/: 1254, /*::[*/0xCB/*::]*/: 1253,
|
||||
/*::[*/0x00/*::]*/: 20127
|
||||
});
|
||||
var DBF_SUPPORTED_VERSIONS = [0x02, 0x03, 0x30, 0x31, 0x83, 0x8B, 0x8C, 0xF5];
|
||||
/* TODO: find an actual specification */
|
||||
function dbf_to_aoa(buf, opts)/*:AOA*/ {
|
||||
var out/*:AOA*/ = [];
|
||||
@ -308,6 +309,7 @@ function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
|
||||
return ba.end();
|
||||
}
|
||||
return {
|
||||
versions: DBF_SUPPORTED_VERSIONS,
|
||||
to_workbook: dbf_to_workbook,
|
||||
to_sheet: dbf_to_sheet,
|
||||
from_sheet: sheet_to_dbf
|
||||
@ -820,7 +822,7 @@ var PRN = (function() {
|
||||
}
|
||||
// If line ends in \r OR \n
|
||||
else if(str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10 ) {
|
||||
//
|
||||
//
|
||||
sep = str.charAt(4); str = str.slice(6);
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
case 0x7B: if(n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o); break;
|
||||
case 0x0A: case 0x0D: case 0x20: return read_plaintext_raw(d, o);
|
||||
}
|
||||
if(n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
if(DBF.versions.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
return read_prn(data, d, o, str);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ function make_csv_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Arr
|
||||
else if(val.v != null) {
|
||||
isempty = false;
|
||||
txt = ''+format_cell(val, null, o);
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
if(txt == "ID") txt = '"ID"';
|
||||
} else if(val.f != null && !val.F) {
|
||||
isempty = false;
|
||||
|
@ -53,7 +53,7 @@ The exported `read` and `readFile` functions accept an options argument:
|
||||
for files employing other encryption methods.
|
||||
- WTF is mainly for development. By default, the parser will suppress read
|
||||
errors on single worksheets, allowing you to read from the worksheets that do
|
||||
parse properly. Setting `WTF:1` forces those errors to be thrown.
|
||||
parse properly. Setting `WTF:true` forces those errors to be thrown.
|
||||
|
||||
### Input Type
|
||||
|
||||
|
1
jszip.js
1
jszip.js
@ -17,6 +17,7 @@ Note: since JSZip 3 removed critical functionality, this version assigns to the
|
||||
else if("function"==typeof define&&define.amd&&"undefined"==typeof DO_NOT_EXPORT_JSZIP){JSZipSync=e();define([],e);}
|
||||
else{
|
||||
var f;
|
||||
"undefined"!=typeof globalThis?f=globalThis:
|
||||
"undefined"!=typeof window?f=window:
|
||||
"undefined"!=typeof global?f=global:
|
||||
"undefined"!=typeof $ && $.global?f=$.global:
|
||||
|
3
types/index.d.ts
vendored
3
types/index.d.ts
vendored
@ -623,6 +623,9 @@ export interface Sheet2CSVOpts extends DateNFOption {
|
||||
|
||||
/** Skip hidden rows and columns in the CSV output */
|
||||
skipHidden?: boolean;
|
||||
|
||||
/** Force quotes around fields */
|
||||
forceQuotes?: boolean;
|
||||
}
|
||||
|
||||
export interface OriginOption {
|
||||
|
@ -6914,6 +6914,7 @@ var dbf_reverse_map = evert({
|
||||
/*::[*/0xCA/*::]*/: 1254, /*::[*/0xCB/*::]*/: 1253,
|
||||
/*::[*/0x00/*::]*/: 20127
|
||||
});
|
||||
var DBF_SUPPORTED_VERSIONS = [0x02, 0x03, 0x30, 0x31, 0x83, 0x8B, 0x8C, 0xF5];
|
||||
/* TODO: find an actual specification */
|
||||
function dbf_to_aoa(buf, opts)/*:AOA*/ {
|
||||
var out/*:AOA*/ = [];
|
||||
@ -7167,6 +7168,7 @@ function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
|
||||
return ba.end();
|
||||
}
|
||||
return {
|
||||
versions: DBF_SUPPORTED_VERSIONS,
|
||||
to_workbook: dbf_to_workbook,
|
||||
to_sheet: dbf_to_sheet,
|
||||
from_sheet: sheet_to_dbf
|
||||
@ -7679,7 +7681,7 @@ var PRN = (function() {
|
||||
}
|
||||
// If line ends in \r OR \n
|
||||
else if(str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10 ) {
|
||||
//
|
||||
//
|
||||
sep = str.charAt(4); str = str.slice(6);
|
||||
}
|
||||
}
|
||||
@ -20950,7 +20952,7 @@ function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
case 0x7B: if(n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o); break;
|
||||
case 0x0A: case 0x0D: case 0x20: return read_plaintext_raw(d, o);
|
||||
}
|
||||
if(n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
if(DBF.versions.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
return read_prn(data, d, o, str);
|
||||
}
|
||||
|
||||
@ -21211,7 +21213,7 @@ function make_csv_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Arr
|
||||
else if(val.v != null) {
|
||||
isempty = false;
|
||||
txt = ''+format_cell(val, null, o);
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
if(txt == "ID") txt = '"ID"';
|
||||
} else if(val.f != null && !val.F) {
|
||||
isempty = false;
|
||||
|
8
xlsx.js
generated
8
xlsx.js
generated
@ -6817,6 +6817,7 @@ var dbf_reverse_map = evert({
|
||||
0xCA: 1254, 0xCB: 1253,
|
||||
0x00: 20127
|
||||
});
|
||||
var DBF_SUPPORTED_VERSIONS = [0x02, 0x03, 0x30, 0x31, 0x83, 0x8B, 0x8C, 0xF5];
|
||||
/* TODO: find an actual specification */
|
||||
function dbf_to_aoa(buf, opts) {
|
||||
var out = [];
|
||||
@ -7069,6 +7070,7 @@ function sheet_to_dbf(ws, opts) {
|
||||
return ba.end();
|
||||
}
|
||||
return {
|
||||
versions: DBF_SUPPORTED_VERSIONS,
|
||||
to_workbook: dbf_to_workbook,
|
||||
to_sheet: dbf_to_sheet,
|
||||
from_sheet: sheet_to_dbf
|
||||
@ -7581,7 +7583,7 @@ var PRN = (function() {
|
||||
}
|
||||
// If line ends in \r OR \n
|
||||
else if(str.charCodeAt(5) == 13 || str.charCodeAt(5) == 10 ) {
|
||||
//
|
||||
//
|
||||
sep = str.charAt(4); str = str.slice(6);
|
||||
}
|
||||
}
|
||||
@ -20826,7 +20828,7 @@ function readSync(data, opts) {
|
||||
case 0x7B: if(n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o); break;
|
||||
case 0x0A: case 0x0D: case 0x20: return read_plaintext_raw(d, o);
|
||||
}
|
||||
if(n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
if(DBF.versions.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
return read_prn(data, d, o, str);
|
||||
}
|
||||
|
||||
@ -21080,7 +21082,7 @@ function make_csv_row(sheet, r, R, cols, fs, rs, FS, o) {
|
||||
else if(val.v != null) {
|
||||
isempty = false;
|
||||
txt = ''+format_cell(val, null, o);
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
if(txt == "ID") txt = '"ID"';
|
||||
} else if(val.f != null && !val.F) {
|
||||
isempty = false;
|
||||
|
@ -8135,7 +8135,7 @@ function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
case 0x7B: if(n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o); break;
|
||||
case 0x0A: case 0x0D: case 0x20: return read_plaintext_raw(d, o);
|
||||
}
|
||||
if(n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
if(DBF.versions.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
return read_prn(data, d, o, str);
|
||||
}
|
||||
|
||||
@ -8396,7 +8396,7 @@ function make_csv_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Arr
|
||||
else if(val.v != null) {
|
||||
isempty = false;
|
||||
txt = ''+format_cell(val, null, o);
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
if(txt == "ID") txt = '"ID"';
|
||||
} else if(val.f != null && !val.F) {
|
||||
isempty = false;
|
||||
|
@ -8038,7 +8038,7 @@ function readSync(data, opts) {
|
||||
case 0x7B: if(n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o); break;
|
||||
case 0x0A: case 0x0D: case 0x20: return read_plaintext_raw(d, o);
|
||||
}
|
||||
if(n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
if(DBF.versions.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);
|
||||
return read_prn(data, d, o, str);
|
||||
}
|
||||
|
||||
@ -8292,7 +8292,7 @@ function make_csv_row(sheet, r, R, cols, fs, rs, FS, o) {
|
||||
else if(val.v != null) {
|
||||
isempty = false;
|
||||
txt = ''+format_cell(val, null, o);
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
for(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
||||
if(txt == "ID") txt = '"ID"';
|
||||
} else if(val.f != null && !val.F) {
|
||||
isempty = false;
|
||||
|
Loading…
Reference in New Issue
Block a user