Hello Hacker News and r/Javascript! Discover 100+ more golfed apps & games here! Fork me on GitHub

Sheet

A 188b/253b spreadsheet app in HTML/JS


Inspired by aem1k.com/sheet and this 30-line app
Golfed by xem, subzey, p01, rlauck, aemkei, odensc, mmastrac, corruptio
More backstory (2015)


Full (253b)

Features:

supports any value: texts, numbers, floats, and formulae. Ex: "=A1+8"
cells update in cascade, circular reference protection
implicit Math object. Ex: "=sqrt(A1)"
localStorage persistence

Source code:
(commented source code)

o=b=>{for(i in{}+o)with(M=Math)M[y='ABCD'[i%5]+-~(i/5%6)]=b?document.write(y&&
i<30?`<input placeholder=${y} id=`+y:'<br',` onfocus=value=[l[id]] onblur=l[id
]=value,o()>`):(top[y].value=[/^=/.test(z=l[y])?eval('x'+z):x=z],x-~x?+x:x)};o
(o(l=localStorage))

Demo:





Minimal (188b)

Supports numbers and formulae.
updates in cascade and prevents circular references.

Source code:
(commented source code)

(o=v=>{for(i in z='<input onblur=o[id]=value;o`.value` id=')y="
ABCD"[i%5]+-~(i/5),v?eval(y+(v+o[y]).replace(/[A-Z]\d/g," +$&"+
v)):document.write(y||'<p ',z,y,' onfocus=value=[o[id]]>')})()

Demo:





Full with headers (277b)


with(M=Math)o=b=>{for(i in{}+o)(top[y=(C='-ABCD'[r=i%6])+(R=~~(i%35/6))]||
o).value=[x=/^=/.test(z=i<35?b&&document.write(y?'<input id='+y:'<p',R&&r?
` onfocus=value=[l[id]] onblur=l[id]=value,o()>`:' disabled>'):l[y])?eval(
'x'+z):R?r?z:R:C],M[y]=x-~x?+x:x};o(o(l=localStorage))



© 2014-2017 The Codegolf Team