PHPExcel unreadable content

2019-08-12 05:14发布

I am making an .xlsx file then send it via email. But when I received the file in my email. It says "unreadable content" and try to recover it. When I recover it the file is complete and intact. Nothing is missing. But I don't want that error box to appear.

I am using this line of code because php_zip is not enabled on my server therefore I must use this. Without this I will get an error that says ZipArchive missing or something.

PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);

And lastly this is my function to make the excel file:

$objPHPExcel = new PHPExcel();

           $counter = -1; $counterEmpty = 0;
           foreach($user_notifications as $mode => $arrayRawData){
               if(!empty($arrayRawData)){
                   if($counter != -1)
                   {$objPHPExcel->createSheet();}

                    $Header = "A";
                    $Header2 = "A";
                    $HeaderCol = 1;
                    $counter++;
                    $counterEmpty++;

                    foreach($arrayRawData as $HwKeyColumn => $arrayHwData){
                       $objPHPExcel->setActiveSheetIndex($counter)
                                    -> setCellValue($Header2 . $HeaderCol , $HwKeyColumn);
                       $objPHPExcel->getActiveSheet()->setTitle($mode);
                       $Header2++;
                    }

                    foreach($arrayRawData as $HwKeyColumn => $arrayHwData){
                       $HeaderCol2 = $HeaderCol;

                    foreach($arrayHwData as $id => $value){
                            $HeaderCol2++;
                            $objPHPExcel->setActiveSheetIndex($counter)
                                        -> setCellValue($Header . $HeaderCol2,$value);
                        }
                        $Header++;
                    }
                }
           }

           if($counterEmpty==0)
           {
        $Header2 = "A";
                $HeaderCol = 1;
                $objPHPExcel->setActiveSheetIndex(0)
                           -> setCellValue($Header2 . $HeaderCol, 'No update or errors.');
           }
           else{}

           $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
           $objWriter->save($date.'_SUBCON_'.$vendor_name.'_AUTO_UPDATE_REPORT.xlsx');

A picture of the error of excel enter image description here

标签: php phpexcel
0条回答
登录 后发表回答