Giter VIP home page Giter VIP logo

artemsyzonenko / excelformulautilitiesjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joshbtn/excelformulautilitiesjs

0.0 2.0 0.0 5.37 MB

Based on ewbi's go calc excel formula parser http://ewbi.blogs.com/develops/popular/excelformulaparsing.html. This library contains methods to beautify an excel formula. This library also contains functions to convert an excel formula to JavaScript (ECMAScript) or C#.

Home Page: http://excelformulabeautifier.com/

License: MIT License

excelformulautilitiesjs's Introduction

ExcelFormulaBeautifier.com

This lives under the gh-pages branch. To submit pull requests for ExcelFormulaBeautifier.com please use this branch. Changes to the core js library live in the master branch.

Excel Formula Utilities for JavaScript

##Installation

  1. Save excelFormulaUtilities-[version].js(For dev) or excelFormulaUtilities-[version].js.min (For prod).
  2. Save excelFormulaUtilities.css if you'd like basic styling when outputting formulas to html.
  3. Drop these files into your project.

Check out the examples below or if you'd like to use the beautifier online click here http://excelformulabeautifier.com/

##Basic usage

This will return a formated formula in plain text.

excelFormulaUtilities.formatFormula('IF(1+1=2,"true","false")'); //Returns a string containing the formatted formula.

##Example

To see this example check out ./examples/basic_example1/index.html

###The JavaScript window.onload = function(){ //Beautify an Excel formula output to text var formula_1 = 'SUM((A1:A10>=5)*(A1:A10<=10)*A1:A10)'; document.getElementById('fomatFormula_1').innerHTML = formula_1; document.getElementById('fomatFormula_1_out').innerHTML = excelFormulaUtilities.formatFormula(formula_1);

    //Beautify an Excel formula output to html.
    var formula_2 = '=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))';
	document.getElementById('fomatFormula_2').innerHTML = formula_2;
	document.getElementById('fomatFormula_2_out').innerHTML = excelFormulaUtilities.formatFormulaHTML(formula_2);
	
    //Convert an Excel formula to C#
    var formula_3 = '=IF(A2:A3="YES","A2 equals yes", "A2 does not equal yes")';
	document.getElementById('fomatFormula_3').innerHTML = formula_3;
	document.getElementById('fomatFormula_3_out').innerHTML = excelFormulaUtilities.formula2CSharp(formula_3);
	
    //Convert an Excel formula to JavaScript
    var formula_4 = 'ADDRESS(ROW(DataRange2),COLUMN(DataRange2),4)&":"&ADDRESS(MAX((DataRange2<>"")*ROW(DataRange2)),COLUMN(DataRange2)+COLUMNS(DataRange2)-1,4)';
	document.getElementById('fomatFormula_4').innerHTML = formula_4;
	document.getElementById('fomatFormula_4_out').innerHTML = excelFormulaUtilities.formula2JavaScript(formula_4);
}

###The HTML

excelFormulaUtilities.formatFormula( "" );


<div class="formula">
	<h2>excelFormulaUtilities.formatFormulaHTML( "<span id="fomatFormula_2"></span>" );</h2>
	<pre id="fomatFormula_2_out"></pre>
</div>

<div class="formula">
	<h2>excelFormulaUtilities.formula2CSharp( "<span id="fomatFormula_3"></span>" );</h2>
	<div id="fomatFormula_3_out"></div>
</div>

<div class="formula">
	<h2>excelFormulaUtilities.formula2Javascript( "<span id="fomatFormula_4"></span>" );</h2>
	<pre id="fomatFormula_4_out"></pre>
</div>

excelformulautilitiesjs's People

Contributors

joshbtn avatar adamschmideg avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.