php - PHPExcel: After saving file, returning broken worksheet

287

I have problem with PHPExcel. I already read that question:

How to modify excel file using PHPExcel in symfony2

...because on the begining that was my problem. But I already done everything which Abhishek Jaiswal said and... Ive got another problem. Probably Ive done something bad, because that answer is quite reasonable.

Ok, about code:

$excelReader = \PHPExcel_IOFactory::createReader('Excel2007');
$excelObj = $excelReader->load($path.$filename);

for ($i = 3; $i <= 30; $i++) {
        $excelObj->setActiveSheetIndex(0)->setCellValue('O'.$i, 'tytyty')->
        setCellValue('P'.$i, $company->getFullName())->
        setCellValue('Q'.$i, $company->getAddress())->
        setCellValue('S'.$i, $company->getAddressAddition())->
        setCellValue('T'.$i, $company->getPostalCode())->
        setCellValue('U'.$i, $company->getCity())->
        setCellValue('V'.$i, $entity->__toString())->
        setCellValue('W'.$i, $entity->getPhone())->
        setCellValue('X'.$i, $entity->getInternalPhoneNumber())->
        setCellValue('Y'.$i, $entity->getEmail());
    }
$excelObj->setActiveSheetIndex(0);
$excelWriter = \PHPExcel_IOFactory::createWriter($excelObj, 'Excel2007');
$excelWriter->save($path . $new_filename);

And when I look on saved file, on edited worksheet i got worksheet that start from 31 row (which is first not edited row, and first without any formating in that worksheet). In fact, it also looks broken, because when I opening it in LibreOffice I dont see rows, just numbers on the right.

And Im pretty sure, that xlsx, which Im loading, is good because I tried to dump data from it, and I got, what I expected.

905

Answer

Solution:

Ok... I found it. I repeated test, that i've done above, but with one difference. I took ,to create file, Microsoft Office. It appear, that Libre Office have some problems with 2007/2010 format.

Everything works great with MO file.

People are also looking for solutions to the problem: regex - Regular Expression to match multiple patterns in Php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.