inactive sheets gets blank after update excel

Topics: Developer Forum
Mar 15, 2013 at 8:35 AM
hi,

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
Coordinator
Mar 15, 2013 at 9: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 9: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);
            $excel2->setActiveSheetIndex(0);

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

            $objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel2007');
            //$objWriter->setIncludeCharts(TRUE);
            $objWriter->save($filename);
Mar 15, 2013 at 9:40 AM
is it ok now or i hv to explore it bit more....
Mar 15, 2013 at 9:49 AM
is it ok now or i hv to explore it bit more....
Coordinator
Mar 15, 2013 at 11:14 AM
It would be useful if you could upload a copy of your sample_excel.xlsx to http://phpexcel.codeplex.com/workitem/10749?ProjectName=phpexcel
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);
$excel2->setActiveSheetIndex(0);

would be better