PHPExcel: 1.7.8, 2012-10-12
PHP 5
I currently am using PHPExcel to read from an uploaded file, with xls, xlsx and csv being allowed upload formats. One of the cells in the spreadsheet will often contain a number with a leading zero, e.g. 012345. For excel spreadsheet uploads, as long as the uploader has formatted the column as "Text" in Excel, the data is being read fine with the leading zero. However for csv uploads the leading zero is being dropped, regardless of whether the field is enclosed in quotes or not in the csv file.
Is there any way to prevent the zero from being dropped from this field in a CSV upload using PHPExcel?
Previously I was using the line $exceldoc=PHPExcel_IOFactory::load("$fname"); for both filetypes. I tried using the following for CSV only but it did not prevent the leading zeros from being dropped:
$objReader = new PHPExcel_Reader_CSV();
$exceldoc = $objReader->load("$fname");
Any help or even a pointer in the right direction would be greatly appeciated.
Alan