Skip to content

Commit

Permalink
Write: Basic support for formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed May 10, 2015
1 parent 53f7f6d commit d439645
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xlsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -7388,7 +7388,10 @@ function write_ws_xml_cols(ws, cols) {
}

function write_ws_xml_cell(cell, ref, ws, opts, idx, wb) {
if(cell.v === undefined) return "";
if (cell.v === undefined && ! cell.f) {
return '';
}

var vv = "";
var oldt = cell.t, oldv = cell.v;
switch(cell.t) {
Expand All @@ -7405,7 +7408,12 @@ function write_ws_xml_cell(cell, ref, ws, opts, idx, wb) {
break;
default: vv = cell.v; break;
}
var v = writetag('v', escapexml(vv)), o = {r:ref};

var o = { r: ref },
v = cell.f ?
writetag('f', escapexml(cell.f)) :
writetag('v', escapexml(vv));

/* TODO: cell style */
var os = get_cell_style(opts.cellXfs, cell, opts);
if(os !== 0) o.s = os;
Expand Down

2 comments on commit d439645

@michaelshopsin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could someone merge this change, since formulas will not save without it?

@tarwich
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcsf or @michaelshopsin I'm willing to merge into tarwich/js-xlsx if you would like. I didn't create a PR on your behalf out of respect, since it's your code and request.

You can click here to make a pull request if you want to proceed:
tarwich/js-xlsx@master...mcsf:master

Please sign in to comment.