From 43f569884af1625cd8c9024b3f9caa33fab60155 Mon Sep 17 00:00:00 2001 From: Pieter Sheth-Voss Date: Fri, 4 Dec 2015 20:57:48 -0500 Subject: [PATCH] Add row and column breaks --- README.md | 4 ++++ bits/67_wsxml.js | 35 +++++++++++++++++++++++++++++++++++ xlsx.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/README.md b/README.md index 3c6e273..6f98e13 100644 --- a/README.md +++ b/README.md @@ -429,6 +429,10 @@ Special worksheet keys (accessible as `worksheet[key]`, each starting with `!`): will write all cells in the merge range if they exist, so be sure that only the first cell (upper-left) in the range is set. +- `ws['!rowBreaks']`: array of row break points, e.g. `[16,32]` +- `ws['!colBreaks']`: array of col break points, e.g. `[8,16]` + + ### Workbook Object `workbook.SheetNames` is an ordered list of the sheets in the workbook diff --git a/bits/67_wsxml.js b/bits/67_wsxml.js index 937a14d..c5d1323 100644 --- a/bits/67_wsxml.js +++ b/bits/67_wsxml.js @@ -70,6 +70,17 @@ function write_ws_xml_merges(merges) { return o + ''; } +// +// +// +// +// +// +// + + + + function parse_ws_xml_hlinks(s, data, rels) { for(var i = 0; i != data.length; ++i) { var val = parsexmltag(data[i], true); @@ -313,6 +324,30 @@ function write_ws_xml(idx, opts, wb) { if(ws['!merges'] !== undefined && ws['!merges'].length > 0) o[o.length] = (write_ws_xml_merges(ws['!merges'])); + if (ws['!rowBreaks'] !== undefined) o[o.length] = write_ws_xml_row_breaks(ws['!rowBreaks']) + if (ws['!colBreaks'] !== undefined) o[o.length] = write_ws_xml_col_breaks(ws['!colBreaks']) + if(o.length>2) { o[o.length] = (''); o[1]=o[1].replace("/>",">"); } return o.join(""); } + +function write_ws_xml_row_breaks(breaks) { + console.log("Writing breaks") + var brk = []; + for (var i=0; i'; } +// +// +// +// +// +// +// + + + + function parse_ws_xml_hlinks(s, data, rels) { for(var i = 0; i != data.length; ++i) { var val = parsexmltag(data[i], true); @@ -7838,10 +7849,33 @@ function write_ws_xml(idx, opts, wb) { if(ws['!merges'] !== undefined && ws['!merges'].length > 0) o[o.length] = (write_ws_xml_merges(ws['!merges'])); + if (ws['!rowBreaks'] !== undefined) o[o.length] = write_ws_xml_row_breaks(ws['!rowBreaks']) + if (ws['!colBreaks'] !== undefined) o[o.length] = write_ws_xml_col_breaks(ws['!colBreaks']) + if(o.length>2) { o[o.length] = (''); o[1]=o[1].replace("/>",">"); } return o.join(""); } +function write_ws_xml_row_breaks(breaks) { + console.log("Writing breaks") + var brk = []; + for (var i=0; i