csvhtml5 exportoptions format body

csvhtml5 exportoptions format body

evan123evan123 Posts: 8Questions: 6Answers: 1

Hello,

Looking to format one of my columns that I am exporting to a csv.

Cannot find a good example

I tried the following ... how do I format column 15 ... i tried just foobar but does not come through

Thanks,
Evan

    {extend: 'csvHtml5', text:'CSV', className:'btn-link',
     filename: 'my export ' ,
         exportOptions: {
     columns: [ ':visible' ],
     format: {
                 body: function ( data, row, column, node ) {
         return column == 15 ?
                         'foobar':
                         data;
                 }
     }
         }},

I am using
* https://datatables.net/download/#bs-3.3.7/jq-3.2.1/jszip-2.5.0/pdfmake-0.1.32/dt-1.10.16/e-1.6.5/af-2.2.2/b-1.4.2/b-colvis-1.4.2/b-flash-1.4.2/b-html5-1.4.2/b-print-1.4.2/cr-1.4.1/fc-3.2.3/fh-3.1.3/kt-2.3.2/r-2.2.0/rg-1.0.2/rr-1.2.3/sc-1.4.3/sl-1.2.3
*
* Included libraries:
* Bootstrap 3 3.3.7, jQuery 3 3.2.1, JSZip 2.5.0, pdfmake 0.1.32, DataTables 1.10.16, Editor 1.6.5, AutoFill 2.2.2, Buttons 1.4.2, Column visibility 1.4.2, Flash export 1.4.2, HTML5 export 1.4.2, Print view 1.4.2, ColReorder 1.4.1, FixedColumns 3.2.3, FixedHeader 3.1.3, KeyTable 2.3.2, Responsive 2.2.0, RowGroup 1.0.2, RowReorder 1.2.3, Scroller 1.4.3, Select 1.2.3

Answers

  • kthorngrenkthorngren Posts: 21,376Questions: 26Answers: 4,957
    edited December 2017

    Your code is working in this example:
    http://live.datatables.net/yetefidi/1/edit

    I have not loaded all the extensions like you just the basic Buttons code.

    The only thing I can think of with just your code snippit is the column numbers start counting at 0 so you need at least 16 columns in your table to reference column 15.

    EDIT: I would recommend not loading all the extension like you have. The pages will load faster if you only load what you need.

    Kevin

This discussion has been closed.