How can to read the value of a cell of a new .xlsx?

Topics: Developer Forum
Aug 23, 2014 at 4:54 AM

I have created an .xlsx file with about 2500 cells on it, now I'm in need of read and update the value of few cells that were created on that new file. I know what are the cells to change, is it possible to do it on the fly without loading the file to be read?

Aug 26, 2014 at 4:35 PM
Replying my own question...

Yes it is possible. Use $phpexcel->getActiveSheet()->getCellByColumnAndRow($x,$y), where $x is the column and $y is the row; then you can update it again: $phpexcel->setActiveSheetIndex($this->sheet_1)->setCellValue($col.$row, $new_value);

This is a simple script to debug the cell cordinates of the current excel being created:
  private function debugCellCoordinates() {
    echo '<table border="1">';
    for ($y=0; $y<=150; $y++) {
      echo '<tr>';
      for ($x=0; $x<=17; $x++) {
        if($y==0) {
          echo '<td>['.$x.']</td>';
        } else if($x==0) {
          echo '<td>['.$y.']</td>';
        if($y>0) {
          echo '<td>'.$this->phpexcel->getActiveSheet()->getCellByColumnAndRow($x,$y).'</td>';
      echo '</tr>';
    echo '</table>';