I have made a script using PHPExcel to convert .xls files to .csv files. The .xls file has date formatting in it, and when converted to .csv the date fields has a high number increasing 1 for every day:
So how do I fix this? I want it to say it like this: 10/Jun or 15/Apr.
My code:
$count = 0;
foreach($html->find('section#content_main a') as $e) {
echo "<h3>" . $e->href . "</h3>";
$link = $e->href;
echo "<p>" . $array[$count] . "</p>";
$file = $array[$count] . ".xls";
file_put_contents($file, fopen($link, 'r'));
if(file_exists($array[$count] . ".csv") == 0){
$fileType = PHPExcel_IOFactory::identify($file);
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objReader->setReadDataOnly(false);
for($i = 0; $i < (count($letters) * 2); $i++){
if(i < count($letters)){
}else{
}
}
$objPHPExcel = $objReader->load($file);
$objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()
->setFormatCode('d-mmm');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save($array[$count] . ".csv");
$count = $count + 1;
echo "<p>File dosen't exist!</p>";
}else{
echo "<p>File do exist!</p>";
}
}
Thanks for the support on my first post. I don't know what did the trick but i might think that it was this piece of code: