Calc.ts in Excel for the web

Calc.ts accelerates calculations in Excel for the web to desktop performance

Garage Wall of Fame - Calc.ts in Excel for the web
"Calc.ts is an outstanding project, and it's helping us improve the overall experience of the web version of Excel, which in these times of people working from home, has become even more vital to our business."
Brian Jones, Partner GPM, Microsoft Excel

About Calc.ts in Excel for the web

When Excel first came to the web, it did so by evaluating all formulas in the cloud, and sending each result to the browser. Although customers get the full power of desktop Excel, they sometimes get a slower response because of network delays.

Client-side estimation solves this problem by evaluating almost all formulas in the browser, so that the web app has the speed and the full power of the desktop experience.

Calc.ts is the calculation engine in TypeScript that powers client-side estimation. Calc.ts can evaluate more than 99% of formulas with accuracy of 99.95%. Excel for the web has so many customers that Calc.ts saves them a total of 7 years every day.

Journey

In 2017, the Calc Intelligence team was collaborating with Excel on ProjectYellow, bringing new data types and functions to Excel. As part of our research to understand the semantics of Excel formulas, we developed a model implementation of formula evaluation in the F# programming language.

We conceived a new research vision – Calc Anywhere – to empower customers with formulas in places beyond Excel, such as Word tables or Teams chats or even in Wikipedia. We took this idea and created a project for the companywide Hackathon in July 2017. For the Hackathon, we created a Calc Anywhere working demo that showed formulas evaluating within Word, powered by transpiling our F# semantics to JavaScript.

The hackathon was a platform that helped us generate excitement for Calc Anywhere, and we won the prize for Best Hackathon Project at MSR Cambridge. Afterwards, we learnt that part of the Excel team based in Herzliya, Israel, needed a calculation engine to implement client-side estimation in Excel for the web. We decided to pivot to client-side estimation and collaborate with the Excel team to rewrite our engine in TypeScript, which became Calc.ts.

It has been a thrilling collaboration with weekly conference calls and regular hackathons in Cambridge and Herzliya. A website can move fast and initial versions of Calc.ts went live to customers in early 2018. We developed telemetry to measure accuracy and coverage both offline on large collections of public spreadsheets and on-line on Excel for the web. We had a lot of work to complete aspects not covered fully in the initial prototype, including many language features and hundreds of worksheet functions.

We needed new research to develop techniques for evaluating formulas in the face of incomplete data, since for large workbooks it is not possible to download the entire sheet into the browser. Many customers use workbooks a gigabyte or more in size.

To keep the browser responsive to user input while the workbook is being recalculated, we developed libraries to offload the calculation work to a dedicated thread (known as a Worker) which evaluates the formulas alongside the user’s work, keeping the page smooth and responsive while calculation is taking place. This sophisticated use of threading is a first for Excel on the web.

Implementing the complex numeric algorithms of Excel in TypeScript was itself a challenge, requiring use of WebAssembly to port certain sensitive numeric routines into the browser. This is a first for Office on the web.

At the time of writing, mid 2020, the Calc Intelligence team has finished our core research on client-side estimation. We are handing over ownership to the Excel team. We are returning once more to the Calc Anywhere vision, looking at how formulas can work in the Fluid Framework.

Calc.ts is a collaboration between many people; the research lead is Andy Gordon and the engineering lead is Neil Toronto.

“Everyone was amazed. I am super excited about this effort and the level of collaboration between our teams.” – Yair Helman (Partner GEM, Microsoft Excel)

“What a great partnership! Calc.ts is a great solution for instantaneous content latency by providing core Excel capabilities on the browser.” – Lior Moshaiov (Principal EM, Microsoft Excel)

Team

Calc.ts team photo

Calc.ts second team photo

Hackathon project team
Matt McCutchen, Lyndsay Upex, Andy Gordon (Research Lead), Chris Bishop (Lab Director), Neil Toronto (Engineering Lead), and Jack Williams

Second picture
Dany Fabian, Pninit Goldman, Neil Toronto, Tal Kariv, Nick Wilson, and Jack Williams

Not pictured
Hagit Badash, Pantazis Deligiannis, Nahum Farchi, Juliana Vicente Franco, Gali Lustig, Lior Moshaiov, Alexander Novikov, Amos Ortal, Andrew Stegmaier

Calc.ts builds on Project Yellow work by Andrew Kennedy, Simon Peyton Jones, and Claudio Russo

See it here