ruilisi / fortune-sheet

A drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets
https://ruilisi.github.io/fortune-sheet-docs/
MIT License
2.54k stars 227 forks source link

Set default font and cell format #616

Closed AlexBittermann closed 2 weeks ago

AlexBittermann commented 3 weeks ago

I've been digging through the code all day, but I couldn't find any way to set the default font and cell format for the whole sheet. For reference: I want the default font to be Arial instead of Times New Roman and cell format should be text only. So basically something like this: ct: { fa: '@', t: 's' }, ff: 1

Is there any way to achieve this?

sanchit3008 commented 2 weeks ago

This has to be configured per cell, you could just make an object with your settings and then destructure it for every cell entry. Currently no way to apply a global setting.

AlexBittermann commented 2 weeks ago

So basically I have to iterate over every initial cell and then also set it whenever a row or column is added?

sanchit3008 commented 2 weeks ago

You can set it wherever you are setting the sheet data rendering initially. For new rows and cols yes you'll need to handle it manually.

AlexBittermann commented 2 weeks ago

Is there any example for that (especially for new rows and columns)? I saw there's a defaultCell object inside the Context. Could be very helpful to expose that and make it possible to set it on the component level.

sanchit3008 commented 2 weeks ago

I dont have an example handy but I believe you can do this inside the onOp function

Could be very helpful to expose that and make it possible to set it on the component level.

That can be taken up as a feature request