Skip to content

Parse page breaks #2602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Parse page breaks #2602

wants to merge 3 commits into from

Conversation

kigh-ota
Copy link
Contributor

Summary

Reads and parses page breaks into the model.
Previously #1257 added support for writing page breaks, but not for reading/parsing.

Fixes #2249.

Test plan

// Create 1.xlsx that contains a page break
const wb1 = new Excel.Workbook();
const ws1 = wb1.addWorksheet('row-breaks');
ws1.getCell('A1').value = 'A1';
ws1.getCell('A2').value = 'A2';
ws1.getCell('A3').value = 'A3';
ws1.getCell('A4').value = 'A4';
ws1.getRow(2).addPageBreak();
await wb1.xlsx.writeFile('./1.xlsx');

// Read 1.xlsx and write to 2.xlsx
const wb2 = new Excel.Workbook();
await wb2.xlsx.readFile('./1.xlsx');
console.log(wb2.getWorksheet('row-breaks').rowBreaks); // returns an array of length 1
await wb2.xlsx.writeFile('./2.xlsx');

Page Break Preview of 2.xlsx:
Screenshot 2023-11-26 at 20 15 32

I also added unit tests in worksheet-xform.spec.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] WorksheetReader did not read rowBreaks section
1 participant