Skip to content

Instantly share code, notes, and snippets.

@C-Pro
Created May 15, 2020 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save C-Pro/efc3678160af34b9f3ecf3bccef4d880 to your computer and use it in GitHub Desktop.
Save C-Pro/efc3678160af34b9f3ecf3bccef4d880 to your computer and use it in GitHub Desktop.

ExcelJS

The task is to make an Excel-like table with support for the simplest formulas. Recalculation of values in the cells should occur immediately upon loss of focus and affect only those cells whose values should be changed. Do not recalculate the whole table every time (if not necessary). Use pure JS (ES6), HTML, CSS. Use third-party frameworks, libraries is not encouraged for this task. Task result will be viewed with the latest version of chrome (desktop and mobile).

Let the table size be 100x1000 (WxH)

Cell Content

A cell can contain numbers and formulas. Numbers can be either integer or decimal floating point (e.g. 15, 324, -3, 0.08, -123.0001). Formulas begin with a = sign and an expression. An expression consists of operands and operators. Operators are one of 4 arithmetic operations, operands - numbers and addresses of cells.

Examples

=2+2
=A12
=AB33*3

BNF (incomplete)

<cell> :: = <empty> | <number> | <formula>
<empty> :: = ""
<number> :: = <integer> | float>
<integer> :: = "-" [0-9] + | [0-9] +
<float> ::= "-" [0-9] + "." [0-9] + | [0-9] + "." [0-9] +
<formula> :: = "=" <expression>
<expression> :: = <number> | <cell address> | <expression> <operator> <expression>
<cell address>: = <column> <row>
<column> :: = [A-Z] +
<row> :: = [0-9] +
<operator>: == "-" | "+" | "/" | "*"

Good luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment