Skip to content

Commit

Permalink
version bump 0.13.5: HTML newlines
Browse files Browse the repository at this point in the history
- HTML Export emits `<br/>` (fixes SheetJS#1239 h/t @keithbox)
- Unicode Defined Name ODS
  • Loading branch information
SheetJSDev committed Aug 25, 2018
1 parent d01e10c commit eca6b45
Show file tree
Hide file tree
Showing 22 changed files with 166 additions and 84 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This log is intended to keep track of backwards-incompatible changes, including
but not limited to API changes and file location changes. Minor behavioral
changes may not be included if they are not expected to break existing code.

## 0.13.5 (2018-07-25)

* HTML output generates `<br/>` instead of encoded newline character

## 0.13.2 (2018-07-08)

* Buffer.from shim replaced, will not be defined in node `<=0.12`
Expand Down
2 changes: 1 addition & 1 deletion bits/01_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
XLSX.version = '0.13.4';
XLSX.version = '0.13.5';
2 changes: 1 addition & 1 deletion bits/22_xmlutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function escapexmltag(text/*:string*/)/*:string*/{ return escapexml(text).replac
var htmlcharegex = /[\u0000-\u001f]/g;
function escapehtml(text/*:string*/)/*:string*/{
var s = text + '';
return s.replace(decregex, function(y) { return rencoding[y]; }).replace(htmlcharegex,function(s) { return "&#x" + ("000"+s.charCodeAt(0).toString(16)).slice(-4) + ";"; });
return s.replace(decregex, function(y) { return rencoding[y]; }).replace(/\n/g, "<br/>").replace(htmlcharegex,function(s) { return "&#x" + ("000"+s.charCodeAt(0).toString(16)).slice(-4) + ";"; });
}

function escapexlml(text/*:string*/)/*:string*/{
Expand Down
2 changes: 1 addition & 1 deletion bits/75_xlml.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ function write_ws_xlml_names(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbo
/*:: if(!wb || !wb.Workbook || !wb.Workbook.Names) throw new Error("unreachable"); */
var names/*:Array<any>*/ = wb.Workbook.Names;
var out/*:Array<string>*/ = [];
outer: for(var i = 0; i < names.length; ++i) {
for(var i = 0; i < names.length; ++i) {
var n = names[i];
if(n.Sheet != idx) continue;
/*switch(n.Name) {
Expand Down
8 changes: 3 additions & 5 deletions bits/79_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ var HTML_ = (function() {
function make_html_row(ws/*:Worksheet*/, r/*:Range*/, R/*:number*/, o/*:Sheet2HTMLOpts*/)/*:string*/ {
var M/*:Array<Range>*/ = (ws['!merges'] ||[]);
var oo/*:Array<string>*/ = [];
var nullcell = "<td>" + (o.editable ? '<span contenteditable="true"></span>' : "" ) + "</td>";
for(var C = r.s.c; C <= r.e.c; ++C) {
var RS = 0, CS = 0;
for(var j = 0; j < M.length; ++j) {
Expand All @@ -70,13 +69,12 @@ var HTML_ = (function() {
if(RS < 0) continue;
var coord = encode_cell({r:R,c:C});
var cell = o.dense ? (ws[R]||[])[C] : ws[coord];
if(!cell || cell.v == null) { oo.push(nullcell); continue; }
/* TODO: html entities */
var w = cell.h || escapexml(cell.w || (format_cell(cell), cell.w) || "");
var sp = {};
if(RS > 1) sp.rowspan = RS;
if(CS > 1) sp.colspan = CS;
sp.t = cell.t;
/* TODO: html entities */
var w = (cell && cell.v != null) && (cell.h || escapehtml(cell.w || (format_cell(cell), cell.w) || "")) || "";
sp.t = cell && cell.t || 'z';
if(o.editable) w = '<span contenteditable="true">' + w + '</span>';
sp.id = "sjs-" + coord;
oo.push(writextag('td', w, sp));
Expand Down
2 changes: 1 addition & 1 deletion bits/80_parseods.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var parse_content_xml = (function() {
}
if(merges.length) ws['!merges'] = merges;
if(rowinfo.length) ws["!rows"] = rowinfo;
sheetag.name = utf8read(sheetag['名称'] || sheetag.name);
sheetag.name = sheetag['名称'] || sheetag.name;
if(typeof JSON !== 'undefined') JSON.stringify(sheetag);
SheetNames.push(sheetag.name);
Sheets[sheetag.name] = ws;
Expand Down
12 changes: 6 additions & 6 deletions dist/xlsx.core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xlsx.core.min.map

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions dist/xlsx.extendscript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions dist/xlsx.full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xlsx.full.min.map

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions dist/xlsx.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions dist/xlsx.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xlsx.min.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.13.4",
"version": "0.13.5",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [
Expand Down
41 changes: 40 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ var paths = {
dnsxlsx: dir + 'defined_names_simple.xlsx',
dnsxlsb: dir + 'defined_names_simple.xlsb',

dnuxls: dir + 'defined_names_unicode.xls',
dnuxml: dir + 'defined_names_unicode.xml',
dnuods: dir + 'defined_names_unicode.ods',
dnuxlsx: dir + 'defined_names_unicode.xlsx',
dnuxlsb: dir + 'defined_names_unicode.xlsb',

dtxls: dir + 'xlsx-stream-d-date-cell.xls',
dtxml: dir + 'xlsx-stream-d-date-cell.xls.xml',
dtxlsx: dir + 'xlsx-stream-d-date-cell.xlsx',
Expand Down Expand Up @@ -1154,6 +1160,39 @@ describe('parse features', function() {
assert.equal(names[i].Ref, "Sheet1!$A$2");
}); }); });

describe('defined names unicode', function() {[
/* desc path */
['xlsx', paths.dnuxlsx],
['xlsb', paths.dnuxlsb],
['ods', paths.dnuods ],
['xls', paths.dnuxls ],
['xlml', paths.dnuxml ]
].forEach(function(m) { it(m[0], function() {
var wb = X.read(fs.readFileSync(m[1]), {type:TYPE});
[
"NoContainsJapanese",
"\u65E5\u672C\u8a9e\u306e\u307f",
"sheet\u65e5\u672c\u8a9e",
"\u65e5\u672c\u8a9esheet",
"sheet\u65e5\u672c\u8a9esheet"
].forEach(function(n, i) { assert.equal(wb.SheetNames[i], n); });
[
["name\u65e5\u672c\u8a9e", "sheet\u65e5\u672c\u8a9e!$A$1"],
["name\u65e5\u672c\u8a9ename", "sheet\u65e5\u672c\u8a9esheet!$B$2"],
["NoContainsJapaneseName", "\u65e5\u672c\u8a9e\u306e\u307f!$A$1"],
["sheet\u65e5\u672c\u8a9e", "sheet\u65e5\u672c\u8a9e!$A$1"],
["\u65e5\u672c\u8a9e", "NoContainsJapanese!$A$1"],
["\u65e5\u672c\u8a9ename", "\u65e5\u672c\u8a9esheet!$I$2"]
].forEach(function(n) {
var DN = null;
var arr = wb.Workbook.Names;
for(var j = 0; j < arr.length; ++j) if(arr[j].Name == n[0]) DN = arr[j];
assert(DN);
// $FlowIgnore
assert.equal(DN.Ref, n[1]);
});
}); }); });

describe('auto filter', function() {[
['xlsx', paths.afxlsx],
['xlsb', paths.afxlsb],
Expand Down Expand Up @@ -1185,7 +1224,7 @@ describe('parse features', function() {
assert.equal(get_cell(wb2.Sheets.Sheet1, "A2").h, "&amp;");
assert.equal(get_cell(wb2.Sheets.Sheet1, "B2").h, "&lt;");
assert.equal(get_cell(wb2.Sheets.Sheet1, "C2").h, "&gt;");
assert.equal(get_cell(wb2.Sheets.Sheet1, "D2").h, "&#x000a;");
assert.equal(get_cell(wb2.Sheets.Sheet1, "D2").h, "<br/>");
}); });
});

Expand Down
41 changes: 40 additions & 1 deletion tests/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eca6b45

Please sign in to comment.