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

Retrieve shared formulas #67

Closed
wants to merge 23 commits into from
Closed

Retrieve shared formulas #67

wants to merge 23 commits into from

Conversation

Y--
Copy link

@Y-- Y-- commented May 29, 2014

Implement 18.3.1.40

Yves Le Maout added 2 commits May 27, 2014 15:37
Retrieve shared formulas according to ECMA-376, Part 1, 18.3.1.40 f
(Formula)
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) when pulling 131fa7d on Y--:master into c91e94d on SheetJS:master.

@SheetJSDev
Copy link
Contributor

@Y-- apologies for the belated reply -- busy day :/

I just added some test files. Take a look at https://github.com/SheetJS/test_files/raw/master/formulae_test_simple.xlsx -- something looks off:

> var ws = require('./').readFile('formulae_test.xlsx').Sheets.Sheet1; Object.keys(ws).filter(function(x) { return x[0] == "C" || x[0] == "D";}).forEach(function(x) { console.log(x, ws[x].f); })
C1 A1
D1 A1
C2 A2
D2 A2
C3 A2
D3 A2 
C4 A2
D4 A2
C5 A2
D5 A2
C6 A2
D6 B6

- basic style + theme parsing, option .cellStyles (h/t @eladxxx)
- more XLSB writing stubs
- correct resolution of .xml/.bin files
- sheet_to_json improvements from js-xls
o opts.header = 1 for array of arrays
o opts.header = 'A' for spreadsheet column labels
o custom opts.header array for custom labels
o opts.range = n starts from row n
o opts.range = range restricts writer to work within the specified range
- Makefile adapted to work with cygwin on windows
@Y--
Copy link
Author

Y-- commented May 30, 2014

@SheetJSDev thanks for taking a look at my PR.
You're right the current code give only the "master" formula according to specs.
We would need to "recompute" it based on it's relative position inside the shared group.
Is there any code for that in js-xlsx already?

@SheetJSDev
Copy link
Contributor

It looks like we'd need a bona-fide Excel formula parser to do this right, ideally something that converts to the parsed things format that XLS and XLSB use. The grammar for the tokens is laid out in MS-XLSB 2.5.97.88 (http://msdn.microsoft.com/en-us/library/dd946774.aspx) and MS-XLS 2.5.198.104 (http://msdn.microsoft.com/en-us/library/dd908135.aspx). I can look into this later

@Y--
Copy link
Author

Y-- commented May 30, 2014

Ok great. Should we put the master formula in a other field in the meantime ?

@SheetJSDev
Copy link
Contributor

@Y-- For now, it might make sense to add an array !shrfmla to the workbook (just like how merges are currently held) which holds the master formula as well as other relevant information.

For example, in the example, the first shared formula is:

  <c r="C2">
    <f t="shared" ref="C2:C6" si="0">A2</f>
    <v>2</v>
  </c>

In this case, we'd need to store the actual formula A2 as well as the ref C2:C6 and the original cell (the index would match the position in the shared formula array)

SheetJSDev and others added 5 commits May 31, 2014 11:44
- eliminated functional constructs in hot functions
- format try-catch block extracted into new function
- cpexcel + codepage updated to 1.2.0
- more efficient (and correct) clean implementation of RGB/HSL/tint algorithms
- xlsx binary --all option enables every extra formatting and saving option
- column widths parsed and saved (requires cellStyles:true)
- jscs linting to check for trailing comma issues (h/t @altkatz)
- IE: phased out lazy string indexing in favor of charCodeAt
- XLSX: replaced certain operations in hot functions with faster alternatives
- updated SSF to 0.7.1
- improved coverage in tests
The original push showed up as failed, pushing again
Retrieve shared formulas according to ECMA-376, Part 1, 18.3.1.40 f
(Formula)
@coveralls
Copy link

Coverage Status

Coverage increased (+4.69%) when pulling 30b9769 on Y--:master into c91e94d on SheetJS:master.

SheetJSDev and others added 12 commits June 27, 2014 09:58
- updated codepage to 1.3.1 (h/t @VolodymyrL)
- parsexmltag and other hot functions now better optimized for v8
- monomorphic functions (different types -> different funcs)
- more efficient decode_range implementation when source is trusted
- regular expressions cached and simplified without breaking correctness
- more efficient utf8 techniques when available
- XLSX: large functions broken down into sub-functions (e.g. `parse_ws_xml`)
- XLSB: avoid unnecessary binds
- XLSB: assume no exotic codepage exists (no one else tries to write XLSB)
- demo exposes rABS / worker / transferable options
- more tests
- jszip updated to 2.3.0
- SSF updated to 0.8.1
- codepage updated to 1.3.1
- browser shim updated (h/t @wintersm for discovering this)
- smart tag ignores (h/t @lostinplace)
- sheet_to_row_object_array bugfix (fixes SheetJS#80, h/t @ChrisBurkeBSD)
- README improved
- baltic and vietnamese codepages: updated codepage to 1.3.4
- iOS Numbers can handle inline strings -> disabling SST by default
- avoid Buffer accessors (see nodejs/node-v0.x-archive#7809)
- caching certain hot regexes
Retrieve shared formulas according to ECMA-376, Part 1, 18.3.1.40 f
(Formula)
@coveralls
Copy link

Coverage Status

Coverage increased (+4.93%) when pulling be82497 on Y--:master into c91e94d on SheetJS:master.

@matthewmueller
Copy link

What ended up happening with this PR?

@jasconius
Copy link

Hi, bumping this. I've made a private fork of XLSX JS and have created a true blue formula parser and resolver... and I'm just now running into this little issue... the shared formula thing is a big issue and I am wondering if anyone has any documentation about the rules that govern shared formulas and how I can make inferences from the data in the XML and generate the appropriate formulas. I'm pretty much ready to build this, I just need more data to pursue it.

Doing the corporate dance to try and get my work on parsing/resolving into your repo, not easy, but I think you guys would be quite happy with what I've created.

If I could make a request of the group, one of the most immediate barriers is the shared attribute is currently not even being parsed and added to the dictionary. If that could be done then I could do a merge and start cranking...

@SheetJSDev
Copy link
Contributor

This was addressed in 0.8.4. XLSX XLSB XLS and SpreadsheetML now parse shared and array formulae.

In XLSX, the raw shared formula is stored in the upper left cell along with a shared id si attribute. Cells referencing the formula include that si attribute. The parser calculates a delta and applies it to the relative references in the formula.

The current iteration uses a very simple regex which only fail on some special cases that can be refined with a more precise regular expression. @jasconius I originally thought a proper parser was needed but in retrospect a fine tuned regular expression can work (Excel itself prohibits defined names that potentially collide with a valid cell address).

@SheetJSDev SheetJSDev closed this Feb 28, 2017
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.

None yet

6 participants