doc_prop = array( 'Author' => 'SimpleExcel', 'Company' => 'SimpleExcel', 'Created' => gmdate("Y-m-d\TH:i:s\Z"), 'Keywords' => 'SimpleExcel', 'LastAuthor' => 'SimpleExcel', 'Version' => '12.00' ); } /** * Adding row data to XML * * @param array $values An array contains ordered value for every cell * @return void */ public function addRow($values){ $row = &$this->tabl_data; $row .= ' '; foreach($values as $val){ $value = ''; $datatype = 'String'; // check if given variable contains array if(is_array($val)){ $value = $val[0]; $datatype = $val[1]; } else { $value = $val; $datatype = is_numeric($val) ? 'Number' : 'String'; } // escape value from HTML tags $value = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS); $row .= ' '.$value.''; } $row .= ' '; } /** * Get document content as string * * @return string Content of document */ public function saveString(){ $content = ' '; foreach($this->doc_prop as $propname => $propval){ $content .= ' <'.$propname.'>'.$propval.''; } $content .= ' '.$this->tabl_data.'
'; return $content; } /** * Set XML data * * @param array $values An array contains ordered value of arrays for all fields * @return void */ public function setData($values){ if(!is_array($values)){ $values = array($values); } $this->tabl_data = ""; // reset the xml data. // append values as rows foreach ($values as $value) { $this->addRow($value); } } /** * Set a document property of the XML * * @param string $prop Document property to be set * @param string $val Value of the document property * @return void */ public function setDocProp($prop, $val){ $this->doc_prop[$prop] = $val; } } ?>