Skip to content
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

Style ignored on empty cells #7

Closed
azukaar opened this issue Aug 10, 2015 · 2 comments
Closed

Style ignored on empty cells #7

azukaar opened this issue Aug 10, 2015 · 2 comments

Comments

@azukaar
Copy link

azukaar commented Aug 10, 2015

In the XLSX files, the empty cells are skipped, but they are skipped even if they hold style informations.
I think they shouldn't be skipped in this case as they still hold relevant information, plus, importing + exporting an excel file without changing it should be an idempotent operation.

See : #8

@protobi
Copy link
Collaborator

protobi commented Aug 11, 2015

The changes you proposed in the pull request #7 are made to the source files under bits and compiled. There is a new test in tests\test-styles.js that verifies styles in blank cells persist round trip. Changes are merged into the beta branch (https://github.com/protobi/js-xlsx#beta), tagged as version 0.8.6 and published to npm and bower.

describe('styles with blank cells', function () {
  it ('retains styles with blank cells', function() {


    var OUTFILE = '/tmp/ex1.xlsx';
    var OUTFILE2 = '/tmp/ex1a.xlsx';

    var workbook = {
      SheetNames : ["Sheet1"],
      Sheets: {
        "Sheet1": {
          "B2": {v: "Top left", s: { border: { top: { style: 'medium', color: { rgb: "FFFFAA00"}}, left: { style: 'medium', color: { rgb: "FFFFAA00"}} }}},
          "C2": {v: "Top right", s: { border: { top: { style: 'medium', color: { rgb: "FFFFAA00"}}, right: { style: 'medium', color: { rgb: "FFFFAA00"}} }}},
          "B3": {v: "Bottom left", s: { border: { bottom: { style: 'medium', color: { rgb: "FFFFAA00"}}, left: { style: 'medium', color: { rgb: "FFFFAA00"}} }}},
          "C3": {v: "", s: { border: { bottom: { style: 'medium', color: { rgb: "FFFFAA00"}}, right: { style: 'medium', color: { rgb: "FFFFAA00"}} }}},
          "!ref":"B2:C3"
        }
      }
    };

    // write the file and read it back...
    XLSX.writeFile(workbook, OUTFILE, {bookType: 'xlsx', bookSST: false});
    var workbook2 = XLSX.readFile(OUTFILE, {cellStyles: true});
    assert(basicallyEquals(workbook.Sheets, workbook2.Sheets));

    XLSX.writeFile(workbook2, OUTFILE2, {bookType: 'xlsx', bookSST: false});
    var workbook3 = XLSX.readFile(OUTFILE2, {cellStyles: true});
    assert(basicallyEquals(workbook.Sheets, workbook3.Sheets))
  });
});

@protobi protobi closed this as completed Aug 11, 2015
@azukaar
Copy link
Author

azukaar commented Aug 12, 2015

Nice, perfect

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

No branches or pull requests

1 participant