简体   繁体   English

如何将制表符数据导出到 csv,包括格式化

[英]How to export tabulator data to csv including formatting

Is there any way to export tabulator data to CSV using formatting,有什么方法可以使用格式将制表符数据导出到 CSV,

I am using Vue tabulator, Exporting is working fine but it does not include formatted data.我正在使用 Vue 制表符,导出工作正常,但不包括格式化数据。

Exports specifically only include unformatted table data because a lot of formatters include HTML elements that add graphical component to the cells that would not make sense in downloaded file (progress bars for example) .导出特别只包括未格式化的表格数据,因为很多格式化程序包括 HTML 元素,这些元素将图形组件添加到下载文件中没有意义的单元格(例如进度条)

That being said if you would like to transform data as it is being exported, you could look at using an accessor, these are used to transform data as it is leaving the table.话虽这么说,如果您想在导出数据时转换数据,您可以考虑使用访问器,这些访问器用于在数据离开表时转换数据。 in this case we will need to use an accessorDownload accessor.在这种情况下,我们将需要使用accessorDownload访问器。

For the sake of example, lets assume we are doing this to the name column and want to prefix the word "mr " to the beginning of every value;举个例子,假设我们正在对name列执行此操作,并希望在每个值的开头添加单词“mr”;

We would star by defining our accessor function:我们将通过定义我们的访问器 function 来启动:

function mrAccessor(value, data, type, component, row){
    return "mr " + value; //prepend string to value
}

Then in our column definition we would assign the accessor to the column:然后在我们的列定义中,我们将访问器分配给该列:

{title:"Name", field:"name", accessorDownload:mrAccessor},

The data that is exported with the include the changed name values, but the values in the Tabulator table itself will remain unaffected使用 导出的数据包括更改后的名称值,但 Tabulator 表本身中的值将保持不受影响

For full details, have a look at the Accessor Documentation有关完整详细信息,请查看访问器文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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