views:

44

answers:

1

I know this isn't the right place to ask about this specific vague problem, but maybe someone knows this library well enough to enlighten me. Here is the thing:

I am writting an Excel5 over an existing Excel file with PHPExcel. I need to upload that Excel to the Zoom website, so it can provide me with a list of tracking numbers. However, for some reason the library they are using to read the uploaded Excel files cannot read the rows written by PHPExcel and the only solution I've found so far is to manually copy the contents of my dynamically generated Excel to another document using MS Excel 2007.

In other words, the Zoom website can read the rows written natively by Excel but not rows written by PHPExcel. My file has only one single sheet, and I can open it no problem with Excel 2007.

Even if I manually add some rows to the template and then add more rows with PHPExcel, Zoom will read the rows written manually by me, but not the rows written by PHPExcel.

This is how I'm doing it:

// Starting with the PHPExcel library
$this->load->library('PHPExcel');
$this->load->library('PHPExcel/IOFactory');
$template_file = 'zoom_tracking_template.xls';
$i = 3;

$objReader = IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load($template_file);
$objPHPExcel->setActiveSheetIndex(0);

// Fetching ML payments
foreach($payments as $row)
{
 $objPHPExcel->getActiveSheet()->setCellValue('A'.$i, 'VANESSA NEISZER');
 $objPHPExcel->getActiveSheet()->setCellValue('B'.$i, '02127616116');
 $objPHPExcel->getActiveSheet()->setCellValue('C'.$i, '1ER PISO MINITIENDAS 199 BLVD SABANA GRANDE, CRUCE C / CALLE NEGRIN');
 $objPHPExcel->getActiveSheet()->setCellValue('D'.$i, $row->mailing_city);
 $objPHPExcel->getActiveSheet()->setCellValue('E'.$i, $row->mailing_name);
 $objPHPExcel->getActiveSheet()->setCellValue('F'.$i, $row->mailing_name);
 $objPHPExcel->getActiveSheet()->setCellValue('G'.$i, $row->mailing_personal_id);
 $objPHPExcel->getActiveSheet()->setCellValue('H'.$i, $row->mailing_phone);
 $objPHPExcel->getActiveSheet()->setCellValue('I'.$i, $row->mailing_address1.' '.$row->mailing_address2);
 $objPHPExcel->getActiveSheet()->setCellValue('J'.$i, $row->nickname);
 $objPHPExcel->getActiveSheet()->setCellValue('K'.$i, '1');
 $objPHPExcel->getActiveSheet()->setCellValue('L'.$i, '0.3');
 $objPHPExcel->getActiveSheet()->setCellValue('M'.$i, 'M');
 $objPHPExcel->getActiveSheet()->setCellValue('N'.$i, 'PRODUCTO');
 $objPHPExcel->getActiveSheet()->setCellValue('O'.$i, '0');

 $i++;
}


$objPHPExcel->setActiveSheetIndex(0);

$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5');

// Sending headers to force the user to download the file
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Envios'.date('dMy').'.xls"');
header('Cache-Control: max-age=0');

$objWriter->save('php://output');

I have no clue of what PHP library they are using to read Excel files and I am certain they wont tell me if I ask them. I know they use PHP, and their library only read Excel 2003 files, however, I don't know why they can't read my files but they can read other files written manually on MS Excel.

Any clues, ideas or suggestions I could try would be greatly appreciated.

+1  A: 

And PHPExcel's main developer is looking at this issue (among others), somewhere in between trying to find a new day job and having a life. I'm not familiar with the zoom website, or the software that they use. PHPExcel BIFF8 files can be read by Excel, OOCalc and Gnumeric without error... but a couple of questions spring to mind.

  • What version of PHPExcel?
  • Does any of the data contain UTF-8 characters?
  • Are there any formulae in the template worksheet?
  • If so, what are they?
Mark Baker
What version of PHPExcel?: PHPExcel 1.7.3c Production - Does any of the data contain UTF-8 characters?: Yeah, they come UTF-8 encoded from the database and they are inserted in the Excel untouched. - Are there any formulae in the template worksheet?: Not at all, its a basic header with some colors, that's it. Just plain text.
Danny Herran