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

TODAY() function is not working #551

Closed subhajitnag28 closed 4 months ago

subhajitnag28 commented 5 months ago

TODAY() function is not working, it is giving NaN.

Screenshot 2024-05-29 at 5 36 55 PM Screenshot 2024-05-29 at 5 37 12 PM
sanchit3008 commented 5 months ago

I see that the TODAY() function from formulajs returns a date object, but the sheet can support only string and number. Would setting the cell value as string like Sat Jun 01 2024 00:00:00 GMT+0530 (India Standard Time) work for you?

sanchit3008 commented 5 months ago

Following functions have the same issue -

sanchit3008 commented 5 months ago

@zyc9012 what are your thoughts on this? I was thinking to have a check in execfunction in formula.ts to see if the result of the formula parser is a date, and to return result.toString() if it is a date.

subhajitnag28 commented 5 months ago

Hi @sanchit3008 I think it should work. Can you please help to make the change?

sanchit3008 commented 5 months ago

I have the changes ready, will wait for @zyc9012's inputs for a couple of days

subhajitnag28 commented 5 months ago

Thanks @sanchit3008

sanchit3008 commented 5 months ago

553