How do Spreadsheet programs efficiently deal with 10s of thousands of cells?

200x200 is nothing.

Your problem is you are creating UI widgets for all the cells upfront. This is bad.

You should have a data structure that represents your sheet as pure data. e.g. simple 2D array of Cell struct where each struct is basically a string and a double, or whatever it is you feel is the right way to represent the data behind the cell.

I did this kind of thing in Javascript and I can assure you that initializing a 2D array of simple objects is really fast. I can do 200x10000 array of objects in javascript and it would initialize in like 100ms or so.

Then when you render, you have a fixed number of cell widgets that you recycle all the time to only render the cells that are currently in view.

/r/AskProgramming Thread