/**
  * Get the width of a column in pixels. We use the relationship y = ceil(7x) where
  * x is the width in intrinsic Excel units (measuring width in number of normal characters)
  * This holds for Arial 10
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param integer $col The column
  * @return integer The width in pixels
  */
 public static function sizeCol($sheet, $col = 'A')
 {
     $columnDimensions = $sheet->getColumnDimensions();
     // first find the true column width in pixels (uncollapsed and unhidden)
     if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
         // then we have column dimension with explicit width
         $columnDimension = $columnDimensions[$col];
         $width = $columnDimension->getWidth();
         $pixelWidth = (int) ceil(7 * $width);
         // here we assume Arial 10
     } else {
         if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
             // then we have default column dimension with explicit width
             $defaultColumnDimension = $sheet->getDefaultColumnDimension();
             $width = $defaultColumnDimension->getWidth();
             $pixelWidth = (int) ceil(7 * $width);
             // here we assume Arial 10
         } else {
             $pixelWidth = 64;
             // here we assume Arial 10
         }
     }
     // now find the effective column width in pixels
     if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
         $effectivePixelWidth = 0;
     } else {
         $effectivePixelWidth = $pixelWidth;
     }
     return $effectivePixelWidth;
 }
 /**
  * Get the width of a column in pixels. We use the relationship y = ceil(7x) where
  * x is the width in intrinsic Excel units (measuring width in number of normal characters)
  * This holds for Arial 10
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param integer $col The column
  * @return integer The width in pixels
  */
 public static function sizeCol($sheet, $col = 'A')
 {
     // default font size of workbook
     $fontSize = $sheet->getParent()->getDefaultStyle()->getFont()->getSize();
     $columnDimensions = $sheet->getColumnDimensions();
     // first find the true column width in pixels (uncollapsed and unhidden)
     if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
         // then we have column dimension with explicit width
         $columnDimension = $columnDimensions[$col];
         $width = $columnDimension->getWidth();
         $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
     } else {
         if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
             // then we have default column dimension with explicit width
             $defaultColumnDimension = $sheet->getDefaultColumnDimension();
             $width = $defaultColumnDimension->getWidth();
             $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
         } else {
             $pixelWidth = (int) 64 * $fontSize / 11;
             // here we interpolate from Calibri 11
         }
     }
     // now find the effective column width in pixels
     if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
         $effectivePixelWidth = 0;
     } else {
         $effectivePixelWidth = $pixelWidth;
     }
     return $effectivePixelWidth;
 }
 /**
  * Get the width of a column in pixels. We use the relationship y = ceil(7x) where
  * x is the width in intrinsic Excel units (measuring width in number of normal characters)
  * This holds for Arial 10
  *
  * @param PHPExcel_Worksheet $sheet The sheet
  * @param string $col The column
  * @return integer The width in pixels
  */
 public static function sizeCol($sheet, $col = 'A')
 {
     // default font of the workbook
     $font = $sheet->getParent()->getDefaultStyle()->getFont();
     $columnDimensions = $sheet->getColumnDimensions();
     // first find the true column width in pixels (uncollapsed and unhidden)
     if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
         // then we have column dimension with explicit width
         $columnDimension = $columnDimensions[$col];
         $width = $columnDimension->getWidth();
         $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
     } else {
         if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
             // then we have default column dimension with explicit width
             $defaultColumnDimension = $sheet->getDefaultColumnDimension();
             $width = $defaultColumnDimension->getWidth();
             $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
         } else {
             // we don't even have any default column dimension. Width depends on default font
             $pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
         }
     }
     // now find the effective column width in pixels
     if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
         $effectivePixelWidth = 0;
     } else {
         $effectivePixelWidth = $pixelWidth;
     }
     return $effectivePixelWidth;
 }
Example #4
0
                     $newstr = '';
                     for ($j = 0; $j < strlen($retstr); ++$j) {
                         $newstr .= $retstr[$j] . chr(0);
                     }
                     $retstr = $newstr;
                     $len = min($charsLeft * 2, $limitpos - $pos);
                     $retstr .= substr($recordData, $pos, $len);
                     $charsLeft -= $len / 2;
                     $isCompressed = false;
                 }
                 $pos += $len;
             }
         }
         // convert to UTF-8
         $retstr = self::_encodeUTF16($retstr, $isCompressed);
         // read additional Rich-Text information, if any
         $fmtRuns = array();
         if ($hasRichText) {
             // list of formatting runs
             for ($j = 0; $j < $formattingRuns; ++$j) {
                 // first formatted character; zero-based
                 $charPos = self::_GetInt2d($recordData, $pos + $j * 4);
                 // index to font record
                 $fontIndex = self::_GetInt2d($recordData, $pos + 2 + $j * 4);
                 $fmtRuns[] = array('charPos' => $charPos, 'fontIndex' => $fontIndex);
             }
             $pos += 4 * $formattingRuns;
         }
         // read additional Asian phonetics information, if any
         if ($hasAsian) {
             // For Asian phonetic settings, we skip the extended string data
             $pos += $extendedRunLength;
         }
         // store the shared sting
         $this->_sst[] = array('value' => $retstr, 'fmtRuns' => $fmtRuns);
     }
     // _getSplicedRecordData() takes care of moving current position in data stream
 }
 /**
Example #5
0
 /**
  * Write Cols
  *
  * @param	PHPExcel_Shared_XMLWriter			$objWriter		XML Writer
  * @param	PHPExcel_Worksheet					$pSheet			Worksheet
  * @throws	Exception
  */
 private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
 {
     // cols
     if (count($pSheet->getColumnDimensions()) > 0) {
         $objWriter->startElement('cols');
         $pSheet->calculateColumnWidths();
         // Loop through column dimensions
         foreach ($pSheet->getColumnDimensions() as $colDimension) {
             // col
             $objWriter->startElement('col');
             $objWriter->writeAttribute('min', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
             $objWriter->writeAttribute('max', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
             if ($colDimension->getWidth() < 0) {
                 // No width set, apply default of 10
                 $objWriter->writeAttribute('width', '9.10');
             } else {
                 // Width set
                 $objWriter->writeAttribute('width', PHPExcel_Shared_String::FormatNumber($colDimension->getWidth()));
             }
             // Column visibility
             if ($colDimension->getVisible() == false) {
                 $objWriter->writeAttribute('hidden', 'true');
             }
             // Auto size?
             if ($colDimension->getAutoSize()) {
                 $objWriter->writeAttribute('bestFit', 'true');
             }
             // Custom width?
             if ($colDimension->getWidth() != $pSheet->getDefaultColumnDimension()->getWidth()) {
                 $objWriter->writeAttribute('customWidth', 'true');
             }
             // Collapsed
             if ($colDimension->getCollapsed() == true) {
                 $objWriter->writeAttribute('collapsed', 'true');
             }
             // Outline level
             if ($colDimension->getOutlineLevel() > 0) {
                 $objWriter->writeAttribute('outlineLevel', $colDimension->getOutlineLevel());
             }
             // Style
             $objWriter->writeAttribute('style', $colDimension->getXfIndex());
             $objWriter->endElement();
         }
         $objWriter->endElement();
     }
 }
Example #6
0
 /**
  * Write SheetFormatPr
  *
  * @param	PHPExcel_Shared_XMLWriter $objWriter		XML Writer
  * @param	PHPExcel_Worksheet		  $pSheet			Worksheet
  * @throws	Exception
  */
 private function _writeSheetFormatPr(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
 {
     // sheetFormatPr
     $objWriter->startElement('sheetFormatPr');
     // Default row height
     if ($pSheet->getDefaultRowDimension()->getRowHeight() >= 0) {
         $objWriter->writeAttribute('customHeight', 'true');
         $objWriter->writeAttribute('defaultRowHeight', PHPExcel_Shared_String::FormatNumber($pSheet->getDefaultRowDimension()->getRowHeight()));
     } else {
         $objWriter->writeAttribute('defaultRowHeight', '12.75');
     }
     // Default column width
     if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) {
         $objWriter->writeAttribute('defaultColWidth', PHPExcel_Shared_String::FormatNumber($pSheet->getDefaultColumnDimension()->getWidth()));
     }
     // Outline level - row
     $outlineLevelRow = 0;
     foreach ($pSheet->getRowDimensions() as $dimension) {
         if ($dimension->getOutlineLevel() > $outlineLevelRow) {
             $outlineLevelRow = $dimension->getOutlineLevel();
         }
     }
     $objWriter->writeAttribute('outlineLevelRow', (int) $outlineLevelRow);
     // Outline level - column
     $outlineLevelCol = 0;
     foreach ($pSheet->getColumnDimensions() as $dimension) {
         if ($dimension->getOutlineLevel() > $outlineLevelCol) {
             $outlineLevelCol = $dimension->getOutlineLevel();
         }
     }
     $objWriter->writeAttribute('outlineLevelCol', (int) $outlineLevelCol);
     $objWriter->endElement();
 }
Example #7
0
 /**
  * Add data to the beginning of the workbook (note the reverse order)
  * and to the end of the workbook.
  *
  * @access public
  * @see PHPExcel_Writer_Excel5_Workbook::storeWorkbook()
  */
 function close()
 {
     $num_sheets = count($this->_phpSheet->getParent()->getAllSheets());
     // Write BOF record
     $this->_storeBof(0x10);
     // Write PRINTHEADERS
     $this->_writePrintHeaders();
     // Write PRINTGRIDLINES
     $this->_writePrintGridlines();
     // Write GRIDSET
     $this->_writeGridset();
     // Calculate column widths
     $this->_phpSheet->calculateColumnWidths();
     // Column dimensions
     $columnDimensions = $this->_phpSheet->getColumnDimensions();
     for ($i = 0; $i < 256; ++$i) {
         $hidden = 0;
         $level = 0;
         $xfIndex = 15;
         // there are 15 cell style Xfs
         if ($this->_phpSheet->getDefaultColumnDimension()->getWidth() >= 0) {
             $width = $this->_phpSheet->getDefaultColumnDimension()->getWidth();
         } else {
             $width = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($this->_phpSheet->getParent()->getDefaultStyle()->getFont());
         }
         $columnLetter = PHPExcel_Cell::stringFromColumnIndex($i);
         if (isset($columnDimensions[$columnLetter])) {
             $columnDimension = $columnDimensions[$columnLetter];
             if ($columnDimension->getWidth() >= 0) {
                 $width = $columnDimension->getWidth();
             }
             $hidden = $columnDimension->getVisible() ? 0 : 1;
             $level = $columnDimension->getOutlineLevel();
             $xfIndex = $columnDimension->getXfIndex() + 15;
             // there are 15 cell style Xfs
         }
         // Components of _colinfo:
         // $firstcol first column on the range
         // $lastcol  last column on the range
         // $width	width to set
         // $xfIndex  The optional cell style Xf index to apply to the columns
         // $hidden   The optional hidden atribute
         // $level	The optional outline level
         $this->_colinfo[] = array($i, $i, $width, $xfIndex, $hidden, $level);
     }
     // Write GUTS
     $this->_writeGuts();
     // Write DEFAULTROWHEIGHT
     if ($this->_BIFF_version == 0x600) {
         $this->_writeDefaultRowHeight();
     }
     // Write WSBOOL
     $this->_writeWsbool();
     // Write horizontal and vertical page breaks
     $this->_writeBreaks();
     // Write page header
     $this->_writeHeader();
     // Write page footer
     $this->_writeFooter();
     // Write page horizontal centering
     $this->_writeHcenter();
     // Write page vertical centering
     $this->_writeVcenter();
     // Write left margin
     $this->_writeMarginLeft();
     // Write right margin
     $this->_writeMarginRight();
     // Write top margin
     $this->_writeMarginTop();
     // Write bottom margin
     $this->_writeMarginBottom();
     // Write page setup
     $this->_writeSetup();
     // Write sheet protection
     $this->_writeProtect();
     // Write SCENPROTECT
     $this->_writeScenProtect();
     // Write OBJECTPROTECT
     $this->_writeObjectProtect();
     // Write sheet password
     $this->_writePassword();
     // Write DEFCOLWIDTH record
     $this->_writeDefcol();
     // Write the COLINFO records if they exist
     if (!empty($this->_colinfo)) {
         $colcount = count($this->_colinfo);
         for ($i = 0; $i < $colcount; ++$i) {
             $this->_writeColinfo($this->_colinfo[$i]);
         }
     }
     // Write EXTERNCOUNT of external references
     if ($this->_BIFF_version == 0x500) {
         $this->_writeExterncount($num_sheets);
     }
     // Write EXTERNSHEET references
     if ($this->_BIFF_version == 0x500) {
         for ($i = 0; $i < $num_sheets; ++$i) {
             $this->_writeExternsheet($this->_phpSheet->getParent()->getSheet($i)->getTitle());
         }
     }
     // Write sheet dimensions
     $this->_writeDimensions();
     // Row dimensions
     foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
         $xfIndex = $rowDimension->getXfIndex() + 15;
         // there are 15 cellXfs
         $this->_writeRow($rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), $xfIndex, $rowDimension->getVisible() ? '0' : '1', $rowDimension->getOutlineLevel());
     }
     // Write Cells
     foreach ($this->_phpSheet->getCellCollection() as $cellID) {
         $cell = $this->_phpSheet->getCell($cellID);
         $row = $cell->getRow() - 1;
         $column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
         // Don't break Excel!
         if ($row + 1 > 65536 or $column + 1 > 256) {
             break;
         }
         // Write cell value
         $xfIndex = $cell->getXfIndex() + 15;
         // there are 15 cell style Xfs
         if ($cell->getValue() instanceof PHPExcel_RichText) {
             $this->_writeString($row, $column, $cell->getValue()->getPlainText(), $xfIndex);
         } else {
             switch ($cell->getDatatype()) {
                 case PHPExcel_Cell_DataType::TYPE_STRING:
                     if ($cell->getValue() === '' or $cell->getValue() === null) {
                         $this->_writeBlank($row, $column, $xfIndex);
                     } else {
                         $this->_writeString($row, $column, $cell->getValue(), $xfIndex);
                     }
                     break;
                 case PHPExcel_Cell_DataType::TYPE_FORMULA:
                     $calculatedValue = $this->_preCalculateFormulas ? $cell->getCalculatedValue() : null;
                     $this->_writeFormula($row, $column, $cell->getValue(), $xfIndex, $calculatedValue);
                     break;
                 case PHPExcel_Cell_DataType::TYPE_BOOL:
                     $this->_writeBoolErr($row, $column, $cell->getValue(), 0, $xfIndex);
                     break;
                 case PHPExcel_Cell_DataType::TYPE_ERROR:
                     $this->_writeBoolErr($row, $column, $this->_mapErrorCode($cell->getValue()), 1, $xfIndex);
                     break;
                 case PHPExcel_Cell_DataType::TYPE_NUMERIC:
                     $this->_writeNumber($row, $column, $cell->getValue(), $xfIndex);
                     break;
             }
         }
     }
     // Append
     if ($this->_BIFF_version == 0x600) {
         $this->_writeMsoDrawing();
     }
     $this->_writeWindow2();
     $this->_writeZoom();
     if ($this->_phpSheet->getFreezePane()) {
         $this->_writePanes();
     }
     $this->_writeSelection();
     $this->_writeMergedCells();
     // Hyperlinks
     if ($this->_BIFF_version == 0x600) {
         foreach ($this->_phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
             list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinate);
             $url = $hyperlink->getUrl();
             if (strpos($url, 'sheet://') !== false) {
                 // internal to current workbook
                 $url = str_replace('sheet://', 'internal:', $url);
             } else {
                 if (preg_match('/^(http:|https:|ftp:|mailto:)/', $url)) {
                     // URL
                     // $url = $url;
                 } else {
                     // external (local file)
                     $url = 'external:' . $url;
                 }
             }
             $this->_writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
         }
     }
     if ($this->_BIFF_version == 0x600) {
         $this->_writeDataValidity();
         $this->_writeSheetLayout();
         $this->_writeSheetProtection();
         $this->_writeRangeProtection();
     }
     $this->_storeEof();
 }
Example #8
0
 /**
  * Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
  *
  * @access private
  */
 function _storeDefcol()
 {
     $defaultColWidth = (int) $this->_phpSheet->getDefaultColumnDimension()->getWidth();
     if ($defaultColWidth < 0) {
         return;
     }
     $record = 0x55;
     // Record identifier
     $length = 0x2;
     // Number of bytes to follow
     $header = pack("vv", $record, $length);
     $data = pack("v", $defaultColWidth);
     $this->_prepend($header . $data);
 }
Example #9
0
 /**
  * Write Cols
  *
  * @param	PHPExcel_Shared_XMLWriter			$objWriter		XML Writer
  * @param	PHPExcel_Worksheet					$pSheet			Worksheet
  * @throws	Exception
  */
 private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
 {
     // cols
     $objWriter->startElement('cols');
     // Check if there is at least one column dimension specified. If not, create one.
     if (count($pSheet->getColumnDimensions()) == 0) {
         if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) {
             $pSheet->getColumnDimension('A')->setWidth($pSheet->getDefaultColumnDimension()->getWidth());
         } else {
             $pSheet->getColumnDimension('A')->setWidth(9.1);
         }
     }
     $pSheet->calculateColumnWidths();
     // Loop trough column dimensions
     foreach ($pSheet->getColumnDimensions() as $colDimension) {
         // col
         $objWriter->startElement('col');
         $objWriter->writeAttribute('min', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
         $objWriter->writeAttribute('max', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
         if ($colDimension->getWidth() < 0) {
             // No width set, apply default of 10
             $objWriter->writeAttribute('width', '9.10');
         } else {
             // Width set
             $objWriter->writeAttribute('width', PHPExcel_Shared_String::FormatNumber($colDimension->getWidth()));
         }
         // Column visibility
         if ($colDimension->getVisible() == false) {
             $objWriter->writeAttribute('hidden', 'true');
         }
         // Auto size?
         if ($colDimension->getAutoSize()) {
             $objWriter->writeAttribute('bestFit', 'true');
         }
         // Custom width?
         if ($colDimension->getWidth() != $pSheet->getDefaultColumnDimension()->getWidth()) {
             $objWriter->writeAttribute('customWidth', 'true');
         }
         // Collapsed
         if ($colDimension->getCollapsed() == true) {
             $objWriter->writeAttribute('collapsed', 'true');
         }
         // Outline level
         if ($colDimension->getOutlineLevel() > 0) {
             $objWriter->writeAttribute('outlineLevel', $colDimension->getOutlineLevel());
         }
         // Style
         $styleIndex = $this->getParentWriter()->getStylesHashTable()->getIndexForHashCode($pSheet->getDefaultStyle()->getHashCode());
         if ($styleIndex != '') {
             $objWriter->writeAttribute('style', $styleIndex);
         }
         $objWriter->endElement();
     }
     $objWriter->endElement();
 }
Example #10
0
 /**
  * Read DEFCOLWIDTH record
  */
 private function _readDefColWidth()
 {
     $spos = $this->_pos;
     $length = $this->_GetInt2d($this->_data, $spos + 2);
     $recordData = substr($this->_data, $spos + 4, $length);
     $spos += 4;
     // offset: 0; size: 2; row index
     $width = $this->_GetInt2d($recordData, 0);
     $this->_phpSheet->getDefaultColumnDimension()->setWidth($width);
     $this->_pos += 4 + $length;
 }
Example #11
0
 /**
  * Add data to the beginning of the workbook (note the reverse order)
  * and to the end of the workbook.
  *
  * @access public
  * @see PHPExcel_Writer_Excel5_Workbook::storeWorkbook()
  */
 function close()
 {
     $num_sheets = count($this->_phpSheet->getParent()->getAllSheets());
     // Write BOF record
     $this->_storeBof(0x10);
     // Write DEFCOLWIDTH record
     $this->_storeDefcol();
     // Calculate column widths
     $this->_phpSheet->calculateColumnWidths();
     // Column dimensions
     $columnDimensions = $this->_phpSheet->getColumnDimensions();
     for ($i = 0; $i < 256; ++$i) {
         $width = 9.140625;
         // assuming Calibri 11
         $hidden = 0;
         $level = 0;
         if ($this->_phpSheet->getDefaultColumnDimension()->getWidth() >= 0) {
             $width = $this->_phpSheet->getDefaultColumnDimension()->getWidth();
         }
         $columnLetter = PHPExcel_Cell::stringFromColumnIndex($i);
         if (isset($columnDimensions[$columnLetter])) {
             $columnDimension = $columnDimensions[$columnLetter];
             if ($columnDimension->getWidth() >= 0) {
                 $width = $columnDimension->getWidth();
             }
             $hidden = $columnDimension->getVisible() ? 0 : 1;
             $level = $columnDimension->getOutlineLevel();
         }
         $this->_setColumn($i, $i, $width, null, $hidden, $level);
     }
     // Write the COLINFO records if they exist
     if (!empty($this->_colinfo)) {
         $colcount = count($this->_colinfo);
         for ($i = 0; $i < $colcount; ++$i) {
             $this->_storeColinfo($this->_colinfo[$i]);
         }
     }
     // Write EXTERNCOUNT of external references
     if ($this->_BIFF_version == 0x500) {
         $this->_storeExterncount($num_sheets);
     }
     // Write EXTERNSHEET references
     if ($this->_BIFF_version == 0x500) {
         for ($i = 0; $i < $num_sheets; ++$i) {
             $this->_storeExternsheet($this->_phpSheet->getParent()->getSheet($i)->getTitle());
         }
     }
     // Write PRINTHEADERS
     $this->_storePrintHeaders();
     // Write PRINTGRIDLINES
     $this->_storePrintGridlines();
     // Write GUTS
     $this->_storeGuts();
     // Write GRIDSET
     $this->_storeGridset();
     // Write DEFAULTROWHEIGHT
     if ($this->_BIFF_version == 0x600) {
         $this->_storeDefaultRowHeight();
     }
     // Write WSBOOL
     $this->_storeWsbool();
     // Write horizontal and vertical page breaks
     $this->_storeBreaks();
     // Write page header
     $this->_storeHeader();
     // Write page footer
     $this->_storeFooter();
     // Write page horizontal centering
     $this->_storeHcenter();
     // Write page vertical centering
     $this->_storeVcenter();
     // Write left margin
     $this->_storeMarginLeft();
     // Write right margin
     $this->_storeMarginRight();
     // Write top margin
     $this->_storeMarginTop();
     // Write bottom margin
     $this->_storeMarginBottom();
     // Write page setup
     $this->_storeSetup();
     // Write sheet protection
     $this->_storeProtect();
     // Write sheet password
     $this->_storePassword();
     // Write sheet dimensions
     $this->_storeDimensions();
     // Write Cells
     foreach ($this->_phpSheet->getCellCollection() as $cell) {
         $row = $cell->getRow() - 1;
         $column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
         // Don't break Excel!
         if ($row + 1 > 65536 or $column + 1 > 256) {
             break;
         }
         // Write cell value
         $xfIndex = $cell->getXfIndex() + 15;
         // there are 15 cell style Xfs
         if ($cell->getValue() instanceof PHPExcel_RichText) {
             $this->_writeString($row, $column, $cell->getValue()->getPlainText(), $xfIndex);
         } else {
             switch ($cell->getDatatype()) {
                 case PHPExcel_Cell_DataType::TYPE_STRING:
                     if ($cell->getValue() === '' or $cell->getValue() === null) {
                         $this->_writeBlank($row, $column, $xfIndex);
                     } else {
                         $this->_writeString($row, $column, $cell->getValue(), $xfIndex);
                     }
                     break;
                 case PHPExcel_Cell_DataType::TYPE_FORMULA:
                     $this->_writeFormula($row, $column, $cell->getValue(), $xfIndex);
                     break;
                 case PHPExcel_Cell_DataType::TYPE_BOOL:
                     $this->_writeBoolErr($row, $column, $cell->getValue(), 0, $xfIndex);
                     break;
                 case PHPExcel_Cell_DataType::TYPE_ERROR:
                     $this->_writeBoolErr($row, $column, $this->_mapErrorCode($cell->getValue()), 1, $xfIndex);
                     break;
                 case PHPExcel_Cell_DataType::TYPE_NUMERIC:
                     $this->_writeNumber($row, $column, $cell->getValue(), $xfIndex);
                     break;
             }
             // Hyperlink?
             if ($cell->hasHyperlink()) {
                 $this->_writeUrl($row, $column, str_replace('sheet://', 'internal:', $cell->getHyperlink()->getUrl()));
             }
         }
     }
     // Row dimensions
     foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
         $this->_setRow($rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), null, $rowDimension->getVisible() ? '0' : '1', $rowDimension->getOutlineLevel());
     }
     // Append
     if ($this->_BIFF_version == 0x600) {
         $this->_storeMsoDrawing();
     }
     $this->_storeWindow2();
     $this->_storeZoom();
     if ($this->_phpSheet->getFreezePane()) {
         $this->_storePanes();
     }
     $this->_storeSelection($this->_selection);
     $this->_storeMergedCells();
     /*if ($this->_BIFF_version == 0x0600) {
     			$this->_storeDataValidity();
     		}*/
     if ($this->_BIFF_version == 0x600) {
         $this->_storeRangeProtection();
     }
     $this->_storeEof();
 }
 /**
  * Read DEFCOLWIDTH record
  */
 private function _readDefColWidth()
 {
     $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;
     // offset: 0; size: 2; default column width
     $width = $this->_GetInt2d($recordData, 0);
     if ($width != 8) {
         $this->_phpSheet->getDefaultColumnDimension()->setWidth($width);
     }
 }