original_string: public function setCell($col_index, $row_index, $val, $type=null)
      {
  
              $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']/Data", $this->active_worksheet);
              $data = $result->item(0);
              $type = $type ? $type : $this->getValueType($val);
  
              if($data){
                  $data->setAttribute('ss:Type', $type);
                  $data->firstChild->nodeValue = $val;
              } else {
  
              $result = $this->xpath->query("//Row[@Index='".$row_index."']");
  
              $row = $result->item(0);
  
              if(!$row){
                  $row = $this->createElement('Row');
                  $this->active_worksheet->table->appendChild($row);
                  $row->setAttribute('Index', $row_index);
              }
  
              $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']", $row);
              $cell = $result->item(0);
              if(!$cell){
                  $cell = $this->createElement('Cell');
                  $row->appendChild($cell);
                  $cell->setAttribute('Index', $col_index);
                  $data = $this->createElement('Data');
                  $cell->appendChild($data);
                  $data->setAttribute('ss:Type', $type);
                  $data->appendChild($this->createTextNode($val));
              } else {
                  $data = $cell->getElementsByTagName('Data')->item(0);
                  $data->setAttribute('ss:Type', $type);
                  $data->firstChild->nodeValue = $val;
              }
  
              }
          return $data->parentNode;
  
      }
code: public function setCell($col_index, $row_index, $val, $type=null)
      {
  
              $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']/Data", $this->active_worksheet);
              $data = $result->item(0);
              $type = $type ? $type : $this->getValueType($val);
  
              if($data){
                  $data->setAttribute('ss:Type', $type);
                  $data->firstChild->nodeValue = $val;
              } else {
  
              $result = $this->xpath->query("//Row[@Index='".$row_index."']");
  
              $row = $result->item(0);
  
              if(!$row){
                  $row = $this->createElement('Row');
                  $this->active_worksheet->table->appendChild($row);
                  $row->setAttribute('Index', $row_index);
              }
  
              $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']", $row);
              $cell = $result->item(0);
              if(!$cell){
                  $cell = $this->createElement('Cell');
                  $row->appendChild($cell);
                  $cell->setAttribute('Index', $col_index);
                  $data = $this->createElement('Data');
                  $cell->appendChild($data);
                  $data->setAttribute('ss:Type', $type);
                  $data->appendChild($this->createTextNode($val));
              } else {
                  $data = $cell->getElementsByTagName('Data')->item(0);
                  $data->setAttribute('ss:Type', $type);
                  $data->firstChild->nodeValue = $val;
              }
  
              }
          return $data->parentNode;
  
      }
code_tokens: public function setCell ( $ col_index , $ row_index , $ val , $ type = null ) { $ result = $ this -> xpath -> query ( "//Row[@Index='" . $ row_index . "']/Cell[@Index='" . $ col_index . "']/Data" , $ this -> active_worksheet ) ; $ data = $ result -> item ( 0 ) ; $ type = $ type ? $ type : $ this -> getValueType ( $ val ) ; if ( $ data ) { $ data -> setAttribute ( 'ss:Type' , $ type ) ; $ data -> firstChild -> nodeValue = $ val ; } else { $ result = $ this -> xpath -> query ( "//Row[@Index='" . $ row_index . "']" ) ; $ row = $ result -> item ( 0 ) ; if ( ! $ row ) { $ row = $ this -> createElement ( 'Row' ) ; $ this -> active_worksheet -> table -> appendChild ( $ row ) ; $ row -> setAttribute ( 'Index' , $ row_index ) ; } $ result = $ this -> xpath -> query ( "//Row[@Index='" . $ row_index . "']/Cell[@Index='" . $ col_index . "']" , $ row ) ; $ cell = $ result -> item ( 0 ) ; if ( ! $ cell ) { $ cell = $ this -> createElement ( 'Cell' ) ; $ row -> appendChild ( $ cell ) ; $ cell -> setAttribute ( 'Index' , $ col_index ) ; $ data = $ this -> createElement ( 'Data' ) ; $ cell -> appendChild ( $ data ) ; $ data -> setAttribute ( 'ss:Type' , $ type ) ; $ data -> appendChild ( $ this -> createTextNode ( $ val ) ) ; } else { $ data = $ cell -> getElementsByTagName ( 'Data' ) -> item ( 0 ) ; $ data -> setAttribute ( 'ss:Type' , $ type ) ; $ data -> firstChild -> nodeValue = $ val ; } } return $ data -> parentNode ; }
docstring: Sets a cell by 1 based column and row index
  @param integer $col_index 1based column index
  @param integer $row_index 1 based row index
  @param mixed $val The value to insert
  @param string $type The ss:Type attribute
  @return DOMElement the cell itself
docstring_tokens: Sets a cell by 1 based column and row index