public function PHPExcel_Writer_Excel2007_Rels::writeWorksheetRelationships in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Rels.php \PHPExcel_Writer_Excel2007_Rels::writeWorksheetRelationships()
* Write worksheet relationships to XML format * * Numbering is as follows: * rId1 - Drawings * rId_hyperlink_x - Hyperlinks * *
Parameters
PHPExcel_Worksheet $pWorksheet: * @param int $pWorksheetId * @param boolean $includeCharts Flag indicating if we should write charts * @return string XML Output * @throws PHPExcel_Writer_Exception
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel2007/ Rels.php, line 202
Class
- PHPExcel_Writer_Excel2007_Rels
- PHPExcel_Writer_Excel2007_Rels
Code
public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE) {
// Create XML writer
$objWriter = null;
if ($this
->getParentWriter()
->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this
->getParentWriter()
->getDiskCachingDirectory());
}
else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter
->startDocument('1.0', 'UTF-8', 'yes');
// Relationships
$objWriter
->startElement('Relationships');
$objWriter
->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Write drawing relationships?
$d = 0;
if ($includeCharts) {
$charts = $pWorksheet
->getChartCollection();
}
else {
$charts = array();
}
if ($pWorksheet
->getDrawingCollection()
->count() > 0 || count($charts) > 0) {
$this
->_writeRelationship($objWriter, ++$d, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', '../drawings/drawing' . $pWorksheetId . '.xml');
}
// Write chart relationships?
// $chartCount = 0;
// $charts = $pWorksheet->getChartCollection();
// echo 'Chart Rels: ' , count($charts) , '<br />';
// if (count($charts) > 0) {
// foreach($charts as $chart) {
// $this->_writeRelationship(
// $objWriter,
// ++$d,
// 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
// '../charts/chart' . ++$chartCount . '.xml'
// );
// }
// }
//
// Write hyperlink relationships?
$i = 1;
foreach ($pWorksheet
->getHyperlinkCollection() as $hyperlink) {
if (!$hyperlink
->isInternal()) {
$this
->_writeRelationship($objWriter, '_hyperlink_' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink
->getUrl(), 'External');
++$i;
}
}
// Write comments relationship?
$i = 1;
if (count($pWorksheet
->getComments()) > 0) {
$this
->_writeRelationship($objWriter, '_comments_vml' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', '../drawings/vmlDrawing' . $pWorksheetId . '.vml');
$this
->_writeRelationship($objWriter, '_comments' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', '../comments' . $pWorksheetId . '.xml');
}
// Write header/footer relationship?
$i = 1;
if (count($pWorksheet
->getHeaderFooter()
->getImages()) > 0) {
$this
->_writeRelationship($objWriter, '_headerfooter_vml' . $i, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', '../drawings/vmlDrawingHF' . $pWorksheetId . '.vml');
}
$objWriter
->endElement();
// Return
return $objWriter
->getData();
}