I am using this php code to allow the user to send dojo.enchancedgrid to file and download it to his machine. The procedure works fine, but the output csv file has the escape lines for the quotes. How can I avoid php inserting those for me. The string that is passed to the function(str) is ok, but after passes through the php code is different.
My javascript code:
function exportCsv(){
var g = dijit.byId("grid");
g.exportGrid("csv",{
writerArgs: {
separator: ","
}
}, function(str){
alert(str);
var form = document.createElement('form');
dojo.attr(form, 'method', 'POST');
document.body.appendChild(form);
dojo.io.iframe.send({
url: "csv.php",
form: form,
method: "POST",
content: {exp: str},
timeout: 15000
});
document.body.removeChild(form);
});
}
My php code:
$time = time();
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=\"grid_$time.csv\"");
$exportedData = $_POST['exp'];
echo $exportedData;
Also the server is inserting some analytics code in the rows as well…
Thank you very much for the help guys.
Below is the output csv file:
Lon,Lat,Network,RouteId,Measure
-74.18143812,40.62733114,\”Named Route\”,IN278,1
-73.90131905,40.75932358,\”Named Route\”,IN278,25
-73.8005193,40.73819062,\”Named Route\”,IN495,10
-73.82437443,40.79381815,\”Named Route\”,IN678,12
-73.79087796,40.66589334,\”Named Route\”,\”NY 27\”,12
<– Hosting24 Analytics Code –>
<–End Of Analytics Code –>
1 Answer