diff --git a/Classes/PHPExcel/Writer/CSV.php b/Classes/PHPExcel/Writer/CSV.php index 1c756637..9f271007 100644 --- a/Classes/PHPExcel/Writer/CSV.php +++ b/Classes/PHPExcel/Writer/CSV.php @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Writer + * @package PHPExcel_Writer * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ @@ -30,7 +30,7 @@ * PHPExcel_Writer_CSV * * @category PHPExcel - * @package PHPExcel_Writer + * @package PHPExcel_Writer * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { @@ -86,21 +86,21 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { /** * Create a new PHPExcel_Writer_CSV * - * @param PHPExcel $phpExcel PHPExcel object + * @param PHPExcel $phpExcel PHPExcel object */ public function __construct(PHPExcel $phpExcel) { - $this->_phpExcel = $phpExcel; - $this->_delimiter = ','; - $this->_enclosure = '"'; - $this->_lineEnding = PHP_EOL; - $this->_sheetIndex = 0; + $this->_phpExcel = $phpExcel; + $this->_delimiter = ','; + $this->_enclosure = '"'; + $this->_lineEnding = PHP_EOL; + $this->_sheetIndex = 0; } /** * Save PHPExcel to file * - * @param string $pFileName - * @throws Exception + * @param string $pFileName + * @throws Exception */ public function save($pFilename = null) { // Fetch sheet @@ -112,7 +112,7 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file - $fileHandle = fopen($pFilename, 'w'); + $fileHandle = fopen($pFilename, 'wb+'); if ($fileHandle === false) { throw new Exception("Could not open file $pFilename for writing."); } @@ -280,23 +280,23 @@ class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter { } } - /** - * Get Pre-Calculate Formulas - * - * @return boolean - */ - public function getPreCalculateFormulas() { - return $this->_preCalculateFormulas; - } + /** + * Get Pre-Calculate Formulas + * + * @return boolean + */ + public function getPreCalculateFormulas() { + return $this->_preCalculateFormulas; + } - /** - * Set Pre-Calculate Formulas - * - * @param boolean $pValue Pre-Calculate Formulas? - * @return PHPExcel_Writer_CSV - */ - public function setPreCalculateFormulas($pValue = true) { - $this->_preCalculateFormulas = $pValue; - return $this; - } + /** + * Set Pre-Calculate Formulas + * + * @param boolean $pValue Pre-Calculate Formulas? + * @return PHPExcel_Writer_CSV + */ + public function setPreCalculateFormulas($pValue = true) { + $this->_preCalculateFormulas = $pValue; + return $this; + } } diff --git a/Classes/PHPExcel/Writer/HTML.php b/Classes/PHPExcel/Writer/HTML.php index b3b647d9..d0b83812 100644 --- a/Classes/PHPExcel/Writer/HTML.php +++ b/Classes/PHPExcel/Writer/HTML.php @@ -19,10 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel - * @package PHPExcel_Writer + * @package PHPExcel_Writer * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ @@ -30,7 +30,7 @@ * PHPExcel_Writer_HTML * * @category PHPExcel - * @package PHPExcel_Writer + * @package PHPExcel_Writer * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { @@ -135,7 +135,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Create a new PHPExcel_Writer_HTML * - * @param PHPExcel $phpExcel PHPExcel object + * @param PHPExcel $phpExcel PHPExcel object */ public function __construct(PHPExcel $phpExcel) { $this->_phpExcel = $phpExcel; @@ -145,15 +145,15 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $this->_spansAreCalculated = false; $this->_isSpannedCell = array(); - $this->_isBaseCell = array(); + $this->_isBaseCell = array(); $this->_isSpannedRow = array(); } /** * Save PHPExcel to file * - * @param string $pFileName - * @throws Exception + * @param string $pFileName + * @throws Exception */ public function save($pFilename = null) { // garbage collect @@ -168,7 +168,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $this->buildCSS(!$this->_useInlineCss); // Open file - $fileHandle = fopen($pFilename, 'w'); + $fileHandle = fopen($pFilename, 'wb+'); if ($fileHandle === false) { throw new Exception("Could not open file $pFilename for writing."); } @@ -313,8 +313,8 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $html .= '' . "\r\n"; $html .= '' . "\r\n"; $html .= ' ' . "\r\n"; - $html .= ' ' . "\r\n"; - $html .= ' ' . htmlspecialchars($this->_phpExcel->getProperties()->getTitle()) . '' . "\r\n"; + $html .= ' ' . "\r\n"; + $html .= ' ' . htmlspecialchars($this->_phpExcel->getProperties()->getTitle()) . '' . "\r\n"; if ($pIncludeStyles) { $html .= $this->generateStyles(true); } @@ -360,20 +360,20 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Write table header $html .= $this->_generateTableHeader($sheet); - // Get worksheet dimension - $dimension = explode(':', $sheet->calculateWorksheetDimension()); - $dimension[0] = PHPExcel_Cell::coordinateFromString($dimension[0]); - $dimension[0][0] = PHPExcel_Cell::columnIndexFromString($dimension[0][0]) - 1; - $dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]); - $dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1; + // Get worksheet dimension + $dimension = explode(':', $sheet->calculateWorksheetDimension()); + $dimension[0] = PHPExcel_Cell::coordinateFromString($dimension[0]); + $dimension[0][0] = PHPExcel_Cell::columnIndexFromString($dimension[0][0]) - 1; + $dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]); + $dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1; - // row min,max + // row min,max $rowMin = $dimension[0][1]; $rowMax = $dimension[1][1]; // calculate start of , $tbodyStart = $rowMin; - $tbodyEnd = $rowMax; + $tbodyEnd = $rowMax; $theadStart = 0; // default: no $theadEnd = 0; // default: no if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) { @@ -388,29 +388,29 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { } // Loop through cells - $rowData = null; - for ($row = $rowMin; $row <= $rowMax; ++$row) { + $rowData = null; + for ($row = $rowMin; $row <= $rowMax; ++$row) { // Start a new row $rowData = array(); // Loop through columns - for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) { - // Cell exists? - if ($sheet->cellExistsByColumnAndRow($column, $row)) { - $rowData[$column] = $cell = $sheet->getCellByColumnAndRow($column, $row); - } else { - $rowData[$column] = ''; - } - } - - // ? - if ($row == $theadStart) { - $html .= ' ' . "\r\n"; + for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) { + // Cell exists? + if ($sheet->cellExistsByColumnAndRow($column, $row)) { + $rowData[$column] = $cell = $sheet->getCellByColumnAndRow($column, $row); + } else { + $rowData[$column] = ''; + } } - // ? + // ? + if ($row == $theadStart) { + $html .= ' ' . "\r\n"; + } + + // ? if ($row == $tbodyStart) { - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } // Write row if there are HTML table cells in it @@ -418,16 +418,16 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $html .= $this->_generateRow($sheet, $rowData, $row - 1); } - // ? + // ? if ($row == $theadEnd) { - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } - // ? + // ? if ($row == $tbodyEnd) { - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } - } + } // Write table footer $html .= $this->_generateTableFooter(); @@ -493,7 +493,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Generate image tag in cell * - * @param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet + * @param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet * @param string $coordinates Cell coordinates * @return string * @throws Exception @@ -525,7 +525,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $filename = htmlspecialchars($filename); $html .= "\r\n"; - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } } } @@ -555,20 +555,20 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Start styles if ($generateSurroundingHTML) { - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } // Return @@ -604,8 +604,8 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Start styles if ($generateSurroundingHTML) { // html { } - $css['html']['font-family'] = 'Calibri, Arial, Helvetica, sans-serif'; - $css['html']['font-size'] = '11pt'; + $css['html']['font-family'] = 'Calibri, Arial, Helvetica, sans-serif'; + $css['html']['font-size'] = '11pt'; $css['html']['background-color'] = 'white'; } @@ -692,7 +692,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { } $css['table.sheet' . $sheetIndex . ' tr']['height'] = $pt_height . 'pt'; if ($rowDimension->getVisible() === false) { - $css['table.sheet' . $sheetIndex . ' tr']['display'] = 'none'; + $css['table.sheet' . $sheetIndex . ' tr']['display'] = 'none'; $css['table.sheet' . $sheetIndex . ' tr']['visibility'] = 'hidden'; } @@ -728,7 +728,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Create CSS style * - * @param PHPExcel_Style $pStyle PHPExcel_Style + * @param PHPExcel_Style $pStyle PHPExcel_Style * @return array */ private function _createCSSStyle(PHPExcel_Style $pStyle) { @@ -750,7 +750,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Create CSS style (PHPExcel_Style_Alignment) * - * @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment + * @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment * @return array */ private function _createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle) { @@ -770,7 +770,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Create CSS style (PHPExcel_Style_Font) * - * @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font + * @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font * @return array */ private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle) { @@ -803,7 +803,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Create CSS style (PHPExcel_Style_Borders) * - * @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders + * @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders * @return array */ private function _createCSSStyleBorders(PHPExcel_Style_Borders $pStyle) { @@ -872,7 +872,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Generate table header * - * @param PHPExcel_Worksheet $pSheet The worksheet for the table we are writing + * @param PHPExcel_Worksheet $pSheet The worksheet for the table we are writing * @return string * @throws Exception */ @@ -884,15 +884,15 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { if (!$this->_useInlineCss) { $gridlines = $pSheet->getShowGridLines() ? ' gridlines' : ''; - $html .= ' ' . "\r\n"; + $html .= '
' . "\r\n"; } else { $style = isset($this->_cssStyles['table']) ? $this->_assembleCSS($this->_cssStyles['table']) : ''; if ($this->_isPdf && $pSheet->getShowGridLines()) { - $html .= '
' . "\r\n"; + $html .= '
' . "\r\n"; } else { - $html .= '
' . "\r\n"; + $html .= '
' . "\r\n"; } } @@ -900,11 +900,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1; for ($i = 0; $i <= $highestColumnIndex; ++$i) { if (!$this->_useInlineCss) { - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } else { $style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) ? $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) : ''; - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } } @@ -920,7 +920,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { private function _generateTableFooter() { // Construct HTML $html = ''; - $html .= '
' . "\r\n"; + $html .= ' ' . "\r\n"; // Return return $html; @@ -929,7 +929,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { /** * Generate row * - * @param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet + * @param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet * @param array $pValues Array containing cells in a row * @param int $pRow Row number (0-based) * @return string @@ -962,12 +962,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Write row start if (!$this->_useInlineCss) { - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } else { $style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) ? $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : ''; - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; } // Write cells @@ -1088,7 +1088,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { // Write if ($writeCell) { // Column start - $html .= ' _useInlineCss) { $html .= ' class="' . $cssClass . '"'; } else { @@ -1136,7 +1136,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { } // Write row end - $html .= ' ' . "\r\n"; + $html .= ' ' . "\r\n"; // Return return $html; @@ -1162,65 +1162,65 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter { return $string; } - /** - * Get Pre-Calculate Formulas - * - * @return boolean - */ - public function getPreCalculateFormulas() { - return $this->_preCalculateFormulas; - } + /** + * Get Pre-Calculate Formulas + * + * @return boolean + */ + public function getPreCalculateFormulas() { + return $this->_preCalculateFormulas; + } - /** - * Set Pre-Calculate Formulas - * - * @param boolean $pValue Pre-Calculate Formulas? - * @return PHPExcel_Writer_HTML - */ - public function setPreCalculateFormulas($pValue = true) { - $this->_preCalculateFormulas = $pValue; - return $this; - } + /** + * Set Pre-Calculate Formulas + * + * @param boolean $pValue Pre-Calculate Formulas? + * @return PHPExcel_Writer_HTML + */ + public function setPreCalculateFormulas($pValue = true) { + $this->_preCalculateFormulas = $pValue; + return $this; + } - /** - * Get images root - * - * @return string - */ - public function getImagesRoot() { - return $this->_imagesRoot; - } + /** + * Get images root + * + * @return string + */ + public function getImagesRoot() { + return $this->_imagesRoot; + } - /** - * Set images root - * - * @param string $pValue - * @return PHPExcel_Writer_HTML - */ - public function setImagesRoot($pValue = '.') { - $this->_imagesRoot = $pValue; - return $this; - } + /** + * Set images root + * + * @param string $pValue + * @return PHPExcel_Writer_HTML + */ + public function setImagesRoot($pValue = '.') { + $this->_imagesRoot = $pValue; + return $this; + } - /** - * Get use inline CSS? - * - * @return boolean - */ - public function getUseInlineCss() { - return $this->_useInlineCss; - } + /** + * Get use inline CSS? + * + * @return boolean + */ + public function getUseInlineCss() { + return $this->_useInlineCss; + } - /** - * Set use inline CSS? - * - * @param boolean $pValue - * @return PHPExcel_Writer_HTML - */ - public function setUseInlineCss($pValue = false) { - $this->_useInlineCss = $pValue; - return $this; - } + /** + * Set use inline CSS? + * + * @param boolean $pValue + * @return PHPExcel_Writer_HTML + */ + public function setUseInlineCss($pValue = false) { + $this->_useInlineCss = $pValue; + return $this; + } /** * Converts a string so that spaces occuring at beginning of each new line are replaced by