How to automatically read in calculated values with PHPExcel?
getCalculatedValue() seems to work for all cells, see above
getCalculatedValue() seems to work for all cells, see above
Use setSize method instead setFontSize, it should work: $objPHPExcel->getActiveSheet()->getStyle(“F1:G1”)->getFont()->setSize(16);
$objPHPExcel->setActiveSheetIndex(0)->getHighestColumn(); and $objPHPExcel->setActiveSheetIndex(0)->getHighestRow(); or $objPHPExcel->setActiveSheetIndex(0)->calculateWorksheetDimension(); which returns a range as a string like A1:AC2048 although trailing blank rows and columns are included in these. EDIT or you can use the iterators to loop through the existing rows and columns to get each cell within the worksheets used range. See /Tests/28iterator.php in the production distribution for … Read more
That error is just telling you that there was no buffer to delete. To avoid it just use: if (ob_get_contents()) ob_end_clean(); (check if there’s an active output buffer) or: if (ob_get_length()) ob_end_clean(); (checks if there’s a non empty string in the buffer) as suggested by @Venu. also you are calling ob_end_clean(); two times there. And … Read more
There is a specific method to do this: $objPHPExcel->getActiveSheet()->mergeCells(‘A1:C1’); You can also use: $objPHPExcel->setActiveSheetIndex(0)->mergeCells(‘A1:C1’); That should do the trick.
$excel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1); Should set the row height to ‘auto’ for row 1.
Is it populating the worksheet? or saving? that you find too slow? How are you populating the spreadsheet with the data? Using the fromArray() method is more efficient than populating each individual cell, especially if you use the Advanced Value Binder to set cell datatypes automatically. If you’re setting values for every individual cell in … Read more
I asume you have connected to your database already. $sql = “SELECT * FROM my_table”; $result = mysql_query($sql); $row = 1; // 1-based index while($row_data = mysql_fetch_assoc($result)) { $col = 0; foreach($row_data as $key=>$value) { $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value); $col++; } $row++; }
I assume you’re trying to Freeze columns and rows both. freezePane will obviously overwrite any previous parameters you might have given to it. As per your current scenario, I see that you’re trying to freeze the top row and the left-most 3 columns Try this: $objPHPExcel->getActiveSheet()->freezePane(‘D2’); This will freeze Row 1 and Columns A,B & … Read more
I recommend you start reading the documentation (4.6.18. Formatting cells). When applying a lot of formatting it’s better to use applyFromArray() According to the documentation this method is also suppose to be faster when you’re setting many style properties. There’s an annex where you can find all the possible keys for this function. This will … Read more