Search code examples
javascriptxlsxtabulator

Download tabulator table with numeric values?


When trying to download data from a Tabulator library table in XLSX format with sheetjs the numeric values in my table are recognized as strings within MS Excel.

I have tried all the parameters in the download function but there is no option for this.

table.download("xlsx", "data.xlsx", {sheetName:"MyData"});

Expected result is a MS Excel table with numeric values, however I get it with string values, not recognized as numbers.


Solution

  • It is likely that you are storing your values in the table as strings rather than numbers.

    Have you tried using a Download Accessor to convert the string to a number before it is used in the spreadsheet

    for example if you had a age column:

    //custom accessor
    function numberConvert(value, data, type, component){
        return Number(value);
    }
    
    //column definition
    {title:"Age", field:"ade", accessorDownload:numberConvert}