Stripping HTML mark-up during Export

Tags: #<Tag:0x00007efc61cfe0e0>

I’m having a problem while exporting data via the Pro Export module. I’ve inserted HTML markup into my table’s headers, but the mark-up gets exported, as the base mark-up tags, into the resulting CSV file.

Is there an easy way to omit this mark-up from being exported at all?

Hi @crippere

the .csv file gets lean data so each cell (and header) loses its meta data and styling. If I use HTML inside headers in the .csv I will get exactly what I have typed http://jsfiddle.net/p56x21y7/

Is there an easy way scrub the HTML out or otherwise transform the headers during export?

I tried changing the downloadFile statement’s “columnHeaders” property to state the header values that I wanted exported, but that didn’t take.

        handsonchart.getPlugin('exportFile').downloadFile(format, {
            filename: 'MyExport',
            columnHeaders: true
            
        });

…to:

        handsonchart.getPlugin('exportFile').downloadFile(format, {
            filename: 'MyExport',
            columnHeaders: ['ID', 'Name', 'MyDescription']
            
        });

What I did get working was to update the whole chart to my export headers, export it, and then update the chart to restore the old, HTMLed headers:

        handsonchart.updateSettings({
            colHeaders: [
                'ID', 'Name', 'MyDescription'
            ]
        });
        handsonchart.render();

        handsonchart.getPlugin('exportFile').downloadFile(format, {
            filename: 'MyExport',
            columnHeaders: true
        });

       handsonchart.updateSettings({
            colHeaders: [
                'ID', 'Name', 'MyDescription <img src="icon.png"/>'
            ]
        });
        handsonchart.render();

…but I’m hoping that there should be a better way.

Hi @crippere

you can also check afterGetColHeader callback. However, it is not a good choice if you use sorting.

demo: http://jsfiddle.net/0dtcdpun/