inactive sheets gets blank after update excel

Topics: Developer Forum
Mar 15, 2013 at 9:35 AM

i am using phpexcel library to read and write excel file having some formulas reading file works great but when i update some fields in active sheet data from other sheets gets deleted and these sheets gets blank.

in that active sheet i am calculating values using data from inactive(sheet no. 2/3), so i am getting wrong calculated values
Mar 15, 2013 at 10:19 AM
Can you please explain in simple steps what you're doing, what your formulas are, what you expect, and what you actually get.

Otherwise, all you're telling me is that there is a bug somewhere in PHPExcel, and expecting me to sort through 50,000 lines of code without knowing what I'm looking for
Mar 15, 2013 at 10:39 AM
i have a excel doc which has multiple sheets in it, and i have two separate tables as input table and output table on first sheet1,
output table gives calculated values using values from input table on sheet1 and formulas present on sheet2 and sheet3 in same doc,
i want to update values in input table on sheet1 and get calculate values from output table on same sheet by using formulas present on sheet2 and sheet3.
but when i update my input table present on sheet1 using php, sheet2 and sheet3 goes blank.

this is my code, is anything wrong in code....
    include APPLICATION_PATH.'../../library/Zend/PHPExcel/Classes/PHPExcel.php';
include APPLICATION_PATH.'../../library/Zend/PHPExcel/Classes/PHPExcel/IOFactory.php';

            $excel2 = PHPExcel_IOFactory::createReader('Excel2007');
            $filename = '../library/Zend/PHPExcel/Classes/sample_excel.xlsx';
            $excel2 = $excel2->load($filename);

            foreach($arr as $key=>$value)
                $fieldVal = explode("=", $value);
                $excel2->getActiveSheet()->setCellValue($fieldVal[0], $fieldVal[1]);

            $objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel2007');
Mar 15, 2013 at 10:40 AM
is it ok now or i hv to explore it bit more....
Mar 15, 2013 at 10:49 AM
is it ok now or i hv to explore it bit more....
Mar 15, 2013 at 12:14 PM
It would be useful if you could upload a copy of your sample_excel.xlsx to
and also give me some idea of the data in your $arr array.

And codewise, you're using the same varname for the Reader and for the Workbook that it loads
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$filename = '../library/Zend/PHPExcel/Classes/sample_excel.xlsx';
$excel2 = $objReader->load($filename);

would be better