I am using php with symfony2 to export the data in csv format using the following steps :
public function exportAction(Request $request) {
$data = array("data" => "test");
$format = $request->getRequestFormat();
if ($format == "csv") {
$response = $this->render('PrototypeBundle:Prototype:export.' . $format . '.twig', array('data' => $data));
$filename = "export_".date("Y_m_d_His").".csv";
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', 'attachment; filename='.$filename);
return $response;
} else if ($format == "json") {
return new Response(json_encode($data));
}
}
How can i set the autoFit for all the columns in csv file and how can i change the tabName of the csv sheet.In my case i only have one sheet in my csv file and would like to specify dynamic sheetName for each csv export workflow.
Thanks.