Live data from Hacker News

A spreadsheet in fewer than 30 lines of JavaScript, no library used

jsfiddle.net

51–60 of 274 posts

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#51
For 30 lines of code it is indeed impressive.

But I think it would of been more impressive at 40 or whatever it would of taken to have a couple error checks.

What I mean by this is if you enter an invalid formula say =() or =asdf in a cell it breaks all the valid formulas you enter after that cell making them display as text instead of a value when refreshed.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#52

For 30 lines of code it is indeed impressive. But I think it would of been more impressive at 40 or whatever it would of taken to have a couple error checks. What I mean by this is if you enter an invalid formula say =() or =asdf in a cell it breaks all the valid formulas you enter after that cell making them display as text instead of a value when refreshed.

Added a trivial try-catch block so error in one cell does not prevent others from evaluating. Line count unchanged :-)

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#53
post #30

Are there any more full-featured libraries that people use for this? I've found SpreadJS[0], GelSheet[1], jQuery.Sheet[2], and ZK Spreadsheet, but none seem like thriving open-source projects as far as I can tell. [0] http://wijmo.com/demo/spreadjs/samples/index.html [1] http://www.gelsheet.org/demo [2] http://visop-dev.com/Project+jQuery.sheet [3] http://www.zkoss.org/product/zkspreadsheet

I have used http://handsontable.com/ before in my projects.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#57
post #30

Are there any more full-featured libraries that people use for this? I've found SpreadJS[0], GelSheet[1], jQuery.Sheet[2], and ZK Spreadsheet, but none seem like thriving open-source projects as far as I can tell. [0] http://wijmo.com/demo/spreadjs/samples/index.html [1] http://www.gelsheet.org/demo [2] http://visop-dev.com/Project+jQuery.sheet [3] http://www.zkoss.org/product/zkspreadsheet

The most full featured OS JS spreadsheet I know of is ethercalc, check it out. It's even got a rest api..

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#58
post #19
post #10

Very cool and a great springboard for others to develop from. Bug/feature: only uppercase works in formulas (A4 works but a4 does not).

Neat idea, lowercase fixed!

Worth a line of code to add return key to move down a cell?

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#59
post #28

My text disappears after I type it in and move on. And why do you call a table an "excel-like" app? Can it so =SUM(); can it do search and replace or the over 9000 other features of excel? No... it's a table, with a editor.

They made a fully functioning spreadsheet in 30 lines with no libraries. I'm sure adding more functions is possible... You could probably even figure out how to create a SUM function...

You can create your built-in functions as this:

var DATA={ SUM: function(a,b) { return a+b; } }

Nice demonstration of language features, like 'with', that we usually take as 'bad practices'.

Post reply on HN