Save Style FlexSheet

Posted by: oskarputraa on 23 October 2019, 12:59 am EST

    • Post Options:
    • Link

    Posted 23 October 2019, 12:59 am EST

    Hi,

    I have an issue when trying to load style (font size, font style, font family, font color, background color, etc) from database. When loaded a lot of data (ex. 5230 styles data), it make my browser crash (not responding)/ out of memory.

    This is how I load style from database and put it into FlexSheet.

    for (let iDataSource_data = 0; iDataSource_data < this.dataSource_data.length; iDataSource_data++) {
    										// this.formatSheet.applyCellsStyle(this.dataSource_style[iDataSource_data].A, [new grid.CellRange(iDataSource_data, 0, iDataSource_data, 0)]);
    									}
    

    Imagine I have 50k data, it will loop 50k times and put it into cell one by one, it would consume a lot of memory.

    Could you help me to get style data efficiently ?

    Thanks,

    Oskar Putra

  • Posted 23 October 2019, 1:01 am EST

    
    for (let iDataSource_data = 0; iDataSource_data < this.dataSource_data.length; iDataSource_data++) {
    this.formatSheet.applyCellsStyle(this.dataSource_style[iDataSource_data].A, [new grid.CellRange(iDataSource_data, 0, iDataSource_data, 0)]);
    }
    
    
  • Posted 24 October 2019, 8:51 am EST

    Hello,

    You may apply the cellsStyles withing deferUpdate method. This will prevent the FlexSheet update.

    Please use it as follows:

    flexSheet.beginUpdate();
    flexSheet.deferUpdate(()=>{
    //style code
    })
    flexSheet.endUpdate();
    

    PS: If you are not exporting the FlexSheet or can ignore the styles during the Excel Export, we would suggest you to style using ItemFormatter or FormatItem.

    Regards,

    Manish Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels