CSS code in column value not recognized while using export csv/pdf in datatables 1.9

CSS code in column value not recognized while using export csv/pdf in datatables 1.9

mick_000mick_000 Posts: 3Questions: 0Answers: 0
edited December 2012 in General
Hi,



I have a column which has the following value

p { text-indent: 0pt;padding: 0px 0px 0px 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 12px;margin-left: 0px;text-align: left;font-family: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000; } Sample entry


The css style has to be applied to the data "Sample entry".

When i tried to export the table value to pdf/csv file, I noticed that the html code is getting ignored whereas along with the text "Sample entry", the css code is also getting exported.

The data in my pdf/csv file after export is

p { text-indent: 0pt;padding: 0px 0px 0px 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 12px;margin-left: 0px;text-align: left;font-family: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000; } Sample entry



Is there anyway wherein the css style can be applied before exporting to pdf/csv file in datatable.

Following is the snippet I am using


var SDomVal= '<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"Ti>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"p>';
var oTable = $("#Sample").dataTable({
bJQueryUI: false,
"sDom": SDomVal,
"oTableTools": {
"sSwfPath": "DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "xls",
"sButtonText": "Save As Excel",
"mColumns": [0]
},
{
"sExtends": "pdf",
"sButtonText": "Save as PDF",
"mColumns": [0]
},
{
"sExtends": "copy",
"sButtonText": "Copy",
"mColumns": [0]
}
]
},
"aButtons": ["test"],
"aaData": aNew,
"bRetrieve": true,
"aoColumns": [

{
"sTitle": "Value",
"bVisible": true,
"fnRender": function (obj) {
var val = obj.aData[0];

return val;
}
}
],
iDisplayLength:30
});






Please guide me.

Thanks in advance.

Replies

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin
    A CSV file obviously can't, itself, hold colour values - you'd need to put some other formatting in such as HTML - so you could modify the data exported to do that. However, in general TableTools just exports plain data, if you want to add additional formatting, you'd need to add a few changes to the libraries to do that.

    Allan
This discussion has been closed.