BigGirl1017 BigGirl1017 -4 years ago 122
Javascript Question

convert excel file to html and javascript

i have one excel calculator file which contains several sheets and formulas searching across sheets.

i want to convert this calculator in html page, and using javascript to do the calculation.
I've built up mySQL database to store these data for lookups...using php forms should get user inputs

I am concerned with the logic and layout in excel is not so straightforward as in javascript using functions.

Is there a way to do this that ensures the accuracy?

Answer Source

I did something like this once. Basically you have to get two things right. The html and the Javascript to compute the formulas :D. To generate the html from the excel I recommend saving the Excel sheet as a web page and study the generated html. You can use it as it is, modify it, or you feel brave enough, try to build a generator yourself. It will be hard to build a generator, it took me about 1.5 months to get all the quirks right.

The formulas are pretty tough as well. In your case, probably you need to translate a couple of formulas, which can be done by hand. Just assign an unique id to each td in the html (it can be the cellId from excel, like R30), and translate the formulas to JS. To mimic the excel cells, you can place input[type=text] tags in the editable tds.

To make a generic formula translator, that works with all formulas is a lot harder. I used ANTLR with an excel grammar. ANTLR then generates a lexer/parser and with the extracted AST we can finally get Javascript formulas. Took another 3 weeks to get everything right.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download