How to create a spreadsheet engine for the web?

everyone. I’m trying to code a spreadsheet for my SAAS in NextJS; the spreadsheet is essential for my app. At present, all I’m doing is running nested for loops in rendering the spreadsheet cells. The spreadsheet cells are being rendered in (n^2) complexity. The spreadsheet is able to render 10,000 cells, but after that the performance starts to decline significantly on the web.

The spreadsheet I’m creating will not support the formulas, etc. that Excel and Google Sheets support. I just want spreadsheet data to be editable on my app that can be saved on the cloud.

I know I have to create a spreadsheet engine, but I don’t know how to go about it.

If anyone can help me with it, I’d be really grateful.