ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
SimpleExcel\Writer\XMLWriter Class Reference
+ Inheritance diagram for SimpleExcel\Writer\XMLWriter:
+ Collaboration diagram for SimpleExcel\Writer\XMLWriter:

Public Member Functions

 __construct ()
 
 addRow ($values)
 Adding row data to XML. More...
 
 saveString ()
 Get document content as string. More...
 
 setData ($values)
 Set XML data. More...
 
 setDocProp ($prop, $val)
 Set a document property of the XML. More...
 
- Public Member Functions inherited from SimpleExcel\Writer\BaseWriter
 __construct ()
 
 addRow ($values)
 Adding row data to table. More...
 
 saveString ()
 Get document content as string. More...
 
 saveFile ($filename, $target=NULL)
 Export the document. More...
 
 setData ($values)
 Set tabular data. More...
 

Protected Attributes

 $content_type = 'application/xml'
 
 $file_extension = 'xml'
 
- Protected Attributes inherited from SimpleExcel\Writer\BaseWriter
 $tabl_data
 
 $content_type = 'text'
 
 $file_extension = 'txt'
 

Private Attributes

 $doc_prop
 

Detailed Description

Definition at line 11 of file XMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleExcel\Writer\XMLWriter::__construct ( )
Returns
void

Definition at line 40 of file XMLWriter.php.

40  {
41  $this->doc_prop = array(
42  'Author' => 'SimpleExcel',
43  'Company' => 'SimpleExcel',
44  'Created' => gmdate("Y-m-d\TH:i:s\Z"),
45  'Keywords' => 'SimpleExcel',
46  'LastAuthor' => 'SimpleExcel',
47  'Version' => '12.00'
48  );
49  }

Member Function Documentation

◆ addRow()

SimpleExcel\Writer\XMLWriter::addRow (   $values)

Adding row data to XML.

Parameters
array$valuesAn array contains ordered value for every cell
Returns
void

Implements SimpleExcel\Writer\IWriter.

Definition at line 57 of file XMLWriter.php.

References $row, and SimpleExcel\Writer\BaseWriter\$tabl_data.

Referenced by SimpleExcel\Writer\XMLWriter\setData().

57  {
59  $row .= '
60  <Row ss:AutoFitHeight="0">';
61 
62  foreach($values as $val){
63 
64  $value = '';
65  $datatype = 'String';
66 
67  // check if given variable contains array
68  if(is_array($val)){
69  $value = $val[0];
70  $datatype = $val[1];
71  } else {
72  $value = $val;
73  $datatype = is_string($val) ? 'String' : (is_numeric($val) ? 'Number' : 'String');
74  }
75 
76  // escape value from HTML tags
77  $value = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
78 
79  $row .= '
80  <Cell><Data ss:Type="'.$datatype.'">'.$value.'</Data></Cell>';
81  }
82 
83  $row .= '
84  </Row>';
85  }
+ Here is the caller graph for this function:

◆ saveString()

SimpleExcel\Writer\XMLWriter::saveString ( )

Get document content as string.

Returns
string Content of document

Implements SimpleExcel\Writer\IWriter.

Definition at line 92 of file XMLWriter.php.

92  {
93  $content = '<?xml version="1.0"?>
94 <?mso-application progid="Excel.Sheet"?>
95 <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
96  xmlns:o="urn:schemas-microsoft-com:office:office"
97  xmlns:x="urn:schemas-microsoft-com:office:excel"
98  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
99  xmlns:html="http://www.w3.org/TR/REC-html40">
100  <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">';
101 
102  foreach($this->doc_prop as $propname => $propval){
103  $content .= '
104  <'.$propname.'>'.$propval.'</'.$propname.'>';
105  }
106 
107  $content .= '
108  </DocumentProperties>
109  <Worksheet ss:Name="Sheet1">
110  <Table>'.$this->tabl_data.'
111  </Table>
112  </Worksheet>
113 </Workbook>';
114  return $content;
115  }

◆ setData()

SimpleExcel\Writer\XMLWriter::setData (   $values)

Set XML data.

Parameters
array$valuesAn array contains ordered value of arrays for all fields
Returns
void

Implements SimpleExcel\Writer\IWriter.

Definition at line 123 of file XMLWriter.php.

References SimpleExcel\Writer\XMLWriter\addRow().

123  {
124  if(!is_array($values)){
125  $values = array($values);
126  }
127  $this->tabl_data = ""; // reset the xml data.
128 
129  // append values as rows
130  foreach ($values as $value) {
131  $this->addRow($value);
132  }
133  }
addRow($values)
Adding row data to XML.
Definition: XMLWriter.php:57
+ Here is the call graph for this function:

◆ setDocProp()

SimpleExcel\Writer\XMLWriter::setDocProp (   $prop,
  $val 
)

Set a document property of the XML.

Parameters
string$propDocument property to be set
string$valValue of the document property
Returns
void

Definition at line 142 of file XMLWriter.php.

142  {
143  $this->doc_prop[$prop] = $val;
144  }

Field Documentation

◆ $content_type

SimpleExcel\Writer\XMLWriter::$content_type = 'application/xml'
protected

Definition at line 19 of file XMLWriter.php.

◆ $doc_prop

SimpleExcel\Writer\XMLWriter::$doc_prop
private

Definition at line 35 of file XMLWriter.php.

◆ $file_extension

SimpleExcel\Writer\XMLWriter::$file_extension = 'xml'
protected

Definition at line 27 of file XMLWriter.php.


The documentation for this class was generated from the following file: