Beispiel #1
0
 /**
  * Read FOOTER record
  */
 private function _readFooter()
 {
     $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
     $recordData = substr($this->_data, $this->_pos + 4, $length);
     // move stream pointer to next record
     $this->_pos += 4 + $length;
     if (!$this->_readDataOnly) {
         // offset: 0; size: var
         // realized that $recordData can be empty even when record exists
         if ($recordData) {
             if ($this->_version == self::XLS_BIFF8) {
                 $string = $this->_readUnicodeStringLong($recordData);
             } else {
                 $string = $this->_readByteStringShort($recordData);
             }
             $this->_phpSheet->getHeaderFooter()->setOddFooter($string['value']);
             $this->_phpSheet->getHeaderFooter()->setEvenFooter($string['value']);
         }
     }
 }
Beispiel #2
0
 /**
  * Store the footer caption BIFF record.
  */
 private function _writeFooter()
 {
     $record = 0x15;
     // Record identifier
     /* removing for now
     		// need to fix character count (multibyte!)
     		if (strlen($this->_phpSheet->getHeaderFooter()->getOddFooter()) <= 255) {
     			$str = $this->_phpSheet->getHeaderFooter()->getOddFooter();
     		} else {
     			$str = '';
     		}
     		*/
     if ($this->_BIFF_version == 0x600) {
         $recordData = Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddFooter());
         $length = strlen($recordData);
     } else {
         $cch = strlen($this->_phpSheet->getHeaderFooter()->getOddFooter());
         // Length of footer string
         $length = 1 + $cch;
         $data = pack("C", $cch);
         $recordData = $data . $this->_phpSheet->getHeaderFooter()->getOddFooter();
     }
     $header = pack("vv", $record, $length);
     $this->_append($header . $recordData);
 }
Beispiel #3
0
 /**
  * Write header/footer drawing relationships to XML format
  *
  * @param 	Worksheet			$pWorksheet
  * @return 	string 						XML Output
  * @throws 	Exception
  */
 public function writeHeaderFooterDrawingRelationships(Worksheet $pWorksheet = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new Shared_XMLWriter(Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new Shared_XMLWriter(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');
     // Loop through images and write relationships
     foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
         // Write relationship for image drawing
         $this->_writeRelationship($objWriter, $key, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $value->getIndexedFilename());
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Beispiel #4
0
 /**
  * Write VML header/footer images to XML format
  *
  * @param 	Worksheet				$pWorksheet
  * @return 	string 								XML Output
  * @throws 	Exception
  */
 public function writeVMLHeaderFooterImages(Worksheet $pWorksheet = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new Shared_XMLWriter(Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new Shared_XMLWriter(Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Header/footer images
     $images = $pWorksheet->getHeaderFooter()->getImages();
     // xml
     $objWriter->startElement('xml');
     $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
     $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
     $objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
     // o:shapelayout
     $objWriter->startElement('o:shapelayout');
     $objWriter->writeAttribute('v:ext', 'edit');
     // o:idmap
     $objWriter->startElement('o:idmap');
     $objWriter->writeAttribute('v:ext', 'edit');
     $objWriter->writeAttribute('data', '1');
     $objWriter->endElement();
     $objWriter->endElement();
     // v:shapetype
     $objWriter->startElement('v:shapetype');
     $objWriter->writeAttribute('id', '_x0000_t75');
     $objWriter->writeAttribute('coordsize', '21600,21600');
     $objWriter->writeAttribute('o:spt', '75');
     $objWriter->writeAttribute('o:preferrelative', 't');
     $objWriter->writeAttribute('path', 'm@4@5l@4@11@9@11@9@5xe');
     $objWriter->writeAttribute('filled', 'f');
     $objWriter->writeAttribute('stroked', 'f');
     // v:stroke
     $objWriter->startElement('v:stroke');
     $objWriter->writeAttribute('joinstyle', 'miter');
     $objWriter->endElement();
     // v:formulas
     $objWriter->startElement('v:formulas');
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'if lineDrawn pixelLineWidth 0');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'sum @0 1 0');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'sum 0 0 @1');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'prod @2 1 2');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'prod @3 21600 pixelWidth');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'prod @3 21600 pixelHeight');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'sum @0 0 1');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'prod @6 1 2');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'prod @7 21600 pixelWidth');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'sum @8 21600 0');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'prod @7 21600 pixelHeight');
     $objWriter->endElement();
     // v:f
     $objWriter->startElement('v:f');
     $objWriter->writeAttribute('eqn', 'sum @10 21600 0');
     $objWriter->endElement();
     $objWriter->endElement();
     // v:path
     $objWriter->startElement('v:path');
     $objWriter->writeAttribute('o:extrusionok', 'f');
     $objWriter->writeAttribute('gradientshapeok', 't');
     $objWriter->writeAttribute('o:connecttype', 'rect');
     $objWriter->endElement();
     // o:lock
     $objWriter->startElement('o:lock');
     $objWriter->writeAttribute('v:ext', 'edit');
     $objWriter->writeAttribute('aspectratio', 't');
     $objWriter->endElement();
     $objWriter->endElement();
     // Loop through images
     foreach ($images as $key => $value) {
         $this->_writeVMLHeaderFooterImage($objWriter, $key, $value);
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Beispiel #5
0
 /**
  * Write LegacyDrawingHF
  *
  * @param	Shared_XMLWriter		$objWriter		XML Writer
  * @param	Worksheet				$pSheet			Worksheet
  * @throws	Exception
  */
 private function _writeLegacyDrawingHF(Shared_XMLWriter $objWriter = null, Worksheet $pSheet = null)
 {
     // If sheet contains comments, add the relationships
     if (count($pSheet->getHeaderFooter()->getImages()) > 0) {
         $objWriter->startElement('legacyDrawingHF');
         $objWriter->writeAttribute('r:id', 'rId_headerfooter_vml1');
         $objWriter->endElement();
     }
 }