src/SimpleExcel/Writer/CSVWriter.php 0000666 00000002513 13436754727 0013411 0 ustar 00 tabl_data as $row) {
fputcsv($fp, $row, $this->delimiter);
}
rewind($fp);
$content = stream_get_contents($fp);
fclose($fp);
return $content;
}
/**
* Set character for delimiter
*
* @param string $delimiter Commonly used character can be a comma, semicolon, tab, or space
* @return void
*/
public function setDelimiter($delimiter){
$this->delimiter = $delimiter;
}
}
?>
src/SimpleExcel/Writer/XMLWriter.php 0000666 00000007134 13436754727 0013422 0 ustar 00 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.''.$propname.'>';
}
$content .= '
';
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;
}
}
?>
src/SimpleExcel/Writer/IWriter.php 0000666 00000000540 13436754727 0013144 0 ustar 00