Skip to content

Commit

Permalink
version bump 0.11.15: right-to-left write
Browse files Browse the repository at this point in the history
- XLSX right-to-left support (fixes SheetJS#927 h/t @mghayour)
- HTML string preserve newline (fixes SheetJS#929 h/t @Irikos)
  • Loading branch information
SheetJSDev committed Dec 25, 2017
1 parent 028d701 commit 33f96fc
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docbits/* linguist-documentation
dist/* linguist-generated=true
xlsx.js linguist-generated=true
xlsxworker.js linguist-generated=true
tests/core.js linguist-generated=true
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ tmp
*.[pP][rR][nN]
*.[sS][lL][kK]
*.socialcalc
*.[xX][lL][sSwWcC]
*.[xX][lL][sS][xXmMbB]
*.[xX][lL][sSwWcCaAtT]
*.[xX][lL][sSaAtT][xXmMbB]
*.[oO][dD][sS]
*.[fF][oO][dD][sS]
*.[xX][mM][lL]
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.11.14';
XLSX.version = '0.11.15';
1 change: 1 addition & 0 deletions bits/30_ctype.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ var CT_LIST = (function(){
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
xlsm: "application/vnd.ms-excel.sheet.macroEnabled.main+xml",
xlsb: "application/vnd.ms-excel.sheet.binary.macroEnabled.main",
xlam: "application/vnd.ms-excel.addin.macroEnabled.main+xml",
xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
},
strs: { /* Shared Strings */
Expand Down
5 changes: 4 additions & 1 deletion bits/67_wsxml.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ function write_ws_xml_autofilter(data)/*:string*/ {
/* 18.3.1.88 sheetViews CT_SheetViews */
/* 18.3.1.87 sheetView CT_SheetView */
function write_ws_xml_sheetviews(ws, opts, idx, wb)/*:string*/ {
return writextag("sheetViews", writextag("sheetView", null, {workbookViewId:"0"}), {});
var sview = {workbookViewId:"0"};
// $FlowIgnore
if( (((wb||{}).Workbook||{}).Views||[])[0] ) sview.rightToLeft = wb.Workbook.Views[0].RTL ? "1" : "0";
return writextag("sheetViews", writextag("sheetView", null, sview), {});
}

function write_ws_xml_cell(cell, ref, ws, opts, idx, wb) {
Expand Down
13 changes: 8 additions & 5 deletions bits/68_wsbin.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,12 @@ function write_BrtMargins(margins/*:Margins*/, o) {
}

/* [MS-XLSB] 2.4.292 BrtBeginWsView */
function write_BrtBeginWsView(ws, o) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
o.write_shift(2, 924); // bit flag
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);
o.write_shift(4, 0); // view first row
o.write_shift(4, 0); // view first col
Expand Down Expand Up @@ -748,11 +751,11 @@ function write_AUTOFILTER(ba, ws) {
write_record(ba, "BrtEndAFilter");
}

function write_WSVIEWS2(ba, ws) {
function write_WSVIEWS2(ba, ws, Workbook) {
write_record(ba, "BrtBeginWsViews");
{ /* 1*WSVIEW2 */
/* [ACUID] */
write_record(ba, "BrtBeginWsView", write_BrtBeginWsView(ws));
write_record(ba, "BrtBeginWsView", write_BrtBeginWsView(ws, Workbook));
/* [BrtPane] */
/* *4BrtSel */
/* *4SXSELECT */
Expand Down Expand Up @@ -785,7 +788,7 @@ function write_ws_bin(idx/*:number*/, opts, wb/*:Workbook*/, rels) {
write_record(ba, "BrtBeginSheet");
write_record(ba, "BrtWsProp", write_BrtWsProp(c));
write_record(ba, "BrtWsDim", write_BrtWsDim(r));
write_WSVIEWS2(ba, ws);
write_WSVIEWS2(ba, ws, wb.Workbook);
write_WSFMTINFO(ba, ws);
write_COLINFOS(ba, ws, idx, opts, wb);
write_CELLTABLE(ba, ws, idx, opts, wb);
Expand Down
1 change: 0 additions & 1 deletion bits/79_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var HTML_ = (function() {
var m = cell, cc = 0;
/* TODO: parse styles etc */
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
while(m.indexOf(">") > -1) m = m.slice(0, m.lastIndexOf("<"));
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
CS = tag.colspan ? +tag.colspan : 1;
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
Expand Down
16 changes: 8 additions & 8 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: 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.

24 changes: 15 additions & 9 deletions dist/xlsx.js

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

22 changes: 11 additions & 11 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.11.14",
"version": "0.11.15",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [
Expand Down
5 changes: 5 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,11 @@ describe('HTML', function() {
it('should interpret values by default', function() { plaintext_test(X.read(html_bstr, {type:"binary"}), false, false); });
it('should generate strings if raw option is passed', function() { plaintext_test(X.read(html_bstr, {type:"binary", raw:true}), true, false); });
it('should handle "string" type', function() { plaintext_test(X.read(html_str, {type:"string"}), false, false); });
it('should handle newlines correctly', function() {
var table = "<table><tr><td>foo<br/>bar</td><td>baz</td></tr></table>";
var wb = X.read(table, {type:"string"});
assert.equal(get_cell(wb.Sheets.Sheet1, "A1").v, "foo\nbar");
});
});
(domtest ? describe : describe.skip)('input DOM', function() {
it('should interpret values by default', function() { plaintext_test(X.utils.table_to_book(get_dom_element(html_str)), false, true); });
Expand Down
5 changes: 5 additions & 0 deletions tests/core.js

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

1 change: 1 addition & 0 deletions tests/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ ws['!protect'] = {
if(!wb.Workbook) wb.Workbook = {Sheets:[], WBProps:{}};
if(!wb.Workbook.WBProps) wb.Workbook.WBProps = {};
wb.Workbook.WBProps.filterPrivacy = true;
//wb.Workbook.Views = [{RTL:true}];

console.log("Worksheet Model:");
console.log(ws);
Expand Down
3 changes: 3 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export interface WBProps {
/** Defined Names */
Names?: DefinedName[];

/** Workbook Views */
Views?: any[];

/** Other Workbook Properties */
WBProps?: WorkbookProperties;
}
Expand Down
1 change: 1 addition & 0 deletions types/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ ws['!protect'] = {
if(!wb.Workbook) wb.Workbook = {Sheets:[], WBProps:{}};
if(!wb.Workbook.WBProps) wb.Workbook.WBProps = {};
wb.Workbook.WBProps.filterPrivacy = true;
wb.Workbook.Views = [{RTL:true}];

console.log("Worksheet Model:");
console.log(ws);
Expand Down
22 changes: 14 additions & 8 deletions xlsx.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.11.14';
XLSX.version = '0.11.15';
var current_codepage = 1200;
/*:: declare var cptable:any; */
/*global cptable:true */
Expand Down Expand Up @@ -3468,6 +3468,7 @@ var CT_LIST = (function(){
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
xlsm: "application/vnd.ms-excel.sheet.macroEnabled.main+xml",
xlsb: "application/vnd.ms-excel.sheet.binary.macroEnabled.main",
xlam: "application/vnd.ms-excel.addin.macroEnabled.main+xml",
xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
},
strs: { /* Shared Strings */
Expand Down Expand Up @@ -11836,7 +11837,10 @@ function write_ws_xml_autofilter(data)/*:string*/ {
/* 18.3.1.88 sheetViews CT_SheetViews */
/* 18.3.1.87 sheetView CT_SheetView */
function write_ws_xml_sheetviews(ws, opts, idx, wb)/*:string*/ {
return writextag("sheetViews", writextag("sheetView", null, {workbookViewId:"0"}), {});
var sview = {workbookViewId:"0"};
// $FlowIgnore
if( (((wb||{}).Workbook||{}).Views||[])[0] ) sview.rightToLeft = wb.Workbook.Views[0].RTL ? "1" : "0";
return writextag("sheetViews", writextag("sheetView", null, sview), {});
}

function write_ws_xml_cell(cell, ref, ws, opts, idx, wb) {
Expand Down Expand Up @@ -12534,9 +12538,12 @@ function write_BrtMargins(margins/*:Margins*/, o) {
}

/* [MS-XLSB] 2.4.292 BrtBeginWsView */
function write_BrtBeginWsView(ws, o) {
function write_BrtBeginWsView(ws, Workbook, o) {
if(o == null) o = new_buf(30);
o.write_shift(2, 924); // bit flag
var f = 0x39c;
// $FlowIgnore
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
o.write_shift(2, f); // bit flag
o.write_shift(4, 0);
o.write_shift(4, 0); // view first row
o.write_shift(4, 0); // view first col
Expand Down Expand Up @@ -12947,11 +12954,11 @@ function write_AUTOFILTER(ba, ws) {
write_record(ba, "BrtEndAFilter");
}

function write_WSVIEWS2(ba, ws) {
function write_WSVIEWS2(ba, ws, Workbook) {
write_record(ba, "BrtBeginWsViews");
{ /* 1*WSVIEW2 */
/* [ACUID] */
write_record(ba, "BrtBeginWsView", write_BrtBeginWsView(ws));
write_record(ba, "BrtBeginWsView", write_BrtBeginWsView(ws, Workbook));
/* [BrtPane] */
/* *4BrtSel */
/* *4SXSELECT */
Expand Down Expand Up @@ -12984,7 +12991,7 @@ function write_ws_bin(idx/*:number*/, opts, wb/*:Workbook*/, rels) {
write_record(ba, "BrtBeginSheet");
write_record(ba, "BrtWsProp", write_BrtWsProp(c));
write_record(ba, "BrtWsDim", write_BrtWsDim(r));
write_WSVIEWS2(ba, ws);
write_WSVIEWS2(ba, ws, wb.Workbook);
write_WSFMTINFO(ba, ws);
write_COLINFOS(ba, ws, idx, opts, wb);
write_CELLTABLE(ba, ws, idx, opts, wb);
Expand Down Expand Up @@ -17436,7 +17443,6 @@ var HTML_ = (function() {
var m = cell, cc = 0;
/* TODO: parse styles etc */
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
while(m.indexOf(">") > -1) m = m.slice(0, m.lastIndexOf("<"));
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
CS = tag.colspan ? +tag.colspan : 1;
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
Expand Down
22 changes: 14 additions & 8 deletions xlsx.js

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

0 comments on commit 33f96fc

Please sign in to comment.