Skip to content

Commit a91dcef

Browse files
committed
Merge branch 'master' into fix-hidden
2 parents 0149879 + c44398b commit a91dcef

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ module.exports = function(grunt) {
6161
sourceMap: true,
6262
output: {
6363
preamble: '/*! ExcelJS <%= grunt.template.today("dd-mm-yyyy") %> */\n',
64+
ascii_only: true,
6465
},
65-
ascii_only: true
6666
},
6767
dist: {
6868
files: {

lib/stream/xlsx/worksheet-writer.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const PageSetupXform = require('../../xlsx/xform/sheet/page-setup-xform');
3131
const AutoFilterXform = require('../../xlsx/xform/sheet/auto-filter-xform');
3232
const PictureXform = require('../../xlsx/xform/sheet/picture-xform');
3333
const ConditionalFormattingsXform = require('../../xlsx/xform/sheet/cf/conditional-formattings-xform');
34+
const RowBreaksXform = require('../../xlsx/xform/sheet/row-breaks-xform');
3435

3536
// since prepare and render are functional, we can use singletons
3637
const xform = {
@@ -47,6 +48,7 @@ const xform = {
4748
autoFilter: new AutoFilterXform(),
4849
picture: new PictureXform(),
4950
conditionalFormattings: new ConditionalFormattingsXform(),
51+
rowBreaks: new RowBreaksXform(),
5052
};
5153

5254
// ============================================================================================
@@ -72,7 +74,7 @@ class WorksheetWriter {
7274
// column keys (addRow convenience): key ==> this._columns index
7375
this._keys = {};
7476

75-
// keep record of all merges
77+
// keep a record of all row and column pageBreaks
7678
this._merges = [];
7779
this._merges.add = function() {}; // ignore cell instruction
7880

@@ -100,6 +102,9 @@ class WorksheetWriter {
100102
// keep a record of conditionalFormattings
101103
this.conditionalFormatting = [];
102104

105+
// keep a record of all row and column pageBreaks
106+
this.rowBreaks = [];
107+
103108
// for default row height, outline levels, etc
104109
this.properties = Object.assign(
105110
{},
@@ -214,6 +219,7 @@ class WorksheetWriter {
214219
this._writePageMargins();
215220
this._writePageSetup();
216221
this._writeBackground();
222+
this._writeRowBreaks();
217223

218224
// Legacy Data tag for comments
219225
this._writeLegacyData();
@@ -580,6 +586,10 @@ class WorksheetWriter {
580586
this.stream.write(xform.conditionalFormattings.toXml(this.conditionalFormatting));
581587
}
582588

589+
_writeRowBreaks() {
590+
this.stream.write(xform.rowBreaks.toXml(this.rowBreaks));
591+
}
592+
583593
_writeDataValidations() {
584594
this.stream.write(xform.dataValidations.toXml(this.dataValidations.model));
585595
}

spec/integration/worksheet-xlsx-writer.spec.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const testutils = require('./../utils/index');
1+
const testutils = require('../utils/index');
22

33
const ExcelJS = verquire('exceljs');
44

@@ -514,4 +514,25 @@ describe('WorksheetWriter', () => {
514514
}).to.throw(Error);
515515
});
516516
});
517+
518+
describe('Page Breaks', () => {
519+
it('adds multiple row breaks', () => {
520+
const wb = new ExcelJS.stream.xlsx.WorkbookWriter();
521+
const ws = wb.addWorksheet('blort');
522+
523+
// initial values
524+
ws.getCell('A1').value = 'A1';
525+
ws.getCell('B1').value = 'B1';
526+
ws.getCell('A2').value = 'A2';
527+
ws.getCell('B2').value = 'B2';
528+
ws.getCell('A3').value = 'A3';
529+
ws.getCell('B3').value = 'B3';
530+
531+
let row = ws.getRow(1);
532+
row.addPageBreak();
533+
row = ws.getRow(2);
534+
row.addPageBreak();
535+
expect(ws.rowBreaks.length).to.equal(2);
536+
});
537+
});
517538
});

0 commit comments

Comments
 (0)