简体   繁体   中英

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.

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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM