ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Writer_Excel2007_Rels Class Reference
+ Inheritance diagram for PHPExcel_Writer_Excel2007_Rels:
+ Collaboration diagram for PHPExcel_Writer_Excel2007_Rels:

Public Member Functions

 writeRelationships (PHPExcel $pPHPExcel=null)
 Write relationships to XML format. More...
 
 writeWorkbookRelationships (PHPExcel $pPHPExcel=null)
 Write workbook relationships to XML format. More...
 
 writeWorksheetRelationships (PHPExcel_Worksheet $pWorksheet=null, $pWorksheetId=1, $includeCharts=FALSE)
 Write worksheet relationships to XML format. More...
 
 writeDrawingRelationships (PHPExcel_Worksheet $pWorksheet=null, &$chartRef, $includeCharts=FALSE)
 Write drawing relationships to XML format. More...
 
 writeHeaderFooterDrawingRelationships (PHPExcel_Worksheet $pWorksheet=null)
 Write header/footer drawing relationships to XML format. More...
 
- Public Member Functions inherited from PHPExcel_Writer_Excel2007_WriterPart
 setParentWriter (PHPExcel_Writer_IWriter $pWriter=null)
 Set parent IWriter object. More...
 
 getParentWriter ()
 Get parent IWriter object. More...
 
 __construct (PHPExcel_Writer_IWriter $pWriter=null)
 Set parent IWriter object. More...
 

Private Member Functions

 _writeRelationship (PHPExcel_Shared_XMLWriter $objWriter=null, $pId=1, $pType='', $pTarget='', $pTargetMode='')
 Write Override content type. More...
 

Detailed Description

Definition at line 36 of file Rels.php.

Member Function Documentation

◆ _writeRelationship()

PHPExcel_Writer_Excel2007_Rels::_writeRelationship ( PHPExcel_Shared_XMLWriter  $objWriter = null,
  $pId = 1,
  $pType = '',
  $pTarget = '',
  $pTargetMode = '' 
)
private

Write Override content type.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
int$pIdRelationship ID. rId will be prepended!
string$pTypeRelationship type
string$pTargetRelationship target
string$pTargetModeRelationship target mode
Exceptions
PHPExcel_Writer_Exception

Definition at line 419 of file Rels.php.

References $objWriter.

Referenced by writeDrawingRelationships(), writeHeaderFooterDrawingRelationships(), writeRelationships(), writeWorkbookRelationships(), and writeWorksheetRelationships().

420  {
421  if ($pType != '' && $pTarget != '') {
422  // Write relationship
423  $objWriter->startElement('Relationship');
424  $objWriter->writeAttribute('Id', 'rId' . $pId);
425  $objWriter->writeAttribute('Type', $pType);
426  $objWriter->writeAttribute('Target', $pTarget);
427 
428  if ($pTargetMode != '') {
429  $objWriter->writeAttribute('TargetMode', $pTargetMode);
430  }
431 
432  $objWriter->endElement();
433  } else {
434  throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
435  }
436  }
+ Here is the caller graph for this function:

◆ writeDrawingRelationships()

PHPExcel_Writer_Excel2007_Rels::writeDrawingRelationships ( PHPExcel_Worksheet  $pWorksheet = null,
$chartRef,
  $includeCharts = FALSE 
)

Write drawing relationships to XML format.

Parameters
PHPExcel_Worksheet$pWorksheet
int&$chartRefChart ID
boolean$includeChartsFlag indicating if we should write charts
Returns
string XML Output
Exceptions
PHPExcel_Writer_Exception

Definition at line 311 of file Rels.php.

References $objWriter, _writeRelationship(), PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Shared_XMLWriter\STORAGE_DISK, and PHPExcel_Shared_XMLWriter\STORAGE_MEMORY.

312  {
313  // Create XML writer
314  $objWriter = null;
315  if ($this->getParentWriter()->getUseDiskCaching()) {
317  } else {
319  }
320 
321  // XML header
322  $objWriter->startDocument('1.0','UTF-8','yes');
323 
324  // Relationships
325  $objWriter->startElement('Relationships');
326  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
327 
328  // Loop through images and write relationships
329  $i = 1;
330  $iterator = $pWorksheet->getDrawingCollection()->getIterator();
331  while ($iterator->valid()) {
332  if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing
333  || $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) {
334  // Write relationship for image drawing
335  $this->_writeRelationship(
336  $objWriter,
337  $i,
338  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
339  '../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
340  );
341  }
342 
343  $iterator->next();
344  ++$i;
345  }
346 
347  if ($includeCharts) {
348  // Loop through charts and write relationships
349  $chartCount = $pWorksheet->getChartCount();
350  if ($chartCount > 0) {
351  for ($c = 0; $c < $chartCount; ++$c) {
352  $this->_writeRelationship(
353  $objWriter,
354  $i++,
355  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
356  '../charts/chart' . ++$chartRef . '.xml'
357  );
358  }
359  }
360  }
361 
362  $objWriter->endElement();
363 
364  // Return
365  return $objWriter->getData();
366  }
getDrawingCollection()
Get collection of drawings.
Definition: Worksheet.php:554
getChartCount()
Return the count of charts on this worksheet.
Definition: Worksheet.php:594
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
$objWriter
_writeRelationship(PHPExcel_Shared_XMLWriter $objWriter=null, $pId=1, $pType='', $pTarget='', $pTargetMode='')
Write Override content type.
Definition: Rels.php:419
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
+ Here is the call graph for this function:

◆ writeHeaderFooterDrawingRelationships()

PHPExcel_Writer_Excel2007_Rels::writeHeaderFooterDrawingRelationships ( PHPExcel_Worksheet  $pWorksheet = null)

Write header/footer drawing relationships to XML format.

Parameters
PHPExcel_Worksheet$pWorksheet
Returns
string XML Output
Exceptions
PHPExcel_Writer_Exception

Definition at line 375 of file Rels.php.

References $objWriter, _writeRelationship(), PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Shared_XMLWriter\STORAGE_DISK, and PHPExcel_Shared_XMLWriter\STORAGE_MEMORY.

376  {
377  // Create XML writer
378  $objWriter = null;
379  if ($this->getParentWriter()->getUseDiskCaching()) {
381  } else {
383  }
384 
385  // XML header
386  $objWriter->startDocument('1.0','UTF-8','yes');
387 
388  // Relationships
389  $objWriter->startElement('Relationships');
390  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
391 
392  // Loop through images and write relationships
393  foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
394  // Write relationship for image drawing
395  $this->_writeRelationship(
396  $objWriter,
397  $key,
398  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
399  '../media/' . $value->getIndexedFilename()
400  );
401  }
402 
403  $objWriter->endElement();
404 
405  // Return
406  return $objWriter->getData();
407  }
getHeaderFooter()
Get page header/footer.
Definition: Worksheet.php:958
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
$objWriter
_writeRelationship(PHPExcel_Shared_XMLWriter $objWriter=null, $pId=1, $pType='', $pTarget='', $pTargetMode='')
Write Override content type.
Definition: Rels.php:419
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
+ Here is the call graph for this function:

◆ writeRelationships()

PHPExcel_Writer_Excel2007_Rels::writeRelationships ( PHPExcel  $pPHPExcel = null)

Write relationships to XML format.

Parameters
PHPExcel$pPHPExcel
Returns
string XML Output
Exceptions
PHPExcel_Writer_Exception

Definition at line 45 of file Rels.php.

References $objWriter, _writeRelationship(), PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Shared_XMLWriter\STORAGE_DISK, and PHPExcel_Shared_XMLWriter\STORAGE_MEMORY.

46  {
47  // Create XML writer
48  $objWriter = null;
49  if ($this->getParentWriter()->getUseDiskCaching()) {
51  } else {
53  }
54 
55  // XML header
56  $objWriter->startDocument('1.0','UTF-8','yes');
57 
58  // Relationships
59  $objWriter->startElement('Relationships');
60  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
61 
62  $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
63  if (!empty($customPropertyList)) {
64  // Relationship docProps/app.xml
65  $this->_writeRelationship(
66  $objWriter,
67  4,
68  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
69  'docProps/custom.xml'
70  );
71 
72  }
73 
74  // Relationship docProps/app.xml
75  $this->_writeRelationship(
76  $objWriter,
77  3,
78  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
79  'docProps/app.xml'
80  );
81 
82  // Relationship docProps/core.xml
83  $this->_writeRelationship(
84  $objWriter,
85  2,
86  'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
87  'docProps/core.xml'
88  );
89 
90  // Relationship xl/workbook.xml
91  $this->_writeRelationship(
92  $objWriter,
93  1,
94  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
95  'xl/workbook.xml'
96  );
97  // a custom UI in workbook ?
98  if($pPHPExcel->hasRibbon()){
99  $this->_writeRelationShip(
100  $objWriter,
101  5,
102  'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
103  $pPHPExcel->getRibbonXMLData('target')
104  );
105  }
106 
107  $objWriter->endElement();
108 
109  // Return
110  return $objWriter->getData();
111  }
hasRibbon()
This workbook have a custom UI ?
Definition: PHPExcel.php:312
getProperties()
Get properties.
Definition: PHPExcel.php:425
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
$objWriter
_writeRelationship(PHPExcel_Shared_XMLWriter $objWriter=null, $pId=1, $pType='', $pTarget='', $pTargetMode='')
Write Override content type.
Definition: Rels.php:419
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
getRibbonXMLData($What='all')
retrieve ribbon XML Data
Definition: PHPExcel.php:243
+ Here is the call graph for this function:

◆ writeWorkbookRelationships()

PHPExcel_Writer_Excel2007_Rels::writeWorkbookRelationships ( PHPExcel  $pPHPExcel = null)

Write workbook relationships to XML format.

Parameters
PHPExcel$pPHPExcel
Returns
string XML Output
Exceptions
PHPExcel_Writer_Exception

Definition at line 120 of file Rels.php.

References $objWriter, _writeRelationship(), PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Shared_XMLWriter\STORAGE_DISK, and PHPExcel_Shared_XMLWriter\STORAGE_MEMORY.

121  {
122  // Create XML writer
123  $objWriter = null;
124  if ($this->getParentWriter()->getUseDiskCaching()) {
126  } else {
128  }
129 
130  // XML header
131  $objWriter->startDocument('1.0','UTF-8','yes');
132 
133  // Relationships
134  $objWriter->startElement('Relationships');
135  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
136 
137  // Relationship styles.xml
138  $this->_writeRelationship(
139  $objWriter,
140  1,
141  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
142  'styles.xml'
143  );
144 
145  // Relationship theme/theme1.xml
146  $this->_writeRelationship(
147  $objWriter,
148  2,
149  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
150  'theme/theme1.xml'
151  );
152 
153  // Relationship sharedStrings.xml
154  $this->_writeRelationship(
155  $objWriter,
156  3,
157  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
158  'sharedStrings.xml'
159  );
160 
161  // Relationships with sheets
162  $sheetCount = $pPHPExcel->getSheetCount();
163  for ($i = 0; $i < $sheetCount; ++$i) {
164  $this->_writeRelationship(
165  $objWriter,
166  ($i + 1 + 3),
167  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
168  'worksheets/sheet' . ($i + 1) . '.xml'
169  );
170  }
171  // Relationships for vbaProject if needed
172  // id : just after the last sheet
173  if($pPHPExcel->hasMacros()){
174  $this->_writeRelationShip(
175  $objWriter,
176  ($i + 1 + 3),
177  'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
178  'vbaProject.bin'
179  );
180  ++$i;//increment i if needed for an another relation
181  }
182 
183  $objWriter->endElement();
184 
185  // Return
186  return $objWriter->getData();
187  }
getSheetCount()
Get sheet count.
Definition: PHPExcel.php:661
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
$objWriter
hasMacros()
The workbook has macros ?
Definition: PHPExcel.php:155
_writeRelationship(PHPExcel_Shared_XMLWriter $objWriter=null, $pId=1, $pType='', $pTarget='', $pTargetMode='')
Write Override content type.
Definition: Rels.php:419
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
+ Here is the call graph for this function:

◆ writeWorksheetRelationships()

PHPExcel_Writer_Excel2007_Rels::writeWorksheetRelationships ( PHPExcel_Worksheet  $pWorksheet = null,
  $pWorksheetId = 1,
  $includeCharts = FALSE 
)

Write worksheet relationships to XML format.

Numbering is as follows: rId1 - Drawings rId_hyperlink_x - Hyperlinks

Parameters
PHPExcel_Worksheet$pWorksheet
int$pWorksheetId
boolean$includeChartsFlag indicating if we should write charts
Returns
string XML Output
Exceptions
PHPExcel_Writer_Exception

Definition at line 202 of file Rels.php.

References $d, $objWriter, _writeRelationship(), array, PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Shared_XMLWriter\STORAGE_DISK, and PHPExcel_Shared_XMLWriter\STORAGE_MEMORY.

203  {
204  // Create XML writer
205  $objWriter = null;
206  if ($this->getParentWriter()->getUseDiskCaching()) {
208  } else {
210  }
211 
212  // XML header
213  $objWriter->startDocument('1.0','UTF-8','yes');
214 
215  // Relationships
216  $objWriter->startElement('Relationships');
217  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
218 
219  // Write drawing relationships?
220  $d = 0;
221  if ($includeCharts) {
222  $charts = $pWorksheet->getChartCollection();
223  } else {
224  $charts = array();
225  }
226  if (($pWorksheet->getDrawingCollection()->count() > 0) ||
227  (count($charts) > 0)) {
228  $this->_writeRelationship(
229  $objWriter,
230  ++$d,
231  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
232  '../drawings/drawing' . $pWorksheetId . '.xml'
233  );
234  }
235 
236  // Write chart relationships?
237 // $chartCount = 0;
238 // $charts = $pWorksheet->getChartCollection();
239 // echo 'Chart Rels: ' , count($charts) , '<br />';
240 // if (count($charts) > 0) {
241 // foreach($charts as $chart) {
242 // $this->_writeRelationship(
243 // $objWriter,
244 // ++$d,
245 // 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
246 // '../charts/chart' . ++$chartCount . '.xml'
247 // );
248 // }
249 // }
250 //
251  // Write hyperlink relationships?
252  $i = 1;
253  foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
254  if (!$hyperlink->isInternal()) {
255  $this->_writeRelationship(
256  $objWriter,
257  '_hyperlink_' . $i,
258  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
259  $hyperlink->getUrl(),
260  'External'
261  );
262 
263  ++$i;
264  }
265  }
266 
267  // Write comments relationship?
268  $i = 1;
269  if (count($pWorksheet->getComments()) > 0) {
270  $this->_writeRelationship(
271  $objWriter,
272  '_comments_vml' . $i,
273  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
274  '../drawings/vmlDrawing' . $pWorksheetId . '.vml'
275  );
276 
277  $this->_writeRelationship(
278  $objWriter,
279  '_comments' . $i,
280  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
281  '../comments' . $pWorksheetId . '.xml'
282  );
283  }
284 
285  // Write header/footer relationship?
286  $i = 1;
287  if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) {
288  $this->_writeRelationship(
289  $objWriter,
290  '_headerfooter_vml' . $i,
291  'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
292  '../drawings/vmlDrawingHF' . $pWorksheetId . '.vml'
293  );
294  }
295 
296  $objWriter->endElement();
297 
298  // Return
299  return $objWriter->getData();
300  }
getDrawingCollection()
Get collection of drawings.
Definition: Worksheet.php:554
getHeaderFooter()
Get page header/footer.
Definition: Worksheet.php:958
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
for($col=0; $col< 50; $col++) $d
getHyperlinkCollection()
Get collection of hyperlinks.
Definition: Worksheet.php:2719
$objWriter
getComments()
Get comments.
Definition: Worksheet.php:2225
Create styles array
The data for the language used.
getChartCollection()
Get collection of charts.
Definition: Worksheet.php:564
_writeRelationship(PHPExcel_Shared_XMLWriter $objWriter=null, $pId=1, $pType='', $pTarget='', $pTargetMode='')
Write Override content type.
Definition: Rels.php:419
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
+ Here is the call graph for this function:

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