Add row/col breaks

This commit is contained in:
Pieter Sheth-Voss 2015-12-04 21:02:05 -05:00
parent 2886195440
commit bbeec3edfd
2 changed files with 70 additions and 0 deletions

@ -70,6 +70,17 @@ function write_ws_xml_merges(merges) {
return o + '</mergeCells>';
}
//<pageSetup scale="90" orientation="portrait" horizontalDpi="4294967292" verticalDpi="4294967292"/>
//<rowBreaks count="1" manualBreakCount="1">
// <brk id="8" max="16383" man="1"/>
//</rowBreaks>
//<colBreaks count="1" manualBreakCount="1">
// <brk id="8" max="1048575" man="1"/>
//</colBreaks>
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] = ('</worksheet>'); 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<breaks.length; i++) {
var thisBreak = ''+ (breaks[i]);
var nextBreak = '' + (breaks[i+1] || '16383');
brk.push(writextag('brk', null, {id: thisBreak, max: nextBreak, man: '1'}))
}
return writextag('rowBreaks', brk.join(' '), {count: brk.length, manualBreakCount: brk.length})
}
function write_ws_xml_col_breaks(breaks) {
console.log("Writing breaks");
var brk = [];
for (var i=0; i<breaks.length; i++) {
var thisBreak = ''+ (breaks[i]);
var nextBreak = '' + (breaks[i+1] || '16383');
brk.push(writextag('brk', null, {id: thisBreak, max: nextBreak, man: '1'}))
}
return writextag('colBreaks', brk.join(' '), {count: brk.length, manualBreakCount: brk.length})
}

35
xlsx.js

@ -7595,6 +7595,17 @@ function write_ws_xml_merges(merges) {
return o + '</mergeCells>';
}
//<pageSetup scale="90" orientation="portrait" horizontalDpi="4294967292" verticalDpi="4294967292"/>
//<rowBreaks count="1" manualBreakCount="1">
// <brk id="8" max="16383" man="1"/>
//</rowBreaks>
//<colBreaks count="1" manualBreakCount="1">
// <brk id="8" max="1048575" man="1"/>
//</colBreaks>
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,34 @@ 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] = ('</worksheet>'); 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<breaks.length; i++) {
var thisBreak = ''+ (breaks[i]);
var nextBreak = '' + (breaks[i+1] || '16383');
brk.push(writextag('brk', null, {id: thisBreak, max: nextBreak, man: '1'}))
}
return writextag('rowBreaks', brk.join(' '), {count: brk.length, manualBreakCount: brk.length})
}
function write_ws_xml_col_breaks(breaks) {
console.log("Writing breaks");
var brk = [];
for (var i=0; i<breaks.length; i++) {
var thisBreak = ''+ (breaks[i]);
var nextBreak = '' + (breaks[i+1] || '16383');
brk.push(writextag('brk', null, {id: thisBreak, max: nextBreak, man: '1'}))
}
return writextag('colBreaks', brk.join(' '), {count: brk.length, manualBreakCount: brk.length})
}
/* [MS-XLSB] 2.4.718 BrtRowHdr */
function parse_BrtRowHdr(data, length) {
var z = [];