Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

csv to excel conversion

Tags:

Is there a way to convert csv file to excel file upon request through apache/.htaccess

like image 990
Ashraf Sufian Avatar asked Oct 06 '10 16:10

Ashraf Sufian


People also ask

How do I open a CSV file in Excel without columns?

How do I open a CSV file in Microsoft Excel without changing the column formatting? To open a comma-delimited (CSV) file properly, use Excel's Data Import from Text feature to open the import wizard and set all columns as text.


1 Answers

Using PHPExcel

include 'PHPExcel/IOFactory.php';  $objReader = PHPExcel_IOFactory::createReader('CSV');  // If the files uses a delimiter other than a comma (e.g. a tab), then tell the reader $objReader->setDelimiter("\t"); // If the files uses an encoding other than UTF-8 or ASCII, then tell the reader $objReader->setInputEncoding('UTF-16LE');  $objPHPExcel = $objReader->load('MyCSVFile.csv'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('MyExcelFile.xls'); 
like image 187
Mark Baker Avatar answered Oct 01 '22 05:10

Mark Baker