Merge branch 'psr2' into develop

This commit is contained in:
MarkBaker 2015-05-14 23:51:30 +01:00
commit 1c26425915
80 changed files with 5464 additions and 5419 deletions

File diff suppressed because it is too large Load Diff

View File

@ -847,7 +847,7 @@ class PHPExcel_Calculation_DateTime
} }
if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) { if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {
switch($method) { switch ($method) {
case 0: case 0:
return self::DAYS360($startDate, $endDate) / 360; return self::DAYS360($startDate, $endDate) / 360;
case 1: case 1:

View File

@ -1019,7 +1019,7 @@ class PHPExcel_Calculation_Engineering
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
switch(floor($ord)) { switch (floor($ord)) {
case 0: case 0:
return self::besselK0($x); return self::besselK0($x);
case 1: case 1:
@ -1103,7 +1103,7 @@ class PHPExcel_Calculation_Engineering
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
switch(floor($ord)) { switch (floor($ord)) {
case 0: case 0:
return self::besselY0($x); return self::besselY0($x);
case 1: case 1:

View File

@ -1120,7 +1120,7 @@ class PHPExcel_Calculation_MathTrig
$subtotal = array_shift($aArgs); $subtotal = array_shift($aArgs);
if ((is_numeric($subtotal)) && (!is_string($subtotal))) { if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
switch($subtotal) { switch ($subtotal) {
case 1: case 1:
return PHPExcel_Calculation_Statistical::AVERAGE($aArgs); return PHPExcel_Calculation_Statistical::AVERAGE($aArgs);
case 2: case 2:

View File

@ -3452,7 +3452,7 @@ class PHPExcel_Calculation_Statistical
* of a data set. * of a data set.
* *
* Excel Function: * Excel Function:
* TRIMEAN(value1[,value2[, ...]],$discard) * TRIMEAN(value1[,value2[, ...]], $discard)
* *
* @access public * @access public
* @category Statistical Functions * @category Statistical Functions

View File

@ -585,7 +585,7 @@ class PHPExcel_Cell
{ {
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) { if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]); return array($matches[1],$matches[2]);
} elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) { } elseif ((strpos($pCoordinateString, ':') !== false) || (strpos($pCoordinateString, ',') !== false)) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells'); throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') { } elseif ($pCoordinateString == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string'); throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
@ -868,7 +868,7 @@ class PHPExcel_Cell
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange))); $cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
foreach ($cellBlocks as $cellBlock) { foreach ($cellBlocks as $cellBlock) {
// Single cell? // Single cell?
if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) { if (strpos($cellBlock, ':') === false && strpos($cellBlock, ',') === false) {
$returnValue[] = $cellBlock; $returnValue[] = $cellBlock;
continue; continue;
} }

View File

@ -90,33 +90,33 @@ class PHPExcel_Chart
*/ */
private $_displayBlanksAs = '0'; private $_displayBlanksAs = '0';
/** /**
* Chart Asix Y as * Chart Asix Y as
* *
* @var PHPExcel_Chart_Axis * @var PHPExcel_Chart_Axis
*/ */
private $_yAxis = null; private $_yAxis = null;
/** /**
* Chart Asix X as * Chart Asix X as
* *
* @var PHPExcel_Chart_Axis * @var PHPExcel_Chart_Axis
*/ */
private $_xAxis = null; private $_xAxis = null;
/** /**
* Chart Major Gridlines as * Chart Major Gridlines as
* *
* @var PHPExcel_Chart_GridLines * @var PHPExcel_Chart_GridLines
*/ */
private $_majorGridlines = null; private $_majorGridlines = null;
/** /**
* Chart Minor Gridlines as * Chart Minor Gridlines as
* *
* @var PHPExcel_Chart_GridLines * @var PHPExcel_Chart_GridLines
*/ */
private $_minorGridlines = null; private $_minorGridlines = null;
/** /**
* Top-Left Cell Position * Top-Left Cell Position
@ -304,7 +304,8 @@ class PHPExcel_Chart
* @param PHPExcel_Chart_Title $label * @param PHPExcel_Chart_Title $label
* @return PHPExcel_Chart * @return PHPExcel_Chart
*/ */
public function setYAxisLabel(PHPExcel_Chart_Title $label) { public function setYAxisLabel(PHPExcel_Chart_Title $label)
{
$this->_yAxisLabel = $label; $this->_yAxisLabel = $label;
return $this; return $this;
@ -365,62 +366,62 @@ class PHPExcel_Chart
} }
/** /**
* Get yAxis * Get yAxis
* *
* @return PHPExcel_Chart_Axis * @return PHPExcel_Chart_Axis
*/ */
public function getChartAxisY() public function getChartAxisY()
{ {
if ($this->_yAxis !== null) { if ($this->_yAxis !== null) {
return $this->_yAxis; return $this->_yAxis;
}
return new PHPExcel_Chart_Axis();
} }
return new PHPExcel_Chart_Axis(); /**
} * Get xAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX()
{
if ($this->_xAxis !== null) {
return $this->_xAxis;
}
/** return new PHPExcel_Chart_Axis();
* Get xAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX()
{
if ($this->_xAxis !== null) {
return $this->_xAxis;
} }
return new PHPExcel_Chart_Axis(); /**
} * Get Major Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMajorGridlines()
{
if ($this->_majorGridlines !== null) {
return $this->_majorGridlines;
}
/** return new PHPExcel_Chart_GridLines();
* Get Major Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMajorGridlines()
{
if ($this->_majorGridlines !== null) {
return $this->_majorGridlines;
} }
return new PHPExcel_Chart_GridLines(); /**
} * Get Minor Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMinorGridlines()
{
if ($this->_minorGridlines !== null) {
return $this->_minorGridlines;
}
/** return new PHPExcel_Chart_GridLines();
* Get Minor Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMinorGridlines()
{
if ($this->_minorGridlines !== null) {
return $this->_minorGridlines;
} }
return new PHPExcel_Chart_GridLines();
}
/** /**
* Set the Top Left position for the chart * Set the Top Left position for the chart
@ -430,7 +431,7 @@ class PHPExcel_Chart
* @param integer $yOffset * @param integer $yOffset
* @return PHPExcel_Chart * @return PHPExcel_Chart
*/ */
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
{ {
$this->_topLeftCellRef = $cell; $this->_topLeftCellRef = $cell;
if (!is_null($xOffset)) { if (!is_null($xOffset)) {
@ -662,9 +663,9 @@ class PHPExcel_Chart
$this->refresh(); $this->refresh();
$libraryPath = PHPExcel_Settings::getChartRendererPath(); $libraryPath = PHPExcel_Settings::getChartRendererPath();
$includePath = str_replace('\\','/',get_include_path()); $includePath = str_replace('\\', '/', get_include_path());
$rendererPath = str_replace('\\','/',$libraryPath); $rendererPath = str_replace('\\', '/', $libraryPath);
if (strpos($rendererPath,$includePath) === false) { if (strpos($rendererPath, $includePath) === false) {
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath); set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
} }

View File

@ -179,8 +179,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null) public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, $minor_unit = null)
{ {
$this->_axis_options['axis_labels'] = (string) $axis_labels; $this->_axis_options['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== null) ($horizontal_crosses_value !== null) ? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null;
($horizontal_crosses !== null) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : null; ($horizontal_crosses !== null) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : null;
($axis_orientation !== null) ? $this->_axis_options['orientation'] = (string) $axis_orientation : null; ($axis_orientation !== null) ? $this->_axis_options['orientation'] = (string) $axis_orientation : null;
($major_tmt !== null) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : null; ($major_tmt !== null) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : null;
@ -265,306 +264,282 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
return $this->_line_properties[$property]; return $this->_line_properties[$property];
} }
/** /**
* Set Line Style Properties * Set Line Style Properties
* *
* @param float $line_width * @param float $line_width
* @param string $compound_type * @param string $compound_type
* @param string $dash_type * @param string $dash_type
* @param string $cap_type * @param string $cap_type
* @param string $join_type * @param string $join_type
* @param string $head_arrow_type * @param string $head_arrow_type
* @param string $head_arrow_size * @param string $head_arrow_size
* @param string $end_arrow_type * @param string $end_arrow_type
* @param string $end_arrow_size * @param string $end_arrow_size
* *
*/ */
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) {
(!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width) : null;
(!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : null;
(!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : null;
(!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : null;
(!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : null;
(!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type : null;
(!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size : null;
(!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type : null;
(!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size : null;
}
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) { /**
(!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width) * Get Line Style Property
: null; *
(!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : null; * @param array|string $elements
(!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : null; *
(!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : null; * @return string
(!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : null; */
(!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type public function getLineStyleProperty($elements)
: null; {
(!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size return $this->getArrayElementsValue($this->_line_style_properties, $elements);
: null; }
(!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type
: null;
(!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size
: null;
}
/** /**
* Get Line Style Property * Get Line Style Arrow Excel Width
* *
* @param array|string $elements * @param string $arrow
* *
* @return string * @return string
*/ */
public function getLineStyleArrowWidth($arrow)
{
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w');
}
public function getLineStyleProperty($elements) /**
{ * Get Line Style Arrow Excel Length
return $this->getArrayElementsValue($this->_line_style_properties, $elements); *
} * @param string $arrow
*
* @return string
*/
public function getLineStyleArrowLength($arrow)
{
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len');
}
/** /**
* Get Line Style Arrow Excel Width * Set Shadow Properties
* *
* @param string $arrow * @param int $shadow_presets
* * @param string $sh_color_value
* @return string * @param string $sh_color_type
*/ * @param string $sh_color_alpha
* @param float $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) {
$this->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
public function getLineStyleArrowWidth($arrow) /**
{ * Set Shadow Color
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w'); *
} * @param int $shadow_presets
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
/** return $this;
* Get Line Style Arrow Excel Length }
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowLength($arrow) /**
{ * Set Shadow Properties from Maped Values
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len'); *
} * @param array $properties_map
* @param * $reference
/** *
* Set Shadow Properties * @return PHPExcel_Chart_Axis
* */
* @param int $shadow_presets private function _setShadowProperiesMapValues(array $properties_map, &$reference = null) {
* @param string $sh_color_value $base_reference = $reference;
* @param string $sh_color_type foreach ($properties_map as $property_key => $property_val) {
* @param string $sh_color_alpha if (is_array($property_val)) {
* @param float $sh_blur if ($reference === null) {
* @param int $sh_angle $reference = & $this->_shadow_properties[$property_key];
* @param float $sh_distance } else {
* $reference = & $reference[$property_key];
*/ }
$this->_setShadowProperiesMapValues($property_val, $reference);
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) { } else {
$this if ($base_reference === null) {
->_setShadowPresetsProperties((int) $sh_presets) $this->_shadow_properties[$property_key] = $property_val;
->_setShadowColor( } else {
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value $reference[$property_key] = $property_val;
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha }
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type) }
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/**
* Set Shadow Color
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties from Maped Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = null) {
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === null) {
$reference = & $this->_shadow_properties[$property_key];
} else {
$reference = & $reference[$property_key];
} }
$this->_setShadowProperiesMapValues($property_val, $reference);
} else { return $this;
if ($base_reference === null) { }
$this->_shadow_properties[$property_key] = $property_val;
} else { /**
$reference[$property_key] = $property_val; * Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowColor($color, $alpha, $type) {
$this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowBlur($blur) {
if ($blur !== null) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
} }
}
return $this;
} }
return $this; /**
} * Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowAngle($angle) {
if ($angle !== null) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
/** return $this;
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowColor($color, $alpha, $type) {
$this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowBlur($blur) {
if ($blur !== null) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
} }
return $this; /**
} * Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowDistance($distance) {
if ($distance !== null) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
/** return $this;
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowAngle($angle) {
if ($angle !== null) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
} }
return $this; /**
} * Get Glow Property
*
/** * @param float $size
* Set Shadow Distance * @param string $color_value
* * @param int $color_alpha
* @param float $distance * @param string $color_type
* */
* @return PHPExcel_Chart_Axis public function getShadowProperty($elements) {
*/ return $this->getArrayElementsValue($this->_shadow_properties, $elements);
private function _setShadowDistance($distance) {
if ($distance !== null) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
} }
return $this; /**
} * Set Glow Properties
*
/** * @param float $size
* Get Glow Property * @param string $color_value
* * @param int $color_alpha
* @param float $size * @param string $color_type
* @param string $color_value */
* @param int $color_alpha public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) {
* @param string $color_type $this->_setGlowSize($size)
*/ ->_setGlowColor(
is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value
public function getShadowProperty($elements) { , is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
return $this->getArrayElementsValue($this->_shadow_properties, $elements); , is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type
} );
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) {
$this
->_setGlowSize($size)
->_setGlowColor(
is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value
, is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
, is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type);
}
/**
* Get Glow Property
*
* @param array|string $property
*
* @return string
*/
public function getGlowProperty($property) {
return $this->getArrayElementsValue($this->_glow_properties, $property);
}
/**
* Set Glow Color
*
* @param float $size
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowSize($size) {
if (!is_null($size)) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
} }
return $this; /**
} * Get Glow Property
*
/** * @param array|string $property
* Set Glow Color *
* * @return string
* @param string $color */
* @param int $alpha public function getGlowProperty($property) {
* @param string $type return $this->getArrayElementsValue($this->_glow_properties, $property);
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowColor($color, $alpha, $type) {
$this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdges($size) {
if (!is_null($size)) {
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
} }
}
/** /**
* Get Soft Edges Size * Set Glow Color
* *
* @return string * @param float $size
*/ *
* @return PHPExcel_Chart_Axis
*/
private function _setGlowSize($size) {
if (!is_null($size)) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
}
public function getSoftEdgesSize() { return $this;
return $this->_soft_edges['size']; }
}
} /**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowColor($color, $alpha, $type) {
$this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdges($size) {
if (!is_null($size)) {
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
}
}

View File

@ -371,21 +371,20 @@ class PHPExcel_Chart_DataSeries
public function refresh(PHPExcel_Worksheet $worksheet) public function refresh(PHPExcel_Worksheet $worksheet)
{ {
foreach($this->_plotValues as $plotValues) { foreach ($this->_plotValues as $plotValues) {
if ($plotValues !== null) { if ($plotValues !== null) {
$plotValues->refresh($worksheet, true); $plotValues->refresh($worksheet, true);
} }
} }
foreach($this->_plotLabel as $plotValues) { foreach ($this->_plotLabel as $plotValues) {
if ($plotValues !== null) { if ($plotValues !== null) {
$plotValues->refresh($worksheet, true); $plotValues->refresh($worksheet, true);
} }
} }
foreach($this->_plotCategory as $plotValues) { foreach ($this->_plotCategory as $plotValues) {
if ($plotValues !== null) { if ($plotValues !== null) {
$plotValues->refresh($worksheet, false); $plotValues->refresh($worksheet, false);
} }
} }
} }
} }

View File

@ -96,7 +96,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return string * @return string
*/ */
public function getDataType() { public function getDataType()
{
return $this->_dataType; return $this->_dataType;
} }
@ -111,7 +112,8 @@ class PHPExcel_Chart_DataSeriesValues
* Normally used for chart data values * Normally used for chart data values
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) { public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER)
{
if (!in_array($dataType, self::$_dataTypeValues)) { if (!in_array($dataType, self::$_dataTypeValues)) {
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values'); throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
} }
@ -125,7 +127,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return string * @return string
*/ */
public function getDataSource() { public function getDataSource()
{
return $this->_dataSource; return $this->_dataSource;
} }
@ -135,7 +138,8 @@ class PHPExcel_Chart_DataSeriesValues
* @param string $dataSource * @param string $dataSource
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setDataSource($dataSource = null, $refreshDataValues = true) { public function setDataSource($dataSource = null, $refreshDataValues = true)
{
$this->_dataSource = $dataSource; $this->_dataSource = $dataSource;
if ($refreshDataValues) { if ($refreshDataValues) {
@ -150,7 +154,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return string * @return string
*/ */
public function getPointMarker() { public function getPointMarker()
{
return $this->_marker; return $this->_marker;
} }
@ -160,7 +165,8 @@ class PHPExcel_Chart_DataSeriesValues
* @param string $marker * @param string $marker
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setPointMarker($marker = null) { public function setPointMarker($marker = null)
{
$this->_marker = $marker; $this->_marker = $marker;
return $this; return $this;
@ -171,7 +177,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return string * @return string
*/ */
public function getFormatCode() { public function getFormatCode()
{
return $this->_formatCode; return $this->_formatCode;
} }
@ -181,7 +188,8 @@ class PHPExcel_Chart_DataSeriesValues
* @param string $formatCode * @param string $formatCode
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setFormatCode($formatCode = null) { public function setFormatCode($formatCode = null)
{
$this->_formatCode = $formatCode; $this->_formatCode = $formatCode;
return $this; return $this;
@ -192,7 +200,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return integer * @return integer
*/ */
public function getPointCount() { public function getPointCount()
{
return $this->_pointCount; return $this->_pointCount;
} }
@ -201,7 +210,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return boolean * @return boolean
*/ */
public function isMultiLevelSeries() { public function isMultiLevelSeries()
{
if (count($this->_dataValues) > 0) { if (count($this->_dataValues) > 0) {
return is_array($this->_dataValues[0]); return is_array($this->_dataValues[0]);
} }
@ -213,9 +223,10 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return boolean * @return boolean
*/ */
public function multiLevelCount() { public function multiLevelCount()
{
$levelCount = 0; $levelCount = 0;
foreach($this->_dataValues as $dataValueSet) { foreach ($this->_dataValues as $dataValueSet) {
$levelCount = max($levelCount,count($dataValueSet)); $levelCount = max($levelCount,count($dataValueSet));
} }
return $levelCount; return $levelCount;
@ -226,7 +237,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return array of mixed * @return array of mixed
*/ */
public function getDataValues() { public function getDataValues()
{
return $this->_dataValues; return $this->_dataValues;
} }
@ -235,7 +247,8 @@ class PHPExcel_Chart_DataSeriesValues
* *
* @return mixed * @return mixed
*/ */
public function getDataValue() { public function getDataValue()
{
$count = count($this->_dataValues); $count = count($this->_dataValues);
if ($count == 0) { if ($count == 0) {
return null; return null;
@ -254,7 +267,8 @@ class PHPExcel_Chart_DataSeriesValues
* FALSE - don't change the value of _dataSource * FALSE - don't change the value of _dataSource
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) { public function setDataValues($dataValues = array(), $refreshDataSource = true)
{
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues); $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
$this->_pointCount = count($dataValues); $this->_pointCount = count($dataValues);
@ -265,47 +279,49 @@ class PHPExcel_Chart_DataSeriesValues
return $this; return $this;
} }
private function _stripNulls($var) { private function _stripNulls($var)
return $var !== NULL; {
return $var !== null;
} }
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) { public function refresh(PHPExcel_Worksheet $worksheet, $flatten = true)
if ($this->_dataSource !== NULL) { {
if ($this->_dataSource !== null) {
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
$newDataValues = PHPExcel_Calculation::_unwrapResult( $newDataValues = PHPExcel_Calculation::_unwrapResult(
$calcEngine->_calculateFormulaValue( $calcEngine->_calculateFormulaValue(
'='.$this->_dataSource, '='.$this->_dataSource,
NULL, null,
$worksheet->getCell('A1') $worksheet->getCell('A1')
) )
); );
if ($flatten) { if ($flatten) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
foreach($this->_dataValues as &$dataValue) { foreach ($this->_dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) { if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
$dataValue = 0.0; $dataValue = 0.0;
} }
} }
unset($dataValue); unset($dataValue);
} else { } else {
$cellRange = explode('!',$this->_dataSource); $cellRange = explode('!', $this->_dataSource);
if (count($cellRange) > 1) { if (count($cellRange) > 1) {
list(,$cellRange) = $cellRange; list(, $cellRange) = $cellRange;
} }
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange)); $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$', '', $cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
} else { } else {
$newArray = array_values(array_shift($newDataValues)); $newArray = array_values(array_shift($newDataValues));
foreach($newArray as $i => $newDataSet) { foreach ($newArray as $i => $newDataSet) {
$newArray[$i] = array($newDataSet); $newArray[$i] = array($newDataSet);
} }
foreach($newDataValues as $newDataSet) { foreach ($newDataValues as $newDataSet) {
$i = 0; $i = 0;
foreach($newDataSet as $newDataVal) { foreach ($newDataSet as $newDataVal) {
array_unshift($newArray[$i++],$newDataVal); array_unshift($newArray[$i++], $newDataVal);
} }
} }
$this->_dataValues = $newArray; $this->_dataValues = $newArray;
@ -313,7 +329,5 @@ class PHPExcel_Chart_DataSeriesValues
} }
$this->_pointCount = count($this->_dataValues); $this->_pointCount = count($this->_dataValues);
} }
} }
} }

View File

@ -7,8 +7,8 @@
* Time: 2:36 PM * Time: 2:36 PM
*/ */
class PHPExcel_Chart_GridLines extends class PHPExcel_Chart_GridLines extends PHPExcel_Chart_Properties
PHPExcel_Chart_Properties { {
/** /**
* Properties of Class: * Properties of Class:
@ -20,333 +20,351 @@ class PHPExcel_Chart_GridLines extends
* *
*/ */
private private $_object_state = false;
$_object_state = FALSE,
$_line_properties = array(
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => NULL,
'alpha' => 0
),
'style' => array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
)
),
$_shadow_properties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 85,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
),
$_glow_properties = array(
'size' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
),
$_soft_edges = array(
'size' => NULL
);
/** private $_line_properties = array(
* Get Object State 'color' => array(
* 'type' => self::EXCEL_COLOR_TYPE_STANDARD,
* @return bool 'value' => null,
*/ 'alpha' => 0
),
'style' => array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
)
);
public function getObjectState() { private $_shadow_properties = array(
return $this->_object_state; 'presets' => self::SHADOW_PRESETS_NOSHADOW,
} 'effect' => null,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 85,
),
'size' => array(
'sx' => null,
'sy' => null,
'kx' => null
),
'blur' => null,
'direction' => null,
'distance' => null,
'algn' => null,
'rotWithShape' => null
);
/** private $_glow_properties = array(
* Change Object State to True 'size' => null,
* 'color' => array(
* @return PHPExcel_Chart_GridLines 'type' => self::EXCEL_COLOR_TYPE_STANDARD,
*/ 'value' => 'black',
'alpha' => 40
)
);
private function _activateObject() { private $_soft_edges = array(
$this->_object_state = TRUE; 'size' => null
);
return $this; /**
} * Get Object State
*
* @return bool
*/
/** public function getObjectState()
* Set Line Color Properties {
* return $this->_object_state;
* @param string $value
* @param int $alpha
* @param string $type
*/
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) {
$this
->_activateObject()
->_line_properties['color'] = $this->setColorProperties(
$value,
$alpha,
$type);
}
/**
* Set Line Color Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*/
public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
$this->_activateObject();
(!is_null($line_width))
? $this->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
(!is_null($compound_type))
? $this->_line_properties['style']['compound'] = (string) $compound_type
: NULL;
(!is_null($dash_type))
? $this->_line_properties['style']['dash'] = (string) $dash_type
: NULL;
(!is_null($cap_type))
? $this->_line_properties['style']['cap'] = (string) $cap_type
: NULL;
(!is_null($join_type))
? $this->_line_properties['style']['join'] = (string) $join_type
: NULL;
(!is_null($head_arrow_type))
? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
(!is_null($head_arrow_size))
? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
(!is_null($end_arrow_type))
? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
(!is_null($end_arrow_size))
? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
}
/**
* Get Line Color Property
*
* @param string $parameter
*
* @return string
*/
public function getLineColorProperty($parameter) {
return $this->_line_properties['color'][$parameter];
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_properties['style'], $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*
*/
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
$this
->_activateObject()
->_setGlowSize($size)
->_setGlowColor($color_value, $color_alpha, $color_type);
}
/**
* Get Glow Color Property
*
* @param string $property
*
* @return string
*/
public function getGlowColor($property) {
return $this->_glow_properties['color'][$property];
}
/**
* Get Glow Size
*
* @return string
*/
public function getGlowSize() {
return $this->_glow_properties['size'];
}
/**
* Set Glow Size
*
* @param float $size
*
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowSize($size) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size);
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowColor($color, $alpha, $type) {
if (!is_null($color)) {
$this->_glow_properties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_glow_properties['color']['type'] = (string) $type;
} }
return $this; /**
} * Change Object State to True
*
* @return PHPExcel_Chart_GridLines
*/
/** private function _activateObject()
* Get Line Style Arrow Parameters {
* $this->_object_state = true;
* @param string $arrow_selector
* @param string $property_selector
*
* @return string
*/
public function getLineStyleArrowParameters($arrow_selector, $property_selector) { return $this;
return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector); }
}
/** /**
* Set Shadow Properties * Set Line Color Properties
* *
* @param int $sh_presets * @param string $value
* @param string $sh_color_value * @param int $alpha
* @param string $sh_color_type * @param string $type
* @param int $sh_color_alpha */
* @param string $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) { public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD)
$this {
->_activateObject() $this
->_setShadowPresetsProperties((int) $sh_presets) ->_activateObject()
->_setShadowColor( ->_line_properties['color'] = $this->setColorProperties(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value $value,
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] $alpha,
: $this->getTrueAlpha($sh_color_alpha) $type);
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type) }
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/** /**
* Set Shadow Presets Properties * Set Line Color Properties
* *
* @param int $shadow_presets * @param float $line_width
* * @param string $compound_type
* @return PHPExcel_Chart_GridLines * @param string $dash_type
*/ * @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*/
private function _setShadowPresetsProperties($shadow_presets) { public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null)
$this->_shadow_properties['presets'] = $shadow_presets; {
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets)); $this->_activateObject();
(!is_null($line_width))
? $this->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: null;
(!is_null($compound_type))
? $this->_line_properties['style']['compound'] = (string) $compound_type
: null;
(!is_null($dash_type))
? $this->_line_properties['style']['dash'] = (string) $dash_type
: null;
(!is_null($cap_type))
? $this->_line_properties['style']['cap'] = (string) $cap_type
: null;
(!is_null($join_type))
? $this->_line_properties['style']['join'] = (string) $join_type
: null;
(!is_null($head_arrow_type))
? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: null;
(!is_null($head_arrow_size))
? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: null;
(!is_null($end_arrow_type))
? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: null;
(!is_null($end_arrow_size))
? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: null;
}
return $this; /**
} * Get Line Color Property
*
* @param string $parameter
*
* @return string
*/
/** public function getLineColorProperty($parameter)
* Set Shadow Properties Values {
* return $this->_line_properties['color'][$parameter];
* @param array $properties_map }
* @param * $reference
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) { /**
$base_reference = $reference; * Get Line Style Property
foreach ($properties_map as $property_key => $property_val) { *
if (is_array($property_val)) { * @param array|string $elements
if ($reference === NULL) { *
$reference = & $this->_shadow_properties[$property_key]; * @return string
} else { */
$reference = & $reference[$property_key];
public function getLineStyleProperty($elements)
{
return $this->getArrayElementsValue($this->_line_properties['style'], $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*
*/
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null)
{
$this
->_activateObject()
->_setGlowSize($size)
->_setGlowColor($color_value, $color_alpha, $color_type);
}
/**
* Get Glow Color Property
*
* @param string $property
*
* @return string
*/
public function getGlowColor($property)
{
return $this->_glow_properties['color'][$property];
}
/**
* Get Glow Size
*
* @return string
*/
public function getGlowSize()
{
return $this->_glow_properties['size'];
}
/**
* Set Glow Size
*
* @param float $size
*
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowSize($size)
{
$this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size);
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowColor($color, $alpha, $type)
{
if (!is_null($color)) {
$this->_glow_properties['color']['value'] = (string) $color;
} }
$this->_setShadowProperiesMapValues($property_val, $reference); if (!is_null($alpha)) {
} else { $this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
} }
} if (!is_null($type)) {
$this->_glow_properties['color']['type'] = (string) $type;
}
return $this;
} }
return $this; /**
} * Get Line Style Arrow Parameters
*
* @param string $arrow_selector
* @param string $property_selector
*
* @return string
*/
public function getLineStyleArrowParameters($arrow_selector, $property_selector)
{
return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector);
}
/**
* Set Shadow Properties
*
* @param int $sh_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param int $sh_color_alpha
* @param string $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null)
{
$this
->_activateObject()
->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha']
: $this->getTrueAlpha($sh_color_alpha)
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/**
* Set Shadow Presets Properties
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowPresetsProperties($shadow_presets)
{
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = null)
{
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === null) {
$reference = & $this->_shadow_properties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === null) {
$this->_shadow_properties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/** /**
* Set Shadow Color * Set Shadow Color
@ -356,7 +374,8 @@ class PHPExcel_Chart_GridLines extends
* @param string $type * @param string $type
* @return PHPExcel_Chart_GridLines * @return PHPExcel_Chart_GridLines
*/ */
private function _setShadowColor($color, $alpha, $type) { private function _setShadowColor($color, $alpha, $type)
{
if (!is_null($color)) { if (!is_null($color)) {
$this->_shadow_properties['color']['value'] = (string) $color; $this->_shadow_properties['color']['value'] = (string) $color;
} }
@ -377,8 +396,9 @@ class PHPExcel_Chart_GridLines extends
* *
* @return PHPExcel_Chart_GridLines * @return PHPExcel_Chart_GridLines
*/ */
private function _setShadowBlur($blur) { private function _setShadowBlur($blur)
if ($blur !== NULL) { {
if ($blur !== null) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur); $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
} }
@ -392,8 +412,9 @@ class PHPExcel_Chart_GridLines extends
* @return PHPExcel_Chart_GridLines * @return PHPExcel_Chart_GridLines
*/ */
private function _setShadowAngle($angle) { private function _setShadowAngle($angle)
if ($angle !== NULL) { {
if ($angle !== null) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle); $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
} }
@ -406,8 +427,9 @@ class PHPExcel_Chart_GridLines extends
* @param float $distance * @param float $distance
* @return PHPExcel_Chart_GridLines * @return PHPExcel_Chart_GridLines
*/ */
private function _setShadowDistance($distance) { private function _setShadowDistance($distance)
if ($distance !== NULL) { {
if ($distance !== null) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance); $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
} }
@ -421,7 +443,8 @@ class PHPExcel_Chart_GridLines extends
* @param array $elements * @param array $elements
* @return string * @return string
*/ */
public function getShadowProperty($elements) { public function getShadowProperty($elements)
{
return $this->getArrayElementsValue($this->_shadow_properties, $elements); return $this->getArrayElementsValue($this->_shadow_properties, $elements);
} }
@ -430,7 +453,8 @@ class PHPExcel_Chart_GridLines extends
* *
* @param float $size * @param float $size
*/ */
public function setSoftEdgesSize($size) { public function setSoftEdgesSize($size)
{
if (!is_null($size)) { if (!is_null($size)) {
$this->_activateObject(); $this->_activateObject();
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size); $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
@ -442,7 +466,8 @@ class PHPExcel_Chart_GridLines extends
* *
* @return string * @return string
*/ */
public function getSoftEdgesSize() { public function getSoftEdgesSize()
{
return $this->_soft_edges['size']; return $this->_soft_edges['size'];
} }
} }

View File

@ -71,7 +71,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private static $_plotMark = 0; private static $_plotMark = 0;
private function _formatPointMarker($seriesPlot,$markerID) { private function _formatPointMarker($seriesPlot, $markerID) {
$plotMarkKeys = array_keys(self::$_markSet); $plotMarkKeys = array_keys(self::$_markSet);
if (is_null($markerID)) { if (is_null($markerID)) {
// Use default plot marker (next marker in the series) // Use default plot marker (next marker in the series)
@ -106,18 +106,18 @@ class PHPExcel_Chart_Renderer_jpgraph
} }
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($datasetLabels as $i => $datasetLabel) { foreach ($datasetLabels as $i => $datasetLabel) {
if (is_array($datasetLabel)) { if (is_array($datasetLabel)) {
if ($rotation == 'bar') { if ($rotation == 'bar') {
$datasetLabels[$i] = implode(" ",$datasetLabel); $datasetLabels[$i] = implode(" ", $datasetLabel);
} else { } else {
$datasetLabel = array_reverse($datasetLabel); $datasetLabel = array_reverse($datasetLabel);
$datasetLabels[$i] = implode("\n",$datasetLabel); $datasetLabels[$i] = implode("\n", $datasetLabel);
} }
} else { } else {
// Format labels according to any formatting code // Format labels according to any formatting code
if (!is_null($datasetLabelFormatCode)) { if (!is_null($datasetLabelFormatCode)) {
$datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode); $datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode);
} }
} }
++$testCurrentIndex; ++$testCurrentIndex;
@ -127,14 +127,14 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _formatDataSetLabels() } // function _formatDataSetLabels()
private function _percentageSumCalculation($groupID,$seriesCount) { private function _percentageSumCalculation($groupID, $seriesCount) {
// Adjust our values to a percentage value across all series in the group // Adjust our values to a percentage value across all series in the group
for($i = 0; $i < $seriesCount; ++$i) { for($i = 0; $i < $seriesCount; ++$i) {
if ($i == 0) { if ($i == 0) {
$sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
} else { } else {
$nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
foreach($nextValues as $k => $value) { foreach ($nextValues as $k => $value) {
if (isset($sumValues[$k])) { if (isset($sumValues[$k])) {
$sumValues[$k] += $value; $sumValues[$k] += $value;
} else { } else {
@ -148,8 +148,8 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _percentageSumCalculation() } // function _percentageSumCalculation()
private function _percentageAdjustValues($dataValues,$sumValues) { private function _percentageAdjustValues($dataValues, $sumValues) {
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
$dataValues[$k] = $dataValue / $sumValues[$k] * 100; $dataValues[$k] = $dataValue / $sumValues[$k] * 100;
} }
@ -165,7 +165,7 @@ class PHPExcel_Chart_Renderer_jpgraph
// If we do, it could be a plain string or an array // If we do, it could be a plain string or an array
if (is_array($caption)) { if (is_array($caption)) {
// Implode an array to a plain string // Implode an array to a plain string
$caption = implode('',$caption); $caption = implode('', $caption);
} }
} }
return $caption; return $caption;
@ -276,7 +276,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$seriesPlots = array(); $seriesPlots = array();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
} }
// Loop through each data series in turn // Loop through each data series in turn
@ -285,13 +285,13 @@ class PHPExcel_Chart_Renderer_jpgraph
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
} }
// Fill in any missing values in the $dataValues array // Fill in any missing values in the $dataValues array
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
while($k != $testCurrentIndex) { while ($k != $testCurrentIndex) {
$dataValues[$testCurrentIndex] = null; $dataValues[$testCurrentIndex] = null;
++$testCurrentIndex; ++$testCurrentIndex;
} }
@ -309,7 +309,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]); $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
} else { } else {
// Set the appropriate plot marker // Set the appropriate plot marker
$this->_formatPointMarker($seriesPlot,$marker); $this->_formatPointMarker($seriesPlot, $marker);
} }
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
$seriesPlot->SetLegend($dataLabel); $seriesPlot->SetLegend($dataLabel);
@ -352,20 +352,20 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$seriesPlots = array(); $seriesPlots = array();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
} }
// Loop through each data series in turn // Loop through each data series in turn
for($j = 0; $j < $seriesCount; ++$j) { for($j = 0; $j < $seriesCount; ++$j) {
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
} }
// Fill in any missing values in the $dataValues array // Fill in any missing values in the $dataValues array
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
while($k != $testCurrentIndex) { while ($k != $testCurrentIndex) {
$dataValues[$testCurrentIndex] = null; $dataValues[$testCurrentIndex] = null;
++$testCurrentIndex; ++$testCurrentIndex;
} }
@ -411,7 +411,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _renderPlotBar() } // function _renderPlotBar()
private function _renderPlotScatter($groupID,$bubble) { private function _renderPlotScatter($groupID, $bubble) {
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
$scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); $scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
@ -423,18 +423,18 @@ class PHPExcel_Chart_Renderer_jpgraph
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
foreach($dataValuesY as $k => $dataValueY) { foreach ($dataValuesY as $k => $dataValueY) {
$dataValuesY[$k] = $k; $dataValuesY[$k] = $k;
} }
$seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY); $seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
if ($scatterStyle == 'lineMarker') { if ($scatterStyle == 'lineMarker') {
$seriesPlot->SetLinkPoints(); $seriesPlot->SetLinkPoints();
$seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]); $seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]);
} elseif ($scatterStyle == 'smoothMarker') { } elseif ($scatterStyle == 'smoothMarker') {
$spline = new Spline($dataValuesY,$dataValuesX); $spline = new Spline($dataValuesY, $dataValuesX);
list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20); list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
$lplot = new LinePlot($splineDataX,$splineDataY); $lplot = new LinePlot($splineDataX, $splineDataY);
$lplot->SetColor(self::$_colourSet[self::$_plotColour]); $lplot->SetColor(self::$_colourSet[self::$_plotColour]);
$this->_graph->Add($lplot); $this->_graph->Add($lplot);
@ -446,7 +446,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesPlot->mark->SetSize($bubbleSize); $seriesPlot->mark->SetSize($bubbleSize);
} else { } else {
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
$this->_formatPointMarker($seriesPlot,$marker); $this->_formatPointMarker($seriesPlot, $marker);
} }
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
$seriesPlot->SetLegend($dataLabel); $seriesPlot->SetLegend($dataLabel);
@ -469,7 +469,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
$dataValues = array(); $dataValues = array();
foreach($dataValuesY as $k => $dataValueY) { foreach ($dataValuesY as $k => $dataValueY) {
$dataValues[$k] = implode(' ',array_reverse($dataValueY)); $dataValues[$k] = implode(' ',array_reverse($dataValueY));
} }
$tmp = array_shift($dataValues); $tmp = array_shift($dataValues);
@ -486,7 +486,7 @@ class PHPExcel_Chart_Renderer_jpgraph
if ($radarStyle == 'filled') { if ($radarStyle == 'filled') {
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]); $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]);
} }
$this->_formatPointMarker($seriesPlot,$marker); $this->_formatPointMarker($seriesPlot, $marker);
$seriesPlot->SetLegend($dataLabel); $seriesPlot->SetLegend($dataLabel);
$this->_graph->Add($seriesPlot); $this->_graph->Add($seriesPlot);
@ -520,13 +520,13 @@ class PHPExcel_Chart_Renderer_jpgraph
$dataValues = array(); $dataValues = array();
// Loop through each data series in turn and build the plot arrays // Loop through each data series in turn and build the plot arrays
foreach($plotOrder as $i => $v) { foreach ($plotOrder as $i => $v) {
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues();
foreach($dataValuesX as $j => $dataValueX) { foreach ($dataValuesX as $j => $dataValueX) {
$dataValues[$plotOrder[$i]][$j] = $dataValueX; $dataValues[$plotOrder[$i]][$j] = $dataValueX;
} }
} }
if(empty($dataValues)) { if (empty($dataValues)) {
return; return;
} }
@ -559,7 +559,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_renderCartesianPlotArea(); $this->_renderCartesianPlotArea();
for($i = 0; $i < $groupCount; ++$i) { for($i = 0; $i < $groupCount; ++$i) {
$this->_renderPlotLine($i,True,False,$dimensions); $this->_renderPlotLine($i,True,False, $dimensions);
} }
} // function _renderAreaChart() } // function _renderAreaChart()
@ -570,7 +570,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_renderCartesianPlotArea(); $this->_renderCartesianPlotArea();
for($i = 0; $i < $groupCount; ++$i) { for($i = 0; $i < $groupCount; ++$i) {
$this->_renderPlotLine($i,False,False,$dimensions); $this->_renderPlotLine($i,False,False, $dimensions);
} }
} // function _renderLineChart() } // function _renderLineChart()
@ -581,7 +581,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_renderCartesianPlotArea(); $this->_renderCartesianPlotArea();
for($i = 0; $i < $groupCount; ++$i) { for($i = 0; $i < $groupCount; ++$i) {
$this->_renderPlotBar($i,$dimensions); $this->_renderPlotBar($i, $dimensions);
} }
} // function _renderBarChart() } // function _renderBarChart()
@ -640,8 +640,8 @@ class PHPExcel_Chart_Renderer_jpgraph
// Fill in any missing values in the $dataValues array // Fill in any missing values in the $dataValues array
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
while($k != $testCurrentIndex) { while ($k != $testCurrentIndex) {
$dataValues[$testCurrentIndex] = null; $dataValues[$testCurrentIndex] = null;
++$testCurrentIndex; ++$testCurrentIndex;
} }
@ -707,7 +707,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _renderStockChart() } // function _renderStockChart()
private function _renderContourChart($groupCount,$dimensions) { private function _renderContourChart($groupCount, $dimensions) {
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php');
$this->_renderCartesianPlotArea('intint'); $this->_renderCartesianPlotArea('intint');
@ -718,7 +718,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _renderContourChart() } // function _renderContourChart()
private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) { private function _renderCombinationChart($groupCount, $dimensions, $outputDestination) {
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
@ -734,17 +734,17 @@ class PHPExcel_Chart_Renderer_jpgraph
case 'area3DChart' : case 'area3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'areaChart' : case 'areaChart' :
$this->_renderPlotLine($i,True,True,$dimensions); $this->_renderPlotLine($i,True,True, $dimensions);
break; break;
case 'bar3DChart' : case 'bar3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'barChart' : case 'barChart' :
$this->_renderPlotBar($i,$dimensions); $this->_renderPlotBar($i, $dimensions);
break; break;
case 'line3DChart' : case 'line3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'lineChart' : case 'lineChart' :
$this->_renderPlotLine($i,False,True,$dimensions); $this->_renderPlotLine($i,False,True, $dimensions);
break; break;
case 'scatterChart' : case 'scatterChart' :
$this->_renderPlotScatter($i,false); $this->_renderPlotScatter($i,false);
@ -785,7 +785,7 @@ class PHPExcel_Chart_Renderer_jpgraph
echo 'Chart is not yet implemented<br />'; echo 'Chart is not yet implemented<br />';
return false; return false;
} else { } else {
return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination); return $this->_renderCombinationChart($groupCount, $dimensions, $outputDestination);
} }
} }
@ -793,27 +793,27 @@ class PHPExcel_Chart_Renderer_jpgraph
case 'area3DChart' : case 'area3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'areaChart' : case 'areaChart' :
$this->_renderAreaChart($groupCount,$dimensions); $this->_renderAreaChart($groupCount, $dimensions);
break; break;
case 'bar3DChart' : case 'bar3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'barChart' : case 'barChart' :
$this->_renderBarChart($groupCount,$dimensions); $this->_renderBarChart($groupCount, $dimensions);
break; break;
case 'line3DChart' : case 'line3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'lineChart' : case 'lineChart' :
$this->_renderLineChart($groupCount,$dimensions); $this->_renderLineChart($groupCount, $dimensions);
break; break;
case 'pie3DChart' : case 'pie3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'pieChart' : case 'pieChart' :
$this->_renderPieChart($groupCount,$dimensions,False,False); $this->_renderPieChart($groupCount, $dimensions,False,False);
break; break;
case 'doughnut3DChart' : case 'doughnut3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'doughnutChart' : case 'doughnutChart' :
$this->_renderPieChart($groupCount,$dimensions,True,True); $this->_renderPieChart($groupCount, $dimensions,True,True);
break; break;
case 'scatterChart' : case 'scatterChart' :
$this->_renderScatterChart($groupCount); $this->_renderScatterChart($groupCount);
@ -827,10 +827,10 @@ class PHPExcel_Chart_Renderer_jpgraph
case 'surface3DChart' : case 'surface3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'surfaceChart' : case 'surfaceChart' :
$this->_renderContourChart($groupCount,$dimensions); $this->_renderContourChart($groupCount, $dimensions);
break; break;
case 'stockChart' : case 'stockChart' :
$this->_renderStockChart($groupCount,$dimensions); $this->_renderStockChart($groupCount, $dimensions);
break; break;
default : default :
echo $chartType.' is not yet implemented<br />'; echo $chartType.' is not yet implemented<br />';

View File

@ -466,7 +466,7 @@ class PHPExcel_DocumentProperties
$propertyType = self::PROPERTY_TYPE_STRING; $propertyType = self::PROPERTY_TYPE_STRING;
} elseif (is_float($propertyValue)) { } elseif (is_float($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_FLOAT; $propertyType = self::PROPERTY_TYPE_FLOAT;
} elseif(is_int($propertyValue)) { } elseif (is_int($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_INTEGER; $propertyType = self::PROPERTY_TYPE_INTEGER;
} elseif (is_bool($propertyValue)) { } elseif (is_bool($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_BOOLEAN; $propertyType = self::PROPERTY_TYPE_BOOLEAN;
@ -497,7 +497,7 @@ class PHPExcel_DocumentProperties
} }
} }
public static function convertProperty($propertyValue,$propertyType) public static function convertProperty($propertyValue, $propertyType)
{ {
switch ($propertyType) { switch ($propertyType) {
case 'empty': // Empty case 'empty': // Empty

View File

@ -637,7 +637,7 @@ class PHPExcel_Helper_HTML
protected function rgbToColour($rgb) { protected function rgbToColour($rgb) {
preg_match_all('/\d+/', $rgb, $values); preg_match_all('/\d+/', $rgb, $values);
foreach($values[0] as &$value) { foreach ($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT); $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
} }
return implode($values[0]); return implode($values[0]);
@ -655,7 +655,7 @@ class PHPExcel_Helper_HTML
if ($attributeName == 'color') { if ($attributeName == 'color') {
if (preg_match('/rgb\s*\(/', $attributeValue)) { if (preg_match('/rgb\s*\(/', $attributeValue)) {
$this->$attributeName = $this->rgbToColour($attributeValue); $this->$attributeName = $this->rgbToColour($attributeValue);
} elseif(strpos(trim($attributeValue), '#') === 0) { } elseif (strpos(trim($attributeValue), '#') === 0) {
$this->$attributeName = ltrim($attributeValue, '#'); $this->$attributeName = ltrim($attributeValue, '#');
} else { } else {
$this->$attributeName = $this->colourNameLookup($attributeValue); $this->$attributeName = $this->colourNameLookup($attributeValue);

View File

@ -203,7 +203,7 @@ class PHPExcel_IOFactory
{ {
$reader = self::createReaderForFile($pFilename); $reader = self::createReaderForFile($pFilename);
$className = get_class($reader); $className = get_class($reader);
$classType = explode('_',$className); $classType = explode('_', $className);
unset($reader); unset($reader);
return array_pop($classType); return array_pop($classType);
} }

View File

@ -110,7 +110,7 @@ class PHPExcel_NamedRange
// Re-attach // Re-attach
if ($this->_worksheet !== NULL) { if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet); $this->_worksheet->getParent()->removeNamedRange($this->_name, $this->_worksheet);
} }
$this->_name = $value; $this->_name = $value;

View File

@ -266,7 +266,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
// Loop through each line of the file in turn // Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
$columnLetter = 'A'; $columnLetter = 'A';
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) { if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures // Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum); $rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);

View File

@ -101,7 +101,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
fclose($fileHandle); fclose($fileHandle);
$valid = true; $valid = true;
foreach($signature as $match) { foreach ($signature as $match) {
// every part of the signature must be present // every part of the signature must be present
if (strpos($data, $match) === false) { if (strpos($data, $match) === false) {
$valid = false; $valid = false;
@ -110,10 +110,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
// Retrieve charset encoding // Retrieve charset encoding
if(preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um',$data,$matches)) { if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um', $data, $matches)) {
$this->_charSet = strtoupper($matches[1]); $this->_charSet = strtoupper($matches[1]);
} }
// echo 'Character Set is ',$this->_charSet,'<br />'; // echo 'Character Set is ', $this->_charSet,'<br />';
return $valid; return $valid;
} }
@ -141,9 +141,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$namespaces = $xml->getNamespaces(true); $namespaces = $xml->getNamespaces(true);
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
$worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet); $worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet);
} }
return $worksheetNames; return $worksheetNames;
@ -170,7 +170,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetID = 1; $worksheetID = 1;
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
$tmpInfo = array(); $tmpInfo = array();
@ -189,11 +189,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if (isset($worksheet->Table->Row)) { if (isset($worksheet->Table->Row)) {
$rowIndex = 0; $rowIndex = 0;
foreach($worksheet->Table->Row as $rowData) { foreach ($worksheet->Table->Row as $rowData) {
$columnIndex = 0; $columnIndex = 0;
$rowHasData = false; $rowHasData = false;
foreach($rowData->Cell as $cell) { foreach ($rowData->Cell as $cell) {
if (isset($cell->Data)) { if (isset($cell->Data)) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex); $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
$rowHasData = true; $rowHasData = true;
@ -241,7 +241,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) { foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) { if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style; $styleAttributeValue = $style;
return true; return true;
@ -336,52 +336,52 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$docProps = $objPHPExcel->getProperties(); $docProps = $objPHPExcel->getProperties();
if (isset($xml->DocumentProperties[0])) { if (isset($xml->DocumentProperties[0])) {
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) { switch ($propertyName) {
case 'Title' : case 'Title' :
$docProps->setTitle(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Subject' : case 'Subject' :
$docProps->setSubject(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Author' : case 'Author' :
$docProps->setCreator(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Created' : case 'Created' :
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'LastAuthor' : case 'LastAuthor' :
$docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'LastSaved' : case 'LastSaved' :
$lastSaveDate = strtotime($propertyValue); $lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate); $docProps->setModified($lastSaveDate);
break; break;
case 'Company' : case 'Company' :
$docProps->setCompany(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Category' : case 'Category' :
$docProps->setCategory(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Manager' : case 'Manager' :
$docProps->setManager(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Keywords' : case 'Keywords' :
$docProps->setKeywords(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Description' : case 'Description' :
$docProps->setDescription(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
} }
} }
} }
if (isset($xml->CustomDocumentProperties)) { if (isset($xml->CustomDocumentProperties)) {
foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
$propertyAttributes = $propertyValue->attributes($namespaces['dt']); $propertyAttributes = $propertyValue->attributes($namespaces['dt']);
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str',$propertyName); $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName);
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
switch((string) $propertyAttributes) { switch ((string) $propertyAttributes) {
case 'string' : case 'string' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue); $propertyValue = trim($propertyValue);
@ -403,11 +403,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$propertyValue = strtotime(trim($propertyValue)); $propertyValue = strtotime(trim($propertyValue));
break; break;
} }
$docProps->setCustomProperty($propertyName,$propertyValue,$propertyType); $docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
} }
} }
foreach($xml->Styles[0] as $style) { foreach ($xml->Styles[0] as $style) {
$style_ss = $style->attributes($namespaces['ss']); $style_ss = $style->attributes($namespaces['ss']);
$styleID = (string) $style_ss['ID']; $styleID = (string) $style_ss['ID'];
// echo 'Style ID = '.$styleID.'<br />'; // echo 'Style ID = '.$styleID.'<br />';
@ -421,17 +421,17 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo $styleType.'<br />'; // echo $styleType.'<br />';
switch ($styleType) { switch ($styleType) {
case 'Alignment' : case 'Alignment' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Vertical' : case 'Vertical' :
if (self::identifyFixedStyleValue($verticalAlignmentStyles,$styleAttributeValue)) { if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
} }
break; break;
case 'Horizontal' : case 'Horizontal' :
if (self::identifyFixedStyleValue($horizontalAlignmentStyles,$styleAttributeValue)) { if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
} }
break; break;
@ -442,10 +442,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Borders' : case 'Borders' :
foreach($styleData->Border as $borderStyle) { foreach ($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']); $borderAttributes = $borderStyle->attributes($namespaces['ss']);
$thisBorder = array(); $thisBorder = array();
foreach($borderAttributes as $borderStyleKey => $borderStyleValue) { foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />'; // echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) { switch ($borderStyleKey) {
case 'LineStyle' : case 'LineStyle' :
@ -472,7 +472,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Font' : case 'Font' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
@ -492,7 +492,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$this->_styles[$styleID]['font']['italic'] = true; $this->_styles[$styleID]['font']['italic'] = true;
break; break;
case 'Underline' : case 'Underline' :
if (self::identifyFixedStyleValue($underlineStyles,$styleAttributeValue)) { if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue; $this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
} }
break; break;
@ -500,7 +500,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Interior' : case 'Interior' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Color' : case 'Color' :
@ -510,9 +510,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'NumberFormat' : case 'NumberFormat' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = str_replace($fromFormats,$toFormats,$styleAttributeValue); $styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue);
switch ($styleAttributeValue) { switch ($styleAttributeValue) {
case 'Short Date' : case 'Short Date' :
$styleAttributeValue = 'dd/mm/yyyy'; $styleAttributeValue = 'dd/mm/yyyy';
@ -524,7 +524,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Protection' : case 'Protection' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
} }
break; break;
@ -538,7 +538,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetID = 0; $worksheetID = 0;
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) && if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
@ -546,13 +546,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
continue; continue;
} }
// echo '<h3>Worksheet: ',$worksheet_ss['Name'],'<h3>'; // echo '<h3>Worksheet: ', $worksheet_ss['Name'],'<h3>';
// //
// Create new Worksheet // Create new Worksheet
$objPHPExcel->createSheet(); $objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID); $objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) { if (isset($worksheet_ss['Name'])) {
$worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet); $worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet);
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
// formula cells... during the load, all formulae should be correct, and we're simply bringing // formula cells... during the load, all formulae should be correct, and we're simply bringing
// the worksheet name in line with the formula, not the reverse // the worksheet name in line with the formula, not the reverse
@ -561,7 +561,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$columnID = 'A'; $columnID = 'A';
if (isset($worksheet->Table->Column)) { if (isset($worksheet->Table->Column)) {
foreach($worksheet->Table->Column as $columnData) { foreach ($worksheet->Table->Column as $columnData) {
$columnData_ss = $columnData->attributes($namespaces['ss']); $columnData_ss = $columnData->attributes($namespaces['ss']);
if (isset($columnData_ss['Index'])) { if (isset($columnData_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1); $columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1);
@ -578,7 +578,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$rowID = 1; $rowID = 1;
if (isset($worksheet->Table->Row)) { if (isset($worksheet->Table->Row)) {
$additionalMergedCells = 0; $additionalMergedCells = 0;
foreach($worksheet->Table->Row as $rowData) { foreach ($worksheet->Table->Row as $rowData) {
$rowHasData = false; $rowHasData = false;
$row_ss = $rowData->attributes($namespaces['ss']); $row_ss = $rowData->attributes($namespaces['ss']);
if (isset($row_ss['Index'])) { if (isset($row_ss['Index'])) {
@ -587,7 +587,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo '<b>Row '.$rowID.'</b><br />'; // echo '<b>Row '.$rowID.'</b><br />';
$columnID = 'A'; $columnID = 'A';
foreach($rowData->Cell as $cell) { foreach ($rowData->Cell as $cell) {
$cell_ss = $cell->attributes($namespaces['ss']); $cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) { if (isset($cell_ss['Index'])) {
@ -643,7 +643,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
const TYPE_ERROR = 'e'; const TYPE_ERROR = 'e';
*/ */
case 'String' : case 'String' :
$cellValue = self::_convertStringEncoding($cellValue,$this->_charSet); $cellValue = self::_convertStringEncoding($cellValue, $this->_charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = PHPExcel_Cell_DataType::TYPE_STRING;
break; break;
case 'Number' : case 'Number' :
@ -673,31 +673,31 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID); $columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
if (substr($cellDataFormula,0,3) == 'of:') { if (substr($cellDataFormula,0,3) == 'of:') {
$cellDataFormula = substr($cellDataFormula,3); $cellDataFormula = substr($cellDataFormula,3);
// echo 'Before: ',$cellDataFormula,'<br />'; // echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) { if ($key = !$key) {
$value = str_replace(array('[.','.',']'),'',$value); $value = str_replace(array('[.','.',']'),'', $value);
} }
} }
} else { } else {
// Convert R1C1 style references to A1 style references (but only when not quoted) // Convert R1C1 style references to A1 style references (but only when not quoted)
// echo 'Before: ',$cellDataFormula,'<br />'; // echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) { if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through // through the formula from left to right. Reversing means that we work right to left.through
// the formula // the formula
$cellReferences = array_reverse($cellReferences); $cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference // then modify the formula to use that new reference
foreach($cellReferences as $cellReference) { foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0]; $rowReference = $cellReference[2][0];
// Empty R reference is the current row // Empty R reference is the current row
if ($rowReference == '') $rowReference = $rowID; if ($rowReference == '') $rowReference = $rowID;
@ -709,20 +709,20 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]'); if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0]));
} }
} }
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"', $temp);
// echo 'After: ',$cellDataFormula,'<br />'; // echo 'After: ', $cellDataFormula,'<br />';
} }
// echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />'; // echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />';
// //
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue),$type); $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue), $type);
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
// echo 'Formula result is '.$cellValue.'<br />'; // echo 'Formula result is '.$cellValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue); $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue);
@ -736,15 +736,15 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$author = 'unknown'; $author = 'unknown';
if (isset($commentAttributes->Author)) { if (isset($commentAttributes->Author)) {
$author = (string)$commentAttributes->Author; $author = (string)$commentAttributes->Author;
// echo 'Author: ',$author,'<br />'; // echo 'Author: ', $author,'<br />';
} }
$node = $cell->Comment->Data->asXML(); $node = $cell->Comment->Data->asXML();
// $annotation = str_replace('html:','',substr($node,49,-10)); // $annotation = str_replace('html:','',substr($node,49,-10));
// echo $annotation,'<br />'; // echo $annotation,'<br />';
$annotation = strip_tags($node); $annotation = strip_tags($node);
// echo 'Annotation: ',$annotation,'<br />'; // echo 'Annotation: ', $annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
->setAuthor(self::_convertStringEncoding($author ,$this->_charSet)) ->setAuthor(self::_convertStringEncoding($author , $this->_charSet))
->setText($this->_parseRichText($annotation) ); ->setText($this->_parseRichText($annotation) );
} }
@ -790,9 +790,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
protected static function _convertStringEncoding($string,$charset) { protected static function _convertStringEncoding($string, $charset) {
if ($charset != 'UTF-8') { if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset); return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8', $charset);
} }
return $string; return $string;
} }
@ -801,7 +801,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
protected function _parseRichText($is = '') { protected function _parseRichText($is = '') {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is,$this->_charSet)); $value->createText(self::_convertStringEncoding($is, $this->_charSet));
return $value; return $value;
} }

View File

@ -217,13 +217,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) { if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) {
$row = $xml->getAttribute('r'); $row = $xml->getAttribute('r');
$tmpInfo['totalRows'] = $row; $tmpInfo['totalRows'] = $row;
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$currCells = 0; $currCells = 0;
} elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) { } elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) {
$currCells++; $currCells++;
} }
} }
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$xml->close(); $xml->close();
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
@ -267,7 +267,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} // function _castToString() } // function _castToString()
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) { private function _castToFormula($c, $r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas, $castBaseType) {
// echo 'Formula', PHP_EOL; // echo 'Formula', PHP_EOL;
// echo '$c->f is ', $c->f, PHP_EOL; // echo '$c->f is ', $c->f, PHP_EOL;
$cellDataType = 'f'; $cellDataType = 'f';
@ -381,7 +381,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$themeColours = array(); $themeColours = array();
foreach ($colourScheme as $k => $xmlColour) { foreach ($colourScheme as $k => $xmlColour) {
$themePos = array_search($k,$themeOrderArray); $themePos = array_search($k, $themeOrderArray);
if ($themePos === false) { if ($themePos === false) {
$themePos = $themeOrderAdditional++; $themePos = $themeOrderAdditional++;
} }
@ -393,7 +393,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$themeColours[$themePos] = $xmlColourData['val']; $themeColours[$themePos] = $xmlColourData['val'];
} }
} }
self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName,$colourSchemeName,$themeColours); self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName, $colourSchemeName, $themeColours);
} }
break; break;
} }
@ -443,9 +443,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
$attributeType = $cellDataOfficeChildren->getName(); $attributeType = $cellDataOfficeChildren->getName();
$attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; $attributeValue = (string) $cellDataOfficeChildren->{$attributeType};
$attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue,$attributeType); $attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue, $attributeType);
$attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType); $attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType);
$docProps->setCustomProperty($propertyName,$attributeValue,$attributeType); $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
} }
} }
} }
@ -453,7 +453,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
//Ribbon //Ribbon
case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility": case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility":
$customUI = $rel['Target']; $customUI = $rel['Target'];
if(!is_null($customUI)){ if (!is_null($customUI)) {
$this->_readRibbon($excel, $customUI, $zip); $this->_readRibbon($excel, $customUI, $zip);
} }
break; break;
@ -478,7 +478,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$worksheets = array(); $worksheets = array();
$macros = $customUI = NULL; $macros = $customUI = NULL;
foreach ($relsWorkbook->Relationship as $ele) { foreach ($relsWorkbook->Relationship as $ele) {
switch($ele['Type']){ switch ($ele['Type']) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
$worksheets[(string) $ele["Id"]] = $ele["Target"]; $worksheets[(string) $ele["Id"]] = $ele["Target"];
break; break;
@ -489,14 +489,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if(!is_null($macros)){ if (!is_null($macros)) {
$macrosCode = $this->_getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin $macrosCode = $this->_getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin
if($macrosCode !== false){ if ($macrosCode !== false) {
$excel->setMacrosCode($macrosCode); $excel->setMacrosCode($macrosCode);
$excel->setHasMacros(true); $excel->setHasMacros(true);
//short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir //short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir
$Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin'); $Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin');
if($Certificate !== false) if ($Certificate !== false)
$excel->setMacrosCertificate($Certificate); $excel->setMacrosCertificate($Certificate);
} }
} }
@ -865,7 +865,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$value = self::_castToBool($c); $value = self::_castToBool($c);
} else { } else {
// Formula // Formula
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToBool'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToBool');
if (isset($c->f['t'])) { if (isset($c->f['t'])) {
$att = array(); $att = array();
$att = $c->f; $att = $c->f;
@ -885,7 +885,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$value = self::_castToError($c); $value = self::_castToError($c);
} else { } else {
// Formula // Formula
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToError');
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL; // echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
} }
@ -899,7 +899,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} else { } else {
// echo 'Treat as Formula', PHP_EOL; // echo 'Treat as Formula', PHP_EOL;
// Formula // Formula
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToString');
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL; // echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
} }
@ -1207,8 +1207,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate // Uppercase coordinate
$range = strtoupper($dataValidation["sqref"]); $range = strtoupper($dataValidation["sqref"]);
$rangeSet = explode(' ',$range); $rangeSet = explode(' ', $range);
foreach($rangeSet as $range) { foreach ($rangeSet as $range) {
$stRange = $docSheet->shrinkRangeToFit($range); $stRange = $docSheet->shrinkRangeToFit($range);
// Extract all cell references in $range // Extract all cell references in $range
@ -1307,7 +1307,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Loop through contents // Loop through contents
foreach ($commentsFile->commentList->comment as $comment) { foreach ($commentsFile->commentList->comment as $comment) {
if(!empty($comment['authorId'])) if (!empty($comment['authorId']))
$docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] );
$docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) ); $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) );
} }
@ -1526,7 +1526,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000); $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
} }
$objDrawing->setWorksheet($docSheet); $objDrawing->setWorksheet($docSheet);
} elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) { } elseif (($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1); $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff); $fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff); $fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
@ -1561,7 +1561,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$extractedRange = (string)$definedName; $extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange);
if (($spos = strpos($extractedRange,'!')) !== false) { if (($spos = strpos($extractedRange,'!')) !== false) {
$extractedRange = substr($extractedRange,0,$spos).str_replace('$', '', substr($extractedRange,$spos)); $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos));
} else { } else {
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
} }
@ -1611,7 +1611,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
$rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma?
$newRangeSets = array(); $newRangeSets = array();
foreach($rangeSets as $rangeSet) { foreach ($rangeSets as $rangeSet) {
$range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark?
$rangeSet = isset($range[1]) ? $range[1] : $range[0]; $rangeSet = isset($range[1]) ? $range[1] : $range[0];
if (strpos($rangeSet, ':') === FALSE) { if (strpos($rangeSet, ':') === FALSE) {
@ -1619,7 +1619,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$newRangeSets[] = str_replace('$', '', $rangeSet); $newRangeSets[] = str_replace('$', '', $rangeSet);
} }
$docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets)); $docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets));
break; break;
default: default:
@ -1640,7 +1640,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$extractedRange = (string)$definedName; $extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange);
if (($spos = strpos($extractedRange,'!')) !== false) { if (($spos = strpos($extractedRange,'!')) !== false) {
$extractedRange = substr($extractedRange,0,$spos).str_replace('$', '', substr($extractedRange,$spos)); $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos));
} else { } else {
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
} }
@ -1731,12 +1731,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml'));
// echo 'Chart ',$chartEntryRef,'<br />'; // echo 'Chart ', $chartEntryRef,'<br />';
// var_dump($charts[$chartEntryRef]); // var_dump($charts[$chartEntryRef]);
// //
if (isset($charts[$chartEntryRef])) { if (isset($charts[$chartEntryRef])) {
$chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id']; $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id'];
// echo 'Position Ref ',$chartPositionRef,'<br />'; // echo 'Position Ref ', $chartPositionRef,'<br />';
if (isset($chartDetails[$chartPositionRef])) { if (isset($chartDetails[$chartPositionRef])) {
// var_dump($chartDetails[$chartPositionRef]); // var_dump($chartDetails[$chartPositionRef]);
@ -1767,7 +1767,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB(); return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
} else if (isset($color["theme"])) { } else if (isset($color["theme"])) {
if (self::$_theme !== NULL) { if (self::$_theme !== NULL) {
$returnColour = self::$_theme->getColourByIndex((int)$color["theme"]); $returnColour = self::$_theme->getColourByIndex((int)$color["theme"]);
@ -1832,7 +1832,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($style->fill)) { if (isset($style->fill)) {
if ($style->fill->gradientFill) { if ($style->fill->gradientFill) {
$gradientFill = $style->fill->gradientFill[0]; $gradientFill = $style->fill->gradientFill[0];
if(!empty($gradientFill["type"])) { if (!empty($gradientFill["type"])) {
$docStyle->getFill()->setFillType((string) $gradientFill["type"]); $docStyle->getFill()->setFillType((string) $gradientFill["type"]);
} }
$docStyle->getFill()->setRotation(floatval($gradientFill["degree"])); $docStyle->getFill()->setRotation(floatval($gradientFill["degree"]));
@ -1934,7 +1934,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($is->t)) { if (isset($is->t)) {
$value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) );
} else { } else {
if(is_object($is->r)) { if (is_object($is->r)) {
foreach ($is->r as $run) { foreach ($is->r as $run) {
if (!isset($run->rPr)) { if (!isset($run->rPr)) {
$objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); $objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );

View File

@ -51,95 +51,95 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _getAttribute() } // function _getAttribute()
private static function _readColor($color,$background=false) { private static function _readColor($color, $background=false) {
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB(); return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
} }
} }
public static function readChart($chartElements,$chartName) { public static function readChart($chartElements, $chartName) {
$namespacesChartMeta = $chartElements->getNamespaces(true); $namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']); $chartElementsC = $chartElements->children($namespacesChartMeta['c']);
$XaxisLabel = $YaxisLabel = $legend = $title = NULL; $XaxisLabel = $YaxisLabel = $legend = $title = NULL;
$dispBlanksAs = $plotVisOnly = NULL; $dispBlanksAs = $plotVisOnly = NULL;
foreach($chartElementsC as $chartElementKey => $chartElement) { foreach ($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) { switch ($chartElementKey) {
case "chart": case "chart":
foreach($chartElement as $chartDetailsKey => $chartDetails) { foreach ($chartElement as $chartDetailsKey => $chartDetails) {
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']); $chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
switch ($chartDetailsKey) { switch ($chartDetailsKey) {
case "plotArea": case "plotArea":
$plotAreaLayout = $XaxisLable = $YaxisLable = null; $plotAreaLayout = $XaxisLable = $YaxisLable = null;
$plotSeries = $plotAttributes = array(); $plotSeries = $plotAttributes = array();
foreach($chartDetails as $chartDetailKey => $chartDetail) { foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) { switch ($chartDetailKey) {
case "layout": case "layout":
$plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea'); $plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'plotArea');
break; break;
case "catAx": case "catAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat'); $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "dateAx": case "dateAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat'); $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "valAx": case "valAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat'); $YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "barChart": case "barChart":
case "bar3DChart": case "bar3DChart":
$barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string'); $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotDirection($barDirection); $plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "lineChart": case "lineChart":
case "line3DChart": case "line3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "areaChart": case "areaChart":
case "area3DChart": case "area3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "doughnutChart": case "doughnutChart":
case "pieChart": case "pieChart":
case "pie3DChart": case "pie3DChart":
$explosion = isset($chartDetail->ser->explosion); $explosion = isset($chartDetail->ser->explosion);
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($explosion); $plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "scatterChart": case "scatterChart":
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string'); $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($scatterStyle); $plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "bubbleChart": case "bubbleChart":
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer'); $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($bubbleScale); $plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "radarChart": case "radarChart":
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string'); $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($radarStyle); $plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
@ -147,13 +147,13 @@ class PHPExcel_Reader_Excel2007_Chart
case "surfaceChart": case "surfaceChart":
case "surface3DChart": case "surface3DChart":
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean'); $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($wireFrame); $plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "stockChart": case "stockChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($plotAreaLayout); $plotAttributes = self::_readChartAttributes($plotAreaLayout);
break; break;
} }
@ -161,8 +161,8 @@ class PHPExcel_Reader_Excel2007_Chart
if ($plotAreaLayout == NULL) { if ($plotAreaLayout == NULL) {
$plotAreaLayout = new PHPExcel_Chart_Layout(); $plotAreaLayout = new PHPExcel_Chart_Layout();
} }
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries); $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
self::_setChartAttributes($plotAreaLayout,$plotAttributes); self::_setChartAttributes($plotAreaLayout, $plotAttributes);
break; break;
case "plotVisOnly": case "plotVisOnly":
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string'); $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
@ -171,13 +171,13 @@ class PHPExcel_Reader_Excel2007_Chart
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string'); $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
break; break;
case "title": case "title":
$title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title'); $title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title');
break; break;
case "legend": case "legend":
$legendPos = 'r'; $legendPos = 'r';
$legendLayout = null; $legendLayout = null;
$legendOverlay = false; $legendOverlay = false;
foreach($chartDetails as $chartDetailKey => $chartDetail) { foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) { switch ($chartDetailKey) {
case "legendPos": case "legendPos":
$legendPos = self::_getAttribute($chartDetail, 'val', 'string'); $legendPos = self::_getAttribute($chartDetail, 'val', 'string');
@ -186,7 +186,7 @@ class PHPExcel_Reader_Excel2007_Chart
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean'); $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
break; break;
case "layout": case "layout":
$legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend'); $legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'legend');
break; break;
} }
} }
@ -196,20 +196,20 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
} }
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel); $chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel);
return $chart; return $chart;
} // function readChart() } // function readChart()
private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) { private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) {
$caption = array(); $caption = array();
$titleLayout = null; $titleLayout = null;
foreach($titleDetails as $titleDetailKey => $chartDetail) { foreach ($titleDetails as $titleDetailKey => $chartDetail) {
switch ($titleDetailKey) { switch ($titleDetailKey) {
case "tx": case "tx":
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']); $titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
foreach($titleDetails as $titleKey => $titleDetail) { foreach ($titleDetails as $titleKey => $titleDetail) {
switch ($titleKey) { switch ($titleKey) {
case "p": case "p":
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']); $titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
@ -218,7 +218,7 @@ class PHPExcel_Reader_Excel2007_Chart
} }
break; break;
case "layout": case "layout":
$titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta); $titleLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta);
break; break;
} }
} }
@ -227,7 +227,7 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartTitle() } // function _chartTitle()
private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) { private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) {
if (!isset($chartDetail->manualLayout)) { if (!isset($chartDetail->manualLayout)) {
return null; return null;
} }
@ -236,7 +236,7 @@ class PHPExcel_Reader_Excel2007_Chart
return null; return null;
} }
$layout = array(); $layout = array();
foreach($details as $detailKey => $detail) { foreach ($details as $detailKey => $detail) {
// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL; // echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
$layout[$detailKey] = self::_getAttribute($detail, 'val', 'string'); $layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
} }
@ -244,20 +244,20 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartLayoutDetails() } // function _chartLayoutDetails()
private static function _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) { private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) {
$multiSeriesType = NULL; $multiSeriesType = NULL;
$smoothLine = false; $smoothLine = false;
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array(); $seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']); $seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
foreach($seriesDetailSet as $seriesDetailKey => $seriesDetails) { foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
switch ($seriesDetailKey) { switch ($seriesDetailKey) {
case "grouping": case "grouping":
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string'); $multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
break; break;
case "ser": case "ser":
$marker = NULL; $marker = NULL;
foreach($seriesDetails as $seriesKey => $seriesDetail) { foreach ($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) { switch ($seriesKey) {
case "idx": case "idx":
$seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer'); $seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
@ -267,7 +267,7 @@ class PHPExcel_Reader_Excel2007_Chart
$plotOrder[$seriesIndex] = $seriesOrder; $plotOrder[$seriesIndex] = $seriesOrder;
break; break;
case "tx": case "tx":
$seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta); $seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break; break;
case "marker": case "marker":
$marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string'); $marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
@ -276,22 +276,22 @@ class PHPExcel_Reader_Excel2007_Chart
$smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean'); $smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
break; break;
case "cat": case "cat":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta); $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break; break;
case "val": case "val":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker); $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
case "xVal": case "xVal":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker); $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
case "yVal": case "yVal":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker); $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
} }
} }
} }
} }
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine); return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
} // function _chartDataSeries() } // function _chartDataSeries()
@ -300,35 +300,35 @@ class PHPExcel_Reader_Excel2007_Chart
$seriesSource = (string) $seriesDetail->strRef->f; $seriesSource = (string) $seriesDetail->strRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->numRef)) { } elseif (isset($seriesDetail->numRef)) {
$seriesSource = (string) $seriesDetail->numRef->f; $seriesSource = (string) $seriesDetail->numRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c'])); $seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->multiLvlStrRef)) { } elseif (isset($seriesDetail->multiLvlStrRef)) {
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f; $seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']); $seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->multiLvlNumRef)) { } elseif (isset($seriesDetail->multiLvlNumRef)) {
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f; $seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']); $seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} }
return null; return null;
} // function _chartDataSeriesValueSet() } // function _chartDataSeriesValueSet()
private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') { private static function _chartDataSeriesValues($seriesValueSet, $dataType='n') {
$seriesVal = array(); $seriesVal = array();
$formatCode = ''; $formatCode = '';
$pointCount = 0; $pointCount = 0;
foreach($seriesValueSet as $seriesValueIdx => $seriesValue) { foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) { switch ($seriesValueIdx) {
case 'ptCount': case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer'); $pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
@ -358,13 +358,13 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartDataSeriesValues() } // function _chartDataSeriesValues()
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') { private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType='n') {
$seriesVal = array(); $seriesVal = array();
$formatCode = ''; $formatCode = '';
$pointCount = 0; $pointCount = 0;
foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) { foreach ($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
foreach($seriesLevel as $seriesValueIdx => $seriesValue) { foreach ($seriesLevel as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) { switch ($seriesValueIdx) {
case 'ptCount': case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer'); $pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
@ -393,7 +393,7 @@ class PHPExcel_Reader_Excel2007_Chart
private static function _parseRichText($titleDetailPart = null) { private static function _parseRichText($titleDetailPart = null) {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
if (isset($titleDetailElement->t)) { if (isset($titleDetailElement->t)) {
$objText = $value->createTextRun( (string) $titleDetailElement->t ); $objText = $value->createTextRun( (string) $titleDetailElement->t );
} }
@ -426,7 +426,7 @@ class PHPExcel_Reader_Excel2007_Chart
if (!is_null($baseline)) { if (!is_null($baseline)) {
if ($baseline > 0) { if ($baseline > 0) {
$objText->getFont()->setSuperScript(true); $objText->getFont()->setSuperScript(true);
} elseif($baseline < 0) { } elseif ($baseline < 0) {
$objText->getFont()->setSubScript(true); $objText->getFont()->setSubScript(true);
} }
} }
@ -435,7 +435,7 @@ class PHPExcel_Reader_Excel2007_Chart
if (!is_null($underscore)) { if (!is_null($underscore)) {
if ($underscore == 'sng') { if ($underscore == 'sng') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
} elseif($underscore == 'dbl') { } elseif ($underscore == 'dbl') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
} else { } else {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
@ -485,10 +485,10 @@ class PHPExcel_Reader_Excel2007_Chart
return $plotAttributes; return $plotAttributes;
} }
private static function _setChartAttributes($plotArea,$plotAttributes) private static function _setChartAttributes($plotArea, $plotAttributes)
{ {
foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch($plotAttributeKey) { switch ($plotAttributeKey) {
case 'showLegendKey' : case 'showLegendKey' :
$plotArea->setShowLegendKey($plotAttributeValue); $plotArea->setShowLegendKey($plotAttributeValue);
break; break;

View File

@ -69,7 +69,7 @@ class PHPExcel_Reader_Excel2007_Theme
* Create a new PHPExcel_Theme * Create a new PHPExcel_Theme
* *
*/ */
public function __construct($themeName,$colourSchemeName,$colourMap) public function __construct($themeName, $colourSchemeName, $colourMap)
{ {
// Initialise values // Initialise values
$this->_themeName = $themeName; $this->_themeName = $themeName;

View File

@ -676,7 +676,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
foreach ($this->_objFonts as $objFont) { foreach ($this->_objFonts as $objFont) {
if (isset($objFont->colorIndex)) { if (isset($objFont->colorIndex)) {
$color = self::_readColor($objFont->colorIndex,$this->_palette,$this->_version); $color = self::_readColor($objFont->colorIndex, $this->_palette, $this->_version);
$objFont->getColor()->setRGB($color['rgb']); $objFont->getColor()->setRGB($color['rgb']);
} }
} }
@ -686,12 +686,12 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$fill = $objStyle->getFill(); $fill = $objStyle->getFill();
if (isset($fill->startcolorIndex)) { if (isset($fill->startcolorIndex)) {
$startColor = self::_readColor($fill->startcolorIndex,$this->_palette,$this->_version); $startColor = self::_readColor($fill->startcolorIndex, $this->_palette, $this->_version);
$fill->getStartColor()->setRGB($startColor['rgb']); $fill->getStartColor()->setRGB($startColor['rgb']);
} }
if (isset($fill->endcolorIndex)) { if (isset($fill->endcolorIndex)) {
$endColor = self::_readColor($fill->endcolorIndex,$this->_palette,$this->_version); $endColor = self::_readColor($fill->endcolorIndex, $this->_palette, $this->_version);
$fill->getEndColor()->setRGB($endColor['rgb']); $fill->getEndColor()->setRGB($endColor['rgb']);
} }
@ -703,27 +703,27 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$diagonal = $objStyle->getBorders()->getDiagonal(); $diagonal = $objStyle->getBorders()->getDiagonal();
if (isset($top->colorIndex)) { if (isset($top->colorIndex)) {
$borderTopColor = self::_readColor($top->colorIndex,$this->_palette,$this->_version); $borderTopColor = self::_readColor($top->colorIndex, $this->_palette, $this->_version);
$top->getColor()->setRGB($borderTopColor['rgb']); $top->getColor()->setRGB($borderTopColor['rgb']);
} }
if (isset($right->colorIndex)) { if (isset($right->colorIndex)) {
$borderRightColor = self::_readColor($right->colorIndex,$this->_palette,$this->_version); $borderRightColor = self::_readColor($right->colorIndex, $this->_palette, $this->_version);
$right->getColor()->setRGB($borderRightColor['rgb']); $right->getColor()->setRGB($borderRightColor['rgb']);
} }
if (isset($bottom->colorIndex)) { if (isset($bottom->colorIndex)) {
$borderBottomColor = self::_readColor($bottom->colorIndex,$this->_palette,$this->_version); $borderBottomColor = self::_readColor($bottom->colorIndex, $this->_palette, $this->_version);
$bottom->getColor()->setRGB($borderBottomColor['rgb']); $bottom->getColor()->setRGB($borderBottomColor['rgb']);
} }
if (isset($left->colorIndex)) { if (isset($left->colorIndex)) {
$borderLeftColor = self::_readColor($left->colorIndex,$this->_palette,$this->_version); $borderLeftColor = self::_readColor($left->colorIndex, $this->_palette, $this->_version);
$left->getColor()->setRGB($borderLeftColor['rgb']); $left->getColor()->setRGB($borderLeftColor['rgb']);
} }
if (isset($diagonal->colorIndex)) { if (isset($diagonal->colorIndex)) {
$borderDiagonalColor = self::_readColor($diagonal->colorIndex,$this->_palette,$this->_version); $borderDiagonalColor = self::_readColor($diagonal->colorIndex, $this->_palette, $this->_version);
$diagonal->getColor()->setRGB($borderDiagonalColor['rgb']); $diagonal->getColor()->setRGB($borderDiagonalColor['rgb']);
} }
} }
@ -863,7 +863,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// treat OBJ records // treat OBJ records
foreach ($this->_objs as $n => $obj) { foreach ($this->_objs as $n => $obj) {
// echo '<hr /><b>Object</b> reference is ',$n,'<br />'; // echo '<hr /><b>Object</b> reference is ', $n,'<br />';
// var_dump($obj); // var_dump($obj);
// echo '<br />'; // echo '<br />';
@ -896,7 +896,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
case 0x19: case 0x19:
// Note // Note
// echo 'Cell Annotation Object<br />'; // echo 'Cell Annotation Object<br />';
// echo 'Object ID is ',$obj['idObjID'],'<br />'; // echo 'Object ID is ', $obj['idObjID'],'<br />';
// //
if (isset($this->_cellNotes[$obj['idObjID']])) { if (isset($this->_cellNotes[$obj['idObjID']])) {
$cellNote = $this->_cellNotes[$obj['idObjID']]; $cellNote = $this->_cellNotes[$obj['idObjID']];
@ -969,7 +969,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
} }
if (!empty($this->_cellNotes)) { if (!empty($this->_cellNotes)) {
foreach($this->_cellNotes as $note => $noteDetails) { foreach ($this->_cellNotes as $note => $noteDetails) {
if (!isset($noteDetails['objTextData'])) { if (!isset($noteDetails['objTextData'])) {
if (isset($this->_textObjects[$note])) { if (isset($this->_textObjects[$note])) {
$textObject = $this->_textObjects[$note]; $textObject = $this->_textObjects[$note];
@ -978,10 +978,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$noteDetails['objTextData']['text'] = ''; $noteDetails['objTextData']['text'] = '';
} }
} }
// echo '<b>Cell annotation ',$note,'</b><br />'; // echo '<b>Cell annotation ', $note,'</b><br />';
// var_dump($noteDetails); // var_dump($noteDetails);
// echo '<br />'; // echo '<br />';
$cellAddress = str_replace('$','',$noteDetails['cellRef']); $cellAddress = str_replace('$','', $noteDetails['cellRef']);
$this->_phpSheet->getComment( $cellAddress ) $this->_phpSheet->getComment( $cellAddress )
->setAuthor( $noteDetails['author'] ) ->setAuthor( $noteDetails['author'] )
->setText($this->_parseRichText($noteDetails['objTextData']['text']) ); ->setText($this->_parseRichText($noteDetails['objTextData']['text']) );
@ -1353,21 +1353,21 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// offset: 8; size: 16 // offset: 8; size: 16
// offset: 24; size: 4; section count // offset: 24; size: 4; section count
$secCount = self::_GetInt4d($this->_documentSummaryInformation, 24); $secCount = self::_GetInt4d($this->_documentSummaryInformation, 24);
// echo '$secCount = ',$secCount,'<br />'; // echo '$secCount = ', $secCount,'<br />';
// offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae // offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae
// offset: 44; size: 4; first section offset // offset: 44; size: 4; first section offset
$secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44); $secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44);
// echo '$secOffset = ',$secOffset,'<br />'; // echo '$secOffset = ', $secOffset,'<br />';
// section header // section header
// offset: $secOffset; size: 4; section length // offset: $secOffset; size: 4; section length
$secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset); $secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset);
// echo '$secLength = ',$secLength,'<br />'; // echo '$secLength = ', $secLength,'<br />';
// offset: $secOffset+4; size: 4; property count // offset: $secOffset+4; size: 4; property count
$countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4); $countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4);
// echo '$countProperties = ',$countProperties,'<br />'; // echo '$countProperties = ', $countProperties,'<br />';
// initialize code page (used to resolve string values) // initialize code page (used to resolve string values)
$codePage = 'CP1252'; $codePage = 'CP1252';
@ -1375,17 +1375,17 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// offset: ($secOffset+8); size: var // offset: ($secOffset+8); size: var
// loop through property decarations and properties // loop through property decarations and properties
for ($i = 0; $i < $countProperties; ++$i) { for ($i = 0; $i < $countProperties; ++$i) {
// echo 'Property ',$i,'<br />'; // echo 'Property ', $i,'<br />';
// offset: ($secOffset+8) + (8 * $i); size: 4; property ID // offset: ($secOffset+8) + (8 * $i); size: 4; property ID
$id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i)); $id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i));
// echo 'ID is ',$id,'<br />'; // echo 'ID is ', $id,'<br />';
// Use value of property id as appropriate // Use value of property id as appropriate
// offset: 60 + 8 * $i; size: 4; offset from beginning of section (48) // offset: 60 + 8 * $i; size: 4; offset from beginning of section (48)
$offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i)); $offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i));
$type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset); $type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset);
// echo 'Type is ',$type,', '; // echo 'Type is ', $type,', ';
// initialize property value // initialize property value
$value = null; $value = null;
@ -1531,9 +1531,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$noteObjID = self::_GetInt2d($recordData, 6); $noteObjID = self::_GetInt2d($recordData, 6);
$noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8)); $noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8));
$noteAuthor = $noteAuthor['value']; $noteAuthor = $noteAuthor['value'];
// echo 'Note Address=',$cellAddress,'<br />'; // echo 'Note Address=', $cellAddress,'<br />';
// echo 'Note Object ID=',$noteObjID,'<br />'; // echo 'Note Object ID=', $noteObjID,'<br />';
// echo 'Note Author=',$noteAuthor,'<hr />'; // echo 'Note Author=', $noteAuthor,'<hr />';
// //
$this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress, $this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress,
'objectID' => $noteObjID, 'objectID' => $noteObjID,
@ -1549,13 +1549,13 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$extension = true; $extension = true;
$cellAddress = array_pop(array_keys($this->_phpSheet->getComments())); $cellAddress = array_pop(array_keys($this->_phpSheet->getComments()));
} }
// echo 'Note Address=',$cellAddress,'<br />'; // echo 'Note Address=', $cellAddress,'<br />';
$cellAddress = str_replace('$','',$cellAddress); $cellAddress = str_replace('$','', $cellAddress);
$noteLength = self::_GetInt2d($recordData, 4); $noteLength = self::_GetInt2d($recordData, 4);
$noteText = trim(substr($recordData, 6)); $noteText = trim(substr($recordData, 6));
// echo 'Note Length=',$noteLength,'<br />'; // echo 'Note Length=', $noteLength,'<br />';
// echo 'Note Text=',$noteText,'<br />'; // echo 'Note Text=', $noteText,'<br />';
if ($extension) { if ($extension) {
// Concatenate this extension with the currently set comment for the cell // Concatenate this extension with the currently set comment for the cell
@ -1601,8 +1601,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$text = $this->_getSplicedRecordData(); $text = $this->_getSplicedRecordData();
$this->_textObjects[$this->textObjRef] = array( $this->_textObjects[$this->textObjRef] = array(
'text' => substr($text["recordData"],$text["spliceOffsets"][0]+1,$cchText), 'text' => substr($text["recordData"], $text["spliceOffsets"][0]+1, $cchText),
'format' => substr($text["recordData"],$text["spliceOffsets"][1],$cbRuns), 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns),
'alignment' => $grbitOpts, 'alignment' => $grbitOpts,
'rotation' => $rot 'rotation' => $rot
); );
@ -4294,7 +4294,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
/** /**
* Read PLV Record(Created by Excel2007 or upper) * Read PLV Record(Created by Excel2007 or upper)
*/ */
private function _readPageLayoutView(){ private function _readPageLayoutView() {
$length = self::_GetInt2d($this->_data, $this->_pos + 2); $length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length);
@ -4564,7 +4564,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false);
$nullOffset = strpos($url, 0x00); $nullOffset = strpos($url, 0x00);
if ($nullOffset) if ($nullOffset)
$url = substr($url,0,$nullOffset); $url = substr($url,0, $nullOffset);
$url .= $hasText ? '#' : ''; $url .= $hasText ? '#' : '';
$offset += $us; $offset += $us;
break; break;
@ -4858,7 +4858,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
case 0x14: case 0x14:
// offset: 16; size: 2; color index for sheet tab // offset: 16; size: 2; color index for sheet tab
$colorIndex = self::_GetInt2d($recordData, 16); $colorIndex = self::_GetInt2d($recordData, 16);
$color = self::_readColor($colorIndex,$this->_palette,$this->_version); $color = self::_readColor($colorIndex, $this->_palette, $this->_version);
$this->_phpSheet->getTabColor()->setRGB($color['rgb']); $this->_phpSheet->getTabColor()->setRGB($color['rgb']);
break; break;
@ -6807,7 +6807,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
* @param array $palette Color palette * @param array $palette Color palette
* @return array RGB color value, example: array('rgb' => 'FF0000') * @return array RGB color value, example: array('rgb' => 'FF0000')
*/ */
private static function _readColor($color,$palette,$version) private static function _readColor($color, $palette, $version)
{ {
if ($color <= 0x07 || $color >= 0x40) { if ($color <= 0x07 || $color >= 0x40) {
// special built-in color // special built-in color

View File

@ -257,13 +257,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$officeDocXML = $officeXML->{'document-meta'}; $officeDocXML = $officeXML->{'document-meta'};
$officeDocMetaXML = $officeDocXML->meta; $officeDocMetaXML = $officeDocXML->meta;
foreach($officeDocMetaXML as $officePropertyData) { foreach ($officeDocMetaXML as $officePropertyData) {
$officePropertyDC = array(); $officePropertyDC = array();
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
} }
foreach($officePropertyDC as $propertyName => $propertyValue) { foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title' :
@ -290,7 +290,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if (isset($namespacesMeta['meta'])) { if (isset($namespacesMeta['meta'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
} }
foreach($officePropertyMeta as $propertyName => $propertyValue) { foreach ($officePropertyMeta as $propertyName => $propertyValue) {
$attributes = $propertyValue->attributes($namespacesMeta['meta']); $attributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
@ -307,7 +307,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'user-defined' : case 'user-defined' :
list(,$attrName) = explode(':',$attributes['name']); list(, $attrName) = explode(':', $attributes['name']);
switch ($attrName) { switch ($attrName) {
case 'publisher' : case 'publisher' :
$docProps->setCompany(trim($propertyValue)); $docProps->setCompany(trim($propertyValue));
@ -324,7 +324,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
} elseif (isset($gnmXML->Summary)) { } elseif (isset($gnmXML->Summary)) {
foreach($gnmXML->Summary->Item as $summaryItem) { foreach ($gnmXML->Summary->Item as $summaryItem) {
$propertyName = $summaryItem->name; $propertyName = $summaryItem->name;
$propertyValue = $summaryItem->{'val-string'}; $propertyValue = $summaryItem->{'val-string'};
switch ($propertyName) { switch ($propertyName) {
@ -355,9 +355,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
$worksheetID = 0; $worksheetID = 0;
foreach($gnmXML->Sheets->Sheet as $sheet) { foreach ($gnmXML->Sheets->Sheet as $sheet) {
$worksheetName = (string) $sheet->Name; $worksheetName = (string) $sheet->Name;
// echo '<b>Worksheet: ',$worksheetName,'</b><br />'; // echo '<b>Worksheet: ', $worksheetName,'</b><br />';
if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) { if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) {
continue; continue;
} }
@ -374,15 +374,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
if (isset($sheet->PrintInformation->Margins)) { if (isset($sheet->PrintInformation->Margins)) {
foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) { foreach ($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) {
$marginAttributes = $margin->attributes(); $marginAttributes = $margin->attributes();
$marginSize = 72 / 100; // Default $marginSize = 72 / 100; // Default
switch($marginAttributes['PrefUnit']) { switch ($marginAttributes['PrefUnit']) {
case 'mm' : case 'mm' :
$marginSize = intval($marginAttributes['Points']) / 100; $marginSize = intval($marginAttributes['Points']) / 100;
break; break;
} }
switch($key) { switch ($key) {
case 'top' : case 'top' :
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize);
break; break;
@ -406,7 +406,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
foreach($sheet->Cells->Cell as $cell) { foreach ($sheet->Cells->Cell as $cell) {
$cellAttributes = $cell->attributes(); $cellAttributes = $cell->attributes();
$row = (int) $cellAttributes->Row + 1; $row = (int) $cellAttributes->Row + 1;
$column = (int) $cellAttributes->Col; $column = (int) $cellAttributes->Col;
@ -425,9 +425,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$ValueType = $cellAttributes->ValueType; $ValueType = $cellAttributes->ValueType;
$ExprID = (string) $cellAttributes->ExprID; $ExprID = (string) $cellAttributes->ExprID;
// echo 'Cell ',$column,$row,'<br />'; // echo 'Cell ', $column, $row,'<br />';
// echo 'Type is ',$ValueType,'<br />'; // echo 'Type is ', $ValueType,'<br />';
// echo 'Value is ',$cell,'<br />'; // echo 'Value is ', $cell,'<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
if ($ExprID > '') { if ($ExprID > '') {
if (((string) $cell) > '') { if (((string) $cell) > '') {
@ -436,7 +436,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
'row' => $cellAttributes->Row, 'row' => $cellAttributes->Row,
'formula' => (string) $cell 'formula' => (string) $cell
); );
// echo 'NEW EXPRESSION ',$ExprID,'<br />'; // echo 'NEW EXPRESSION ', $ExprID,'<br />';
} else { } else {
$expression = $this->_expressions[$ExprID]; $expression = $this->_expressions[$ExprID];
@ -446,12 +446,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$cellAttributes->Row - $expression['row'], $cellAttributes->Row - $expression['row'],
$worksheetName $worksheetName
); );
// echo 'SHARED EXPRESSION ',$ExprID,'<br />'; // echo 'SHARED EXPRESSION ', $ExprID,'<br />';
// echo 'New Value is ',$cell,'<br />'; // echo 'New Value is ', $cell,'<br />';
} }
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
} else { } else {
switch($ValueType) { switch ($ValueType) {
case '10' : // NULL case '10' : // NULL
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = PHPExcel_Cell_DataType::TYPE_NULL;
break; break;
@ -474,11 +474,11 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
case '80' : // Array case '80' : // Array
} }
} }
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell,$type); $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type);
} }
if ((!$this->_readDataOnly) && (isset($sheet->Objects))) { if ((!$this->_readDataOnly) && (isset($sheet->Objects))) {
foreach($sheet->Objects->children('gnm',TRUE) as $key => $comment) { foreach ($sheet->Objects->children('gnm',TRUE) as $key => $comment) {
$commentAttributes = $comment->attributes(); $commentAttributes = $comment->attributes();
// Only comment objects are handled at the moment // Only comment objects are handled at the moment
if ($commentAttributes->Text) { if ($commentAttributes->Text) {
@ -488,9 +488,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
} }
// echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />'; // echo '$maxCol=', $maxCol,'; $maxRow=', $maxRow,'<br />';
// //
foreach($sheet->Styles->StyleRegion as $styleRegion) { foreach ($sheet->Styles->StyleRegion as $styleRegion) {
$styleAttributes = $styleRegion->attributes(); $styleAttributes = $styleRegion->attributes();
if (($styleAttributes['startRow'] <= $maxRow) && if (($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)) { ($styleAttributes['startCol'] <= $maxCol)) {
@ -516,7 +516,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; $styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
// If _readDataOnly is false, we set all formatting information // If _readDataOnly is false, we set all formatting information
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
switch($styleAttributes['HAlign']) { switch ($styleAttributes['HAlign']) {
case '1' : case '1' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
break; break;
@ -538,7 +538,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
break; break;
} }
switch($styleAttributes['VAlign']) { switch ($styleAttributes['VAlign']) {
case '1' : case '1' :
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
break; break;
@ -565,7 +565,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB; $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); $RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]);
$styleArray['fill']['endcolor']['rgb'] = $RGB2; $styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch($shade) { switch ($shade) {
case '1' : case '1' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
break; break;
@ -637,7 +637,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False; $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False;
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False; $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False;
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False;
switch($fontAttributes['Underline']) { switch ($fontAttributes['Underline']) {
case '1' : case '1' :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
break; break;
@ -654,7 +654,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
break; break;
} }
switch($fontAttributes['Script']) { switch ($fontAttributes['Script']) {
case '1' : case '1' :
$styleArray['font']['superScript'] = True; $styleArray['font']['superScript'] = True;
break; break;
@ -704,7 +704,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$columnAttributes = $sheet->Cols->attributes(); $columnAttributes = $sheet->Cols->attributes();
$defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
$c = 0; $c = 0;
foreach($sheet->Cols->ColInfo as $columnOverride) { foreach ($sheet->Cols->ColInfo as $columnOverride) {
$columnAttributes = $columnOverride->attributes(); $columnAttributes = $columnOverride->attributes();
$column = $columnAttributes['No']; $column = $columnAttributes['No'];
$columnWidth = $columnAttributes['Unit'] / 5.4; $columnWidth = $columnAttributes['Unit'] / 5.4;
@ -734,7 +734,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$defaultHeight = $rowAttributes['DefaultSizePts']; $defaultHeight = $rowAttributes['DefaultSizePts'];
$r = 0; $r = 0;
foreach($sheet->Rows->RowInfo as $rowOverride) { foreach ($sheet->Rows->RowInfo as $rowOverride) {
$rowAttributes = $rowOverride->attributes(); $rowAttributes = $rowOverride->attributes();
$row = $rowAttributes['No']; $row = $rowAttributes['No'];
$rowHeight = $rowAttributes['Unit']; $rowHeight = $rowAttributes['Unit'];
@ -760,7 +760,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Handle Merged Cells in this worksheet // Handle Merged Cells in this worksheet
if (isset($sheet->MergedRegions)) { if (isset($sheet->MergedRegions)) {
foreach($sheet->MergedRegions->Merge as $mergeCells) { foreach ($sheet->MergedRegions->Merge as $mergeCells) {
if (strpos($mergeCells,':') !== FALSE) { if (strpos($mergeCells,':') !== FALSE) {
$objPHPExcel->getActiveSheet()->mergeCells($mergeCells); $objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
} }
@ -772,14 +772,14 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Loop through definedNames (global named ranges) // Loop through definedNames (global named ranges)
if (isset($gnmXML->Names)) { if (isset($gnmXML->Names)) {
foreach($gnmXML->Names->Name as $namedRange) { foreach ($gnmXML->Names->Name as $namedRange) {
$name = (string) $namedRange->name; $name = (string) $namedRange->name;
$range = (string) $namedRange->value; $range = (string) $namedRange->value;
if (stripos($range, '#REF!') !== false) { if (stripos($range, '#REF!') !== false) {
continue; continue;
} }
$range = explode('!',$range); $range = explode('!', $range);
$range[0] = trim($range[0],"'");; $range[0] = trim($range[0],"'");;
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
@ -861,12 +861,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
private static function _parseGnumericColour($gnmColour) { private static function _parseGnumericColour($gnmColour) {
list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour); list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2); $gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
$gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2); $gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2);
$gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2); $gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2);
$RGB = $gnmR.$gnmG.$gnmB; $RGB = $gnmR.$gnmG.$gnmB;
// echo 'Excel Colour: ',$RGB,'<br />'; // echo 'Excel Colour: ', $RGB,'<br />';
return $RGB; return $RGB;
} }

View File

@ -89,12 +89,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$stat = $zip->statName('mimetype'); $stat = $zip->statName('mimetype');
if ($stat && ($stat['size'] <= 255)) { if ($stat && ($stat['size'] <= 255)) {
$mimeType = $zip->getFromName($stat['name']); $mimeType = $zip->getFromName($stat['name']);
} elseif($stat = $zip->statName('META-INF/manifest.xml')) { } elseif ($stat = $zip->statName('META-INF/manifest.xml')) {
$xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesContent = $xml->getNamespaces(true); $namespacesContent = $xml->getNamespaces(true);
if (isset($namespacesContent['manifest'])) { if (isset($namespacesContent['manifest'])) {
$manifest = $xml->children($namespacesContent['manifest']); $manifest = $xml->children($namespacesContent['manifest']);
foreach($manifest as $manifestDataSet) { foreach ($manifest as $manifestDataSet) {
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']); $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') { if ($manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'}; $mimeType = (string) $manifestAttributes->{'media-type'};
@ -222,7 +222,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$rowspan = $xml->getAttribute('table:number-rows-repeated'); $rowspan = $xml->getAttribute('table:number-rows-repeated');
$rowspan = empty($rowspan) ? 1 : $rowspan; $rowspan = empty($rowspan) ? 1 : $rowspan;
$tmpInfo['totalRows'] += $rowspan; $tmpInfo['totalRows'] += $rowspan;
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$currCells = 0; $currCells = 0;
// Step into the row // Step into the row
$xml->read(); $xml->read();
@ -243,14 +243,14 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
} while ($xml->name != 'table:table'); } while ($xml->name != 'table:table');
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo; $worksheetInfo[] = $tmpInfo;
} }
} }
// foreach($workbookData->table as $worksheetDataSet) { // foreach ($workbookData->table as $worksheetDataSet) {
// $worksheetData = $worksheetDataSet->children($namespacesContent['table']); // $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
// $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); // $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
// //
@ -309,7 +309,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) { foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) { if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style; $styleAttributeValue = $style;
return true; return true;
@ -353,12 +353,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$docProps = $objPHPExcel->getProperties(); $docProps = $objPHPExcel->getProperties();
$officeProperty = $xml->children($namespacesMeta['office']); $officeProperty = $xml->children($namespacesMeta['office']);
foreach($officeProperty as $officePropertyData) { foreach ($officeProperty as $officePropertyData) {
$officePropertyDC = array(); $officePropertyDC = array();
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
} }
foreach($officePropertyDC as $propertyName => $propertyValue) { foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title' :
@ -385,7 +385,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
} }
foreach($officePropertyMeta as $propertyName => $propertyValue) { foreach ($officePropertyMeta as $propertyName => $propertyValue) {
$propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
@ -404,7 +404,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
foreach ($propertyValueAttributes as $key => $value) { foreach ($propertyValueAttributes as $key => $value) {
if ($key == 'name') { if ($key == 'name') {
$propertyValueName = (string) $value; $propertyValueName = (string) $value;
} elseif($key == 'value-type') { } elseif ($key == 'value-type') {
switch ($value) { switch ($value) {
case 'date' : case 'date' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date');
@ -423,7 +423,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
} }
} }
$docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType); $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType);
break; break;
} }
} }
@ -438,10 +438,10 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo '</pre><hr />'; // echo '</pre><hr />';
$workbook = $xml->children($namespacesContent['office']); $workbook = $xml->children($namespacesContent['office']);
foreach($workbook->body->spreadsheet as $workbookData) { foreach ($workbook->body->spreadsheet as $workbookData) {
$workbookData = $workbookData->children($namespacesContent['table']); $workbookData = $workbookData->children($namespacesContent['table']);
$worksheetID = 0; $worksheetID = 0;
foreach($workbookData->table as $worksheetDataSet) { foreach ($workbookData->table as $worksheetDataSet) {
$worksheetData = $worksheetDataSet->children($namespacesContent['table']); $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
// print_r($worksheetData); // print_r($worksheetData);
// echo '<br />'; // echo '<br />';
@ -466,7 +466,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
$rowID = 1; $rowID = 1;
foreach($worksheetData as $key => $rowData) { foreach ($worksheetData as $key => $rowData) {
// echo '<b>'.$key.'</b><br />'; // echo '<b>'.$key.'</b><br />';
switch ($key) { switch ($key) {
case 'table-header-rows': case 'table-header-rows':
@ -479,7 +479,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
$rowDataTableAttributes['number-rows-repeated'] : 1; $rowDataTableAttributes['number-rows-repeated'] : 1;
$columnID = 'A'; $columnID = 'A';
foreach($rowData as $key => $cellData) { foreach ($rowData as $key => $cellData) {
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== NULL) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue; continue;
@ -514,16 +514,16 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Cell has comment<br />'; // echo 'Cell has comment<br />';
$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']); $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
$textArray = array(); $textArray = array();
foreach($annotationText as $t) { foreach ($annotationText as $t) {
if (isset($t->span)) { if (isset($t->span)) {
foreach($t->span as $text) { foreach ($t->span as $text) {
$textArray[] = (string)$text; $textArray[] = (string)$text;
} }
} else { } else {
$textArray[] = (string) $t; $textArray[] = (string) $t;
} }
} }
$text = implode("\n",$textArray); $text = implode("\n", $textArray);
// echo $text,'<br />'; // echo $text,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
// ->setAuthor( $author ) // ->setAuthor( $author )
@ -596,8 +596,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj); $dateObj->setTimeZone($timezoneObj);
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
if ($dataValue != floor($dataValue)) { if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
} else { } else {
@ -623,21 +623,21 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
// echo 'Formula: ', $cellDataFormula, PHP_EOL; // echo 'Formula: ', $cellDataFormula, PHP_EOL;
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$tKey = false; $tKey = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) { if ($tKey = !$tKey) {
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3',$value); // Cell range reference in another sheet $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3', $value); // Cell range reference in another sheet
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2',$value); // Cell reference in another sheet $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2', $value); // Cell reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2',$value); // Cell range reference $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2', $value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui','$1',$value); // Simple cell reference $value = preg_replace('/\[\.([^\.]+)\]/Ui','$1', $value); // Simple cell reference
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); $value = PHPExcel_Calculation::_translateSeparator(';',',', $value, $inBraces);
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"', $temp);
// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; // echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
} }
@ -651,7 +651,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) { if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) { for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
$rID = $rowID + $rowAdjust; $rID = $rowID + $rowAdjust;
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue), $type);
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
// echo 'Forumla result is '.$dataValue.'<br />'; // echo 'Forumla result is '.$dataValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);

View File

@ -167,8 +167,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$dataType = array_shift($rowData); $dataType = array_shift($rowData);
if ($dataType == 'C') { if ($dataType == 'C') {
// Read cell value data // Read cell value data
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : case 'X' :
$columnIndex = substr($rowDatum,1) - 1; $columnIndex = substr($rowDatum,1) - 1;
@ -256,9 +256,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// Read shared styles // Read shared styles
if ($dataType == 'P') { if ($dataType == 'P') {
$formatArray = array(); $formatArray = array();
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1)); case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats,substr($rowDatum,1));
break; break;
case 'E' : case 'E' :
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1); case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
@ -290,8 +290,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} elseif ($dataType == 'C') { } elseif ($dataType == 'C') {
$hasCalculatedValue = false; $hasCalculatedValue = false;
$cellData = $cellDataFormula = ''; $cellData = $cellDataFormula = '';
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : $column = substr($rowDatum,1); case 'X' : $column = substr($rowDatum,1);
break; break;
@ -302,19 +302,19 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'E' : $cellDataFormula = '='.substr($rowDatum,1); case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
// Convert R1C1 style references to A1 style references (but only when not quoted) // Convert R1C1 style references to A1 style references (but only when not quoted)
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only count/replace in alternate array entries // Only count/replace in alternate array entries
if ($key = !$key) { if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through // through the formula from left to right. Reversing means that we work right to left.through
// the formula // the formula
$cellReferences = array_reverse($cellReferences); $cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference // then modify the formula to use that new reference
foreach($cellReferences as $cellReference) { foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0]; $rowReference = $cellReference[2][0];
// Empty R reference is the current row // Empty R reference is the current row
if ($rowReference == '') $rowReference = $row; if ($rowReference == '') $rowReference = $row;
@ -327,13 +327,13 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]'); if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0]));
} }
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"', $temp);
$hasCalculatedValue = true; $hasCalculatedValue = true;
break; break;
} }
@ -351,8 +351,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} elseif ($dataType == 'F') { } elseif ($dataType == 'F') {
$formatStyle = $columnWidth = $styleSettings = ''; $formatStyle = $columnWidth = $styleSettings = '';
$styleData = array(); $styleData = array();
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : $column = substr($rowDatum,1); case 'X' : $column = substr($rowDatum,1);
break; break;
@ -361,7 +361,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'P' : $formatStyle = $rowDatum; case 'P' : $formatStyle = $rowDatum;
break; break;
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1)); case 'W' : list($startCol, $endCol, $columnWidth) = explode(' ',substr($rowDatum,1));
break; break;
case 'S' : $styleSettings = substr($rowDatum,1); case 'S' : $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) { for ($i=0;$i<strlen($styleSettings);++$i) {
@ -407,8 +407,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
} }
} else { } else {
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : $column = substr($rowDatum,1); case 'X' : $column = substr($rowDatum,1);
break; break;

View File

@ -416,7 +416,7 @@ class PHPExcel_ReferenceHelper
} }
// Loop through cells, bottom-up, and change cell coordinates // Loop through cells, bottom-up, and change cell coordinates
if($remove) { if ($remove) {
// It's faster to reverse and pop than to use unshift, especially with large cell collections // It's faster to reverse and pop than to use unshift, especially with large cell collections
$aCellCollection = array_reverse($aCellCollection); $aCellCollection = array_reverse($aCellCollection);
} }
@ -548,7 +548,7 @@ class PHPExcel_ReferenceHelper
if (count($autoFilterColumns) > 0) { if (count($autoFilterColumns) > 0) {
sscanf($pBefore,'%[A-Z]%d', $column, $row); sscanf($pBefore,'%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) { if ($columnIndex <= $rangeEnd[0]) {
if ($pNumCols < 0) { if ($pNumCols < 0) {
// If we're actually deleting any columns that fall within the autofilter range, // If we're actually deleting any columns that fall within the autofilter range,
@ -556,7 +556,7 @@ class PHPExcel_ReferenceHelper
$deleteColumn = $columnIndex + $pNumCols - 1; $deleteColumn = $columnIndex + $pNumCols - 1;
$deleteCount = abs($pNumCols); $deleteCount = abs($pNumCols);
for ($i = 1; $i <= $deleteCount; ++$i) { for ($i = 1; $i <= $deleteCount; ++$i) {
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) { if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn), $autoFilterColumns)) {
$autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn)); $autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn));
} }
++$deleteColumn; ++$deleteColumn;
@ -586,7 +586,7 @@ class PHPExcel_ReferenceHelper
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1); $toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]); $endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
do { do {
$autoFilter->shiftColumn($startColID,$toColID); $autoFilter->shiftColumn($startColID, $toColID);
++$startColID; ++$startColID;
++$toColID; ++$toColID;
} while ($startColID != $endColID); } while ($startColID != $endColID);
@ -644,9 +644,9 @@ class PHPExcel_ReferenceHelper
*/ */
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') { public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
// Update cell references in the formula // Update cell references in the formula
$formulaBlocks = explode('"',$pFormula); $formulaBlocks = explode('"', $pFormula);
$i = false; $i = false;
foreach($formulaBlocks as &$formulaBlock) { foreach ($formulaBlocks as &$formulaBlock) {
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode) // Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
if ($i = !$i) { if ($i = !$i) {
$adjustCount = 0; $adjustCount = 0;
@ -654,11 +654,11 @@ class PHPExcel_ReferenceHelper
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5) // Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference('$A'.$match[3],$pBefore,$pNumCols,$pNumRows),2); $modified3 = substr($this->updateCellReference('$A'.$match[3], $pBefore, $pNumCols, $pNumRows),2);
$modified4 = substr($this->updateCellReference('$A'.$match[4],$pBefore,$pNumCols,$pNumRows),2); $modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows),2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
@ -679,11 +679,11 @@ class PHPExcel_ReferenceHelper
// Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E) // Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference($match[3].'$1',$pBefore,$pNumCols,$pNumRows),0,-2); $modified3 = substr($this->updateCellReference($match[3].'$1', $pBefore, $pNumCols, $pNumRows),0,-2);
$modified4 = substr($this->updateCellReference($match[4].'$1',$pBefore,$pNumCols,$pNumRows),0,-2); $modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows),0,-2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
@ -704,17 +704,17 @@ class PHPExcel_ReferenceHelper
// Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5) // Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows); $modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
$modified4 = $this->updateCellReference($match[4],$pBefore,$pNumCols,$pNumRows); $modified4 = $this->updateCellReference($match[4], $pBefore, $pNumCols, $pNumRows);
if ($match[3].$match[4] !== $modified3.$modified4) { if ($match[3].$match[4] !== $modified3.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row,'$') + 10000000;
@ -731,16 +731,16 @@ class PHPExcel_ReferenceHelper
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3]; $fromString .= $match[3];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows); $modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
if ($match[3] !== $modified3) { if ($match[3] !== $modified3) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3; $toString .= $modified3;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row,'$') + 10000000;
@ -761,14 +761,14 @@ class PHPExcel_ReferenceHelper
ksort($cellTokens); ksort($cellTokens);
ksort($newCellTokens); ksort($newCellTokens);
} // Update cell references in the formula } // Update cell references in the formula
$formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock)); $formulaBlock = str_replace('\\','',preg_replace($cellTokens, $newCellTokens, $formulaBlock));
} }
} }
} }
unset($formulaBlock); unset($formulaBlock);
// Then rebuild the formula string // Then rebuild the formula string
return implode('"',$formulaBlocks); return implode('"', $formulaBlocks);
} }
/** /**
@ -846,7 +846,7 @@ class PHPExcel_ReferenceHelper
if (ctype_alpha($range[$i][$j])) { if (ctype_alpha($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows)); $r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[0]; $range[$i][$j] = $r[0];
} elseif(ctype_digit($range[$i][$j])) { } elseif (ctype_digit($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows)); $r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[1]; $range[$i][$j] = $r[1];
} else { } else {

View File

@ -162,7 +162,7 @@ class PHPExcel_Shared_Date
$seconds = round($time) - ($hours * 3600) - ($minutes * 60); $seconds = round($time) - ($hours * 3600) - ($minutes * 60);
$dateObj = date_create('1-Jan-1970+'.$days.' days'); $dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours,$minutes,$seconds); $dateObj->setTime($hours, $minutes, $seconds);
return $dateObj; return $dateObj;
} }
@ -188,8 +188,8 @@ class PHPExcel_Shared_Date
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s') $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
); );
} elseif (is_numeric($dateValue)) { } elseif (is_numeric($dateValue)) {
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue), $retValue = self::FormattedPHPToExcel( date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue),
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue) date('H', $dateValue), date('i', $dateValue), date('s', $dateValue)
); );
} }
date_default_timezone_set($saveTimeZone); date_default_timezone_set($saveTimeZone);
@ -327,7 +327,7 @@ class PHPExcel_Shared_Date
// we don't want to test for any of our characters within the quoted blocks // we don't want to test for any of our characters within the quoted blocks
if (strpos($pFormatCode, '"') !== false) { if (strpos($pFormatCode, '"') !== false) {
$segMatcher = false; $segMatcher = false;
foreach(explode('"', $pFormatCode) as $subVal) { foreach (explode('"', $pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks) // Only test in alternate array entries (the non-quoted blocks)
if (($segMatcher = !$segMatcher) && if (($segMatcher = !$segMatcher) &&
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) { (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) {
@ -376,7 +376,7 @@ class PHPExcel_Shared_Date
public static function monthStringToNumber($month) public static function monthStringToNumber($month)
{ {
$monthIndex = 1; $monthIndex = 1;
foreach(self::$monthNames as $shortMonthName => $longMonthName) { foreach (self::$monthNames as $shortMonthName => $longMonthName) {
if (($month === $longMonthName) || ($month === $shortMonthName)) { if (($month === $longMonthName) || ($month === $shortMonthName)) {
return $monthIndex; return $monthIndex;
} }

View File

@ -181,10 +181,10 @@ class PHPExcel_Shared_Drawing
// Load the image into a string // Load the image into a string
$file = fopen($p_sFile,"rb"); $file = fopen($p_sFile,"rb");
$read = fread($file,10); $read = fread($file,10);
while(!feof($file)&&($read<>"")) while (!feof($file)&&($read<>""))
$read .= fread($file,1024); $read .= fread($file,1024);
$temp = unpack("H*",$read); $temp = unpack("H*", $read);
$hex = $temp[1]; $hex = $temp[1];
$header = substr($hex,0,108); $header = substr($hex,0,108);
@ -210,7 +210,7 @@ class PHPExcel_Shared_Drawing
$y = 1; $y = 1;
// Create newimage // Create newimage
$image = imagecreatetruecolor($width,$height); $image = imagecreatetruecolor($width, $height);
// Grab the body from the image // Grab the body from the image
$body = substr($hex,108); $body = substr($hex,108);
@ -255,8 +255,8 @@ class PHPExcel_Shared_Drawing
$b = hexdec($body[$i_pos].$body[$i_pos+1]); $b = hexdec($body[$i_pos].$body[$i_pos+1]);
// Calculate and draw the pixel // Calculate and draw the pixel
$color = imagecolorallocate($image,$r,$g,$b); $color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image,$x,$height-$y,$color); imagesetpixel($image, $x, $height-$y, $color);
// Raise the horizontal position // Raise the horizontal position
$x++; $x++;

View File

@ -111,7 +111,7 @@ class PHPExcel_Shared_File
// Found something? // Found something?
if ($returnValue == '' || ($returnValue === NULL)) { if ($returnValue == '' || ($returnValue === NULL)) {
$pathArray = explode('/' , $pFilename); $pathArray = explode('/' , $pFilename);
while(in_array('..', $pathArray) && $pathArray[0] != '..') { while (in_array('..', $pathArray) && $pathArray[0] != '..') {
for ($i = 0; $i < count($pathArray); ++$i) { for ($i = 0; $i < count($pathArray); ++$i) {
if ($pathArray[$i] == '..' && $i > 0) { if ($pathArray[$i] == '..' && $i > 0) {
unset($pathArray[$i]); unset($pathArray[$i]);

View File

@ -763,7 +763,7 @@ class EigenvalueDecomposition {
for ($j = $nn-1; $j >= $low; --$j) { for ($j = $nn-1; $j >= $low; --$j) {
for ($i = $low; $i <= $high; ++$i) { for ($i = $low; $i <= $high; ++$i) {
$z = 0.0; $z = 0.0;
for ($k = $low; $k <= min($j,$high); ++$k) { for ($k = $low; $k <= min($j, $high); ++$k) {
$z = $z + $this->V[$i][$k] * $this->H[$k][$j]; $z = $z + $this->V[$i][$k] * $this->H[$k][$j];
} }
$this->V[$i][$j] = $z; $this->V[$i][$j] = $z;

View File

@ -82,7 +82,7 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$LUrowi = $this->LU[$i]; $LUrowi = $this->LU[$i];
// Most of the time is spent in the following dot product. // Most of the time is spent in the following dot product.
$kmax = min($i,$j); $kmax = min($i, $j);
$s = 0.0; $s = 0.0;
for ($k = 0; $k < $kmax; ++$k) { for ($k = 0; $k < $kmax; ++$k) {
$s += $LUrowi[$k] * $LUcolj[$k]; $s += $LUrowi[$k] * $LUcolj[$k];

View File

@ -68,7 +68,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
//Rectangular matrix - m x n initialized from 2D array //Rectangular matrix - m x n initialized from 2D array
case 'array': case 'array':
$this->m = count($args[0]); $this->m = count($args[0]);
@ -173,7 +173,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
//A($i0...; $j0...) //A($i0...; $j0...)
case 'integer,integer': case 'integer,integer':
list($i0, $j0) = $args; list($i0, $j0) = $args;
@ -426,7 +426,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -462,7 +462,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -512,7 +512,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -548,7 +548,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -599,7 +599,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -636,7 +636,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -687,7 +687,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -743,7 +743,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -780,7 +780,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -817,7 +817,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -853,7 +853,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
if ($this->n == $B->m) { if ($this->n == $B->m) {
@ -944,7 +944,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -969,7 +969,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
} }
if ($validValues) { if ($validValues) {
$this->A[$i][$j] = pow($this->A[$i][$j],$value); $this->A[$i][$j] = pow($this->A[$i][$j], $value);
} else { } else {
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN(); $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
} }
@ -994,7 +994,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
case 'array': case 'array':

View File

@ -52,7 +52,7 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
* @return Structure to access R and the Householder vectors and compute Q. * @return Structure to access R and the Householder vectors and compute Q.
*/ */
public function __construct($A) { public function __construct($A) {
if($A instanceof PHPExcel_Shared_JAMA_Matrix) { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
// Initialize. // Initialize.
$this->QR = $A->getArrayCopy(); $this->QR = $A->getArrayCopy();
$this->m = $A->getRowDimension(); $this->m = $A->getRowDimension();
@ -175,7 +175,7 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
/* /*
for($i = 0; $i < count($Q); ++$i) { for($i = 0; $i < count($Q); ++$i) {
for($j = 0; $j < count($Q); ++$j) { for($j = 0; $j < count($Q); ++$j) {
if(! isset($Q[$i][$j]) ) { if (! isset($Q[$i][$j]) ) {
$Q[$i][$j] = 0; $Q[$i][$j] = 0;
} }
} }

View File

@ -74,7 +74,7 @@ class SingularValueDecomposition {
// Reduce A to bidiagonal form, storing the diagonal elements // Reduce A to bidiagonal form, storing the diagonal elements
// in s and the super-diagonal elements in e. // in s and the super-diagonal elements in e.
for ($k = 0; $k < max($nct,$nrt); ++$k) { for ($k = 0; $k < max($nct, $nrt); ++$k) {
if ($k < $nct) { if ($k < $nct) {
// Compute the transformation for the k-th column and // Compute the transformation for the k-th column and
@ -291,7 +291,7 @@ class SingularValueDecomposition {
$f = $e[$p-2]; $f = $e[$p-2];
$e[$p-2] = 0.0; $e[$p-2] = 0.0;
for ($j = $p - 2; $j >= $k; --$j) { for ($j = $p - 2; $j >= $k; --$j) {
$t = hypo($this->s[$j],$f); $t = hypo($this->s[$j], $f);
$cs = $this->s[$j] / $t; $cs = $this->s[$j] / $t;
$sn = $f / $t; $sn = $f / $t;
$this->s[$j] = $t; $this->s[$j] = $t;
@ -353,7 +353,7 @@ class SingularValueDecomposition {
$g = $sk * $ek; $g = $sk * $ek;
// Chase zeros. // Chase zeros.
for ($j = $k; $j < $p-1; ++$j) { for ($j = $k; $j < $p-1; ++$j) {
$t = hypo($f,$g); $t = hypo($f, $g);
$cs = $f/$t; $cs = $f/$t;
$sn = $g/$t; $sn = $g/$t;
if ($j != $k) { if ($j != $k) {
@ -370,7 +370,7 @@ class SingularValueDecomposition {
$this->V[$i][$j] = $t; $this->V[$i][$j] = $t;
} }
} }
$t = hypo($f,$g); $t = hypo($f, $g);
$cs = $f/$t; $cs = $f/$t;
$sn = $g/$t; $sn = $g/$t;
$this->s[$j] = $t; $this->s[$j] = $t;

View File

@ -473,8 +473,8 @@ class PHPExcel_Shared_OLE
// days from 1-1-1601 until the beggining of UNIX era // days from 1-1-1601 until the beggining of UNIX era
$days = 134774; $days = 134774;
// calculate seconds // calculate seconds
$big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date), $big_date = $days*24*3600 + gmmktime(date("H", $date),date("i", $date),date("s", $date),
date("m",$date),date("d",$date),date("Y",$date)); date("m", $date),date("d", $date),date("Y", $date));
// multiply just to make MS happy // multiply just to make MS happy
$big_date *= 10000000; $big_date *= 10000000;

View File

@ -204,7 +204,7 @@ class PHPExcel_Shared_OLE_PPS
{ {
if ( !is_array($to_save) || (empty($to_save)) ) { if ( !is_array($to_save) || (empty($to_save)) ) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} elseif( count($to_save) == 1 ) { } elseif ( count($to_save) == 1 ) {
$cnt = count($raList); $cnt = count($raList);
// If the first entry, it's the root... Don't clone it! // If the first entry, it's the root... Don't clone it!
$raList[$cnt] = ( $depth == 0 ) ? $to_save[0] : clone $to_save[0]; $raList[$cnt] = ( $depth == 0 ) ? $to_save[0] : clone $to_save[0];

View File

@ -271,7 +271,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
//if (isset($raList[$i]->_PPS_FILE)) { //if (isset($raList[$i]->_PPS_FILE)) {
// $iLen = 0; // $iLen = 0;
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top // fseek($raList[$i]->_PPS_FILE, 0); // To The Top
// while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) { // while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
// $iLen += strlen($sBuff); // $iLen += strlen($sBuff);
// fwrite($FILE, $sBuff); // fwrite($FILE, $sBuff);
// } // }
@ -337,7 +337,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
$sRes .= $raList[$i]->_data; $sRes .= $raList[$i]->_data;
//} //}
if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) { if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
$sRes .= str_repeat("\x00",$this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); $sRes .= str_repeat("\x00", $this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE));
} }
// Set for PPS // Set for PPS
$raList[$i]->_StartBlock = $iSmBlk; $raList[$i]->_StartBlock = $iSmBlk;

View File

@ -76,7 +76,7 @@ class PHPExcel_Shared_OLERead {
public function read($sFileName) public function read($sFileName)
{ {
// Check if file exists and is readable // Check if file exists and is readable
if(!is_readable($sFileName)) { if (!is_readable($sFileName)) {
throw new PHPExcel_Reader_Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable."); throw new PHPExcel_Reader_Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");
} }
@ -254,7 +254,7 @@ class PHPExcel_Shared_OLERead {
$size = self::_GetInt4d($d, self::SIZE_POS); $size = self::_GetInt4d($d, self::SIZE_POS);
$name = str_replace("\x00", "", substr($d,0,$nameSize)); $name = str_replace("\x00", "", substr($d,0, $nameSize));
$this->props[] = array ( $this->props[] = array (

View File

@ -1837,13 +1837,13 @@
$v_memory_limit = trim($v_memory_limit); $v_memory_limit = trim($v_memory_limit);
$last = strtolower(substr($v_memory_limit, -1)); $last = strtolower(substr($v_memory_limit, -1));
if($last == 'g') if ($last == 'g')
//$v_memory_limit = $v_memory_limit*1024*1024*1024; //$v_memory_limit = $v_memory_limit*1024*1024*1024;
$v_memory_limit = $v_memory_limit*1073741824; $v_memory_limit = $v_memory_limit*1073741824;
if($last == 'm') if ($last == 'm')
//$v_memory_limit = $v_memory_limit*1024*1024; //$v_memory_limit = $v_memory_limit*1024*1024;
$v_memory_limit = $v_memory_limit*1048576; $v_memory_limit = $v_memory_limit*1048576;
if($last == 'k') if ($last == 'k')
$v_memory_limit = $v_memory_limit*1024; $v_memory_limit = $v_memory_limit*1024;
$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
@ -2412,7 +2412,7 @@
$v_offset = @ftell($this->zip_fd); $v_offset = @ftell($this->zip_fd);
// ----- Create the Central Dir files header // ----- Create the Central Dir files header
for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
{ {
// ----- Create the file header // ----- Create the file header
if ($v_header_list[$i]['status'] == 'ok') { if ($v_header_list[$i]['status'] == 'ok') {

View File

@ -330,10 +330,10 @@ class PHPExcel_Shared_String
} }
public static function buildCharacterSets() { public static function buildCharacterSets() {
if(empty(self::$_controlCharacters)) { if (empty(self::$_controlCharacters)) {
self::_buildControlCharacters(); self::_buildControlCharacters();
} }
if(empty(self::$_SYLKCharacters)) { if (empty(self::$_SYLKCharacters)) {
self::_buildSYLKCharacters(); self::_buildSYLKCharacters();
} }
} }
@ -436,19 +436,18 @@ class PHPExcel_Shared_String
// character count // character count
$ln = self::CountCharacters($value, 'UTF-8'); $ln = self::CountCharacters($value, 'UTF-8');
// option flags // option flags
if(empty($arrcRuns)){ if (empty($arrcRuns)) {
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ? $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
0x0001 : 0x0000; 0x0001 : 0x0000;
$data = pack('CC', $ln, $opt); $data = pack('CC', $ln, $opt);
// characters // characters
$data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
} } else {
else {
$data = pack('vC', $ln, 0x09); $data = pack('vC', $ln, 0x09);
$data .= pack('v', count($arrcRuns)); $data .= pack('v', count($arrcRuns));
// characters // characters
$data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
foreach ($arrcRuns as $cRun){ foreach ($arrcRuns as $cRun) {
$data .= pack('v', $cRun['strlen']); $data .= pack('v', $cRun['strlen']);
$data .= pack('v', $cRun['fontidx']); $data .= pack('v', $cRun['fontidx']);
} }
@ -500,9 +499,9 @@ class PHPExcel_Shared_String
return mb_convert_encoding($value, $to, $from); return mb_convert_encoding($value, $to, $from);
} }
if($from == 'UTF-16LE'){ if ($from == 'UTF-16LE') {
return self::utf16_decode($value, false); return self::utf16_decode($value, false);
}else if($from == 'UTF-16BE'){ } else if ($from == 'UTF-16BE') {
return self::utf16_decode($value); return self::utf16_decode($value);
} }
// else, no conversion // else, no conversion
@ -525,15 +524,15 @@ class PHPExcel_Shared_String
* @author vadik56 * @author vadik56
*/ */
public static function utf16_decode($str, $bom_be = TRUE) { public static function utf16_decode($str, $bom_be = TRUE) {
if( strlen($str) < 2 ) return $str; if ( strlen($str) < 2 ) return $str;
$c0 = ord($str{0}); $c0 = ord($str{0});
$c1 = ord($str{1}); $c1 = ord($str{1});
if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); } if ( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; } elseif ( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
$len = strlen($str); $len = strlen($str);
$newstr = ''; $newstr = '';
for($i=0;$i<$len;$i+=2) { for($i=0;$i<$len;$i+=2) {
if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); } if ( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); } else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
$newstr .= ($val == 0x228) ? "\n" : chr($val); $newstr .= ($val == 0x228) ? "\n" : chr($val);
} }
@ -649,8 +648,8 @@ class PHPExcel_Shared_String
{ {
if (self::getIsMbstringEnabled()) { if (self::getIsMbstringEnabled()) {
$characters = self::mb_str_split($pValue); $characters = self::mb_str_split($pValue);
foreach($characters as &$character) { foreach ($characters as &$character) {
if(self::mb_is_upper($character)) { if (self::mb_is_upper($character)) {
$character = mb_strtolower($character, 'UTF-8'); $character = mb_strtolower($character, 'UTF-8');
} else { } else {
$character = mb_strtoupper($character, 'UTF-8'); $character = mb_strtoupper($character, 'UTF-8');

View File

@ -129,7 +129,7 @@ class PHPExcel_Shared_TimeZone
$objTimezone = new DateTimeZone($timezone); $objTimezone = new DateTimeZone($timezone);
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$transitions = $objTimezone->getTransitions($timestamp,$timestamp); $transitions = $objTimezone->getTransitions($timestamp, $timestamp);
} else { } else {
$transitions = self::_getTimezoneTransitions($objTimezone, $timestamp); $transitions = self::_getTimezoneTransitions($objTimezone, $timestamp);
} }

View File

@ -115,7 +115,7 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
public function writeRawData($text) public function writeRawData($text)
{ {
if (is_array($text)) { if (is_array($text)) {
$text = implode("\n",$text); $text = implode("\n", $text);
} }
if (method_exists($this, 'writeRaw')) { if (method_exists($this, 'writeRaw')) {

View File

@ -174,7 +174,7 @@ class PHPExcel_Best_Fit
*/ */
public function getSlope($dp=0) { public function getSlope($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_slope,$dp); return round($this->_slope, $dp);
} }
return $this->_slope; return $this->_slope;
} // function getSlope() } // function getSlope()
@ -188,7 +188,7 @@ class PHPExcel_Best_Fit
*/ */
public function getSlopeSE($dp=0) { public function getSlopeSE($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_slopeSE,$dp); return round($this->_slopeSE, $dp);
} }
return $this->_slopeSE; return $this->_slopeSE;
} // function getSlopeSE() } // function getSlopeSE()
@ -202,7 +202,7 @@ class PHPExcel_Best_Fit
*/ */
public function getIntersect($dp=0) { public function getIntersect($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersect,$dp); return round($this->_intersect, $dp);
} }
return $this->_intersect; return $this->_intersect;
} // function getIntersect() } // function getIntersect()
@ -216,7 +216,7 @@ class PHPExcel_Best_Fit
*/ */
public function getIntersectSE($dp=0) { public function getIntersectSE($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersectSE,$dp); return round($this->_intersectSE, $dp);
} }
return $this->_intersectSE; return $this->_intersectSE;
} // function getIntersectSE() } // function getIntersectSE()
@ -230,7 +230,7 @@ class PHPExcel_Best_Fit
*/ */
public function getGoodnessOfFit($dp=0) { public function getGoodnessOfFit($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_goodnessOfFit,$dp); return round($this->_goodnessOfFit, $dp);
} }
return $this->_goodnessOfFit; return $this->_goodnessOfFit;
} // function getGoodnessOfFit() } // function getGoodnessOfFit()
@ -238,7 +238,7 @@ class PHPExcel_Best_Fit
public function getGoodnessOfFitPercent($dp=0) { public function getGoodnessOfFitPercent($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_goodnessOfFit * 100,$dp); return round($this->_goodnessOfFit * 100, $dp);
} }
return $this->_goodnessOfFit * 100; return $this->_goodnessOfFit * 100;
} // function getGoodnessOfFitPercent() } // function getGoodnessOfFitPercent()
@ -252,7 +252,7 @@ class PHPExcel_Best_Fit
*/ */
public function getStdevOfResiduals($dp=0) { public function getStdevOfResiduals($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_stdevOfResiduals,$dp); return round($this->_stdevOfResiduals, $dp);
} }
return $this->_stdevOfResiduals; return $this->_stdevOfResiduals;
} // function getStdevOfResiduals() } // function getStdevOfResiduals()
@ -260,7 +260,7 @@ class PHPExcel_Best_Fit
public function getSSRegression($dp=0) { public function getSSRegression($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_SSRegression,$dp); return round($this->_SSRegression, $dp);
} }
return $this->_SSRegression; return $this->_SSRegression;
} // function getSSRegression() } // function getSSRegression()
@ -268,7 +268,7 @@ class PHPExcel_Best_Fit
public function getSSResiduals($dp=0) { public function getSSResiduals($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_SSResiduals,$dp); return round($this->_SSResiduals, $dp);
} }
return $this->_SSResiduals; return $this->_SSResiduals;
} // function getSSResiduals() } // function getSSResiduals()
@ -276,7 +276,7 @@ class PHPExcel_Best_Fit
public function getDFResiduals($dp=0) { public function getDFResiduals($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_DFResiduals,$dp); return round($this->_DFResiduals, $dp);
} }
return $this->_DFResiduals; return $this->_DFResiduals;
} // function getDFResiduals() } // function getDFResiduals()
@ -284,7 +284,7 @@ class PHPExcel_Best_Fit
public function getF($dp=0) { public function getF($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_F,$dp); return round($this->_F, $dp);
} }
return $this->_F; return $this->_F;
} // function getF() } // function getF()
@ -292,7 +292,7 @@ class PHPExcel_Best_Fit
public function getCovariance($dp=0) { public function getCovariance($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_covariance,$dp); return round($this->_covariance, $dp);
} }
return $this->_covariance; return $this->_covariance;
} // function getCovariance() } // function getCovariance()
@ -300,7 +300,7 @@ class PHPExcel_Best_Fit
public function getCorrelation($dp=0) { public function getCorrelation($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_correlation,$dp); return round($this->_correlation, $dp);
} }
return $this->_correlation; return $this->_correlation;
} // function getCorrelation() } // function getCorrelation()
@ -311,9 +311,9 @@ class PHPExcel_Best_Fit
} // function getYBestFitValues() } // function getYBestFitValues()
protected function _calculateGoodnessOfFit($sumX,$sumY,$sumX2,$sumY2,$sumXY,$meanX,$meanY, $const) { protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) {
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0; $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach($this->_xValues as $xKey => $xValue) { foreach ($this->_xValues as $xKey => $xValue) {
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue); $bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
$SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY); $SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY);
@ -398,7 +398,7 @@ class PHPExcel_Best_Fit
$this->_intersect = 0; $this->_intersect = 0;
} }
$this->_calculateGoodnessOfFit($x_sum,$y_sum,$xx_sum,$yy_sum,$xy_sum,$meanX,$meanY,$const); $this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
} // function _leastSquareFit() } // function _leastSquareFit()
@ -416,7 +416,7 @@ class PHPExcel_Best_Fit
// Define X Values if necessary // Define X Values if necessary
if ($nX == 0) { if ($nX == 0) {
$xValues = range(1,$nY); $xValues = range(1, $nY);
$nX = $nY; $nX = $nY;
} elseif ($nY != $nX) { } elseif ($nY != $nX) {
// Ensure both arrays of points are the same size // Ensure both arrays of points are the same size

View File

@ -91,7 +91,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getSlope($dp=0) { public function getSlope($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_slope),$dp); return round(exp($this->_slope), $dp);
} }
return exp($this->_slope); return exp($this->_slope);
} // function getSlope() } // function getSlope()
@ -105,7 +105,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getIntersect($dp=0) { public function getIntersect($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_intersect),$dp); return round(exp($this->_intersect), $dp);
} }
return exp($this->_intersect); return exp($this->_intersect);
} // function getIntersect() } // function getIntersect()
@ -119,7 +119,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _exponential_regression($yValues, $xValues, $const) { private function _exponential_regression($yValues, $xValues, $const) {
foreach($yValues as &$value) { foreach ($yValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {

View File

@ -91,7 +91,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _linear_regression($yValues, $xValues, $const) { private function _linear_regression($yValues, $xValues, $const) {
$this->_leastSquareFit($yValues, $xValues,$const); $this->_leastSquareFit($yValues, $xValues, $const);
} // function _linear_regression() } // function _linear_regression()

View File

@ -91,7 +91,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _logarithmic_regression($yValues, $xValues, $const) { private function _logarithmic_regression($yValues, $xValues, $const) {
foreach($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {

View File

@ -75,7 +75,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue) {
$retVal = $this->getIntersect(); $retVal = $this->getIntersect();
$slope = $this->getSlope(); $slope = $this->getSlope();
foreach($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$retVal += $value * pow($xValue, $key + 1); $retVal += $value * pow($xValue, $key + 1);
} }
@ -106,7 +106,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
$equation = 'Y = '.$intersect; $equation = 'Y = '.$intersect;
foreach($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$equation .= ' + '.$value.' * X'; $equation .= ' + '.$value.' * X';
if ($key > 0) { if ($key > 0) {
@ -127,8 +127,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
public function getSlope($dp=0) { public function getSlope($dp=0) {
if ($dp != 0) { if ($dp != 0) {
$coefficients = array(); $coefficients = array();
foreach($this->_slope as $coefficient) { foreach ($this->_slope as $coefficient) {
$coefficients[] = round($coefficient,$dp); $coefficients[] = round($coefficient, $dp);
} }
return $coefficients; return $coefficients;
} }
@ -137,7 +137,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
public function getCoefficients($dp=0) { public function getCoefficients($dp=0) {
return array_merge(array($this->getIntersect($dp)),$this->getSlope($dp)); return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
} // function getCoefficients() } // function getCoefficients()
@ -191,8 +191,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$this->_intersect = array_shift($coefficients); $this->_intersect = array_shift($coefficients);
$this->_slope = $coefficients; $this->_slope = $coefficients;
$this->_calculateGoodnessOfFit($x_sum,$y_sum,$xx_sum,$yy_sum,$xy_sum); $this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum);
foreach($this->_xValues as $xKey => $xValue) { foreach ($this->_xValues as $xKey => $xValue) {
$this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue); $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
} }
} // function _polynomial_regression() } // function _polynomial_regression()

View File

@ -54,7 +54,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue) {
return $this->getIntersect() * pow(($xValue - $this->_Xoffset),$this->getSlope()); return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
} // function getValueOfYForX() } // function getValueOfYForX()
@ -91,7 +91,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getIntersect($dp=0) { public function getIntersect($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_intersect),$dp); return round(exp($this->_intersect), $dp);
} }
return exp($this->_intersect); return exp($this->_intersect);
} // function getIntersect() } // function getIntersect()
@ -105,7 +105,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _power_regression($yValues, $xValues, $const) { private function _power_regression($yValues, $xValues, $const) {
foreach($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {
@ -113,7 +113,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
} }
} }
unset($value); unset($value);
foreach($yValues as &$value) { foreach ($yValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {

View File

@ -91,7 +91,7 @@ class trendClass
// Define X Values if necessary // Define X Values if necessary
if ($nX == 0) { if ($nX == 0) {
$xValues = range(1,$nY); $xValues = range(1, $nY);
$nX = $nY; $nX = $nY;
} elseif ($nY != $nX) { } elseif ($nY != $nX) {
// Ensure both arrays of points are the same size // Ensure both arrays of points are the same size
@ -108,7 +108,7 @@ class trendClass
case self::TREND_POWER : case self::TREND_POWER :
if (!isset(self::$_trendCache[$key])) { if (!isset(self::$_trendCache[$key])) {
$className = 'PHPExcel_'.$trendType.'_Best_Fit'; $className = 'PHPExcel_'.$trendType.'_Best_Fit';
self::$_trendCache[$key] = new $className($yValues,$xValues,$const); self::$_trendCache[$key] = new $className($yValues, $xValues, $const);
} }
return self::$_trendCache[$key]; return self::$_trendCache[$key];
break; break;
@ -119,7 +119,7 @@ class trendClass
case self::TREND_POLYNOMIAL_6 : case self::TREND_POLYNOMIAL_6 :
if (!isset(self::$_trendCache[$key])) { if (!isset(self::$_trendCache[$key])) {
$order = substr($trendType,-1); $order = substr($trendType,-1);
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order,$yValues,$xValues,$const); self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
} }
return self::$_trendCache[$key]; return self::$_trendCache[$key];
break; break;
@ -127,15 +127,15 @@ class trendClass
case self::TREND_BEST_FIT_NO_POLY : case self::TREND_BEST_FIT_NO_POLY :
// If the request is to determine the best fit regression, then we test each trend line in turn // If the request is to determine the best fit regression, then we test each trend line in turn
// Start by generating an instance of each available trend method // Start by generating an instance of each available trend method
foreach(self::$_trendTypes as $trendMethod) { foreach (self::$_trendTypes as $trendMethod) {
$className = 'PHPExcel_'.$trendMethod.'BestFit'; $className = 'PHPExcel_'.$trendMethod.'BestFit';
$bestFit[$trendMethod] = new $className($yValues,$xValues,$const); $bestFit[$trendMethod] = new $className($yValues, $xValues, $const);
$bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit(); $bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
} }
if ($trendType != self::TREND_BEST_FIT_NO_POLY) { if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
foreach(self::$_trendTypePolyOrders as $trendMethod) { foreach (self::$_trendTypePolyOrders as $trendMethod) {
$order = substr($trendMethod,-1); $order = substr($trendMethod,-1);
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order,$yValues,$xValues,$const); $bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
if ($bestFit[$trendMethod]->getError()) { if ($bestFit[$trendMethod]->getError()) {
unset($bestFit[$trendMethod]); unset($bestFit[$trendMethod]);
} else { } else {

View File

@ -378,7 +378,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
*/ */
public function disconnectCells() { public function disconnectCells() {
if ( $this->_cellCollection !== NULL){ if ( $this->_cellCollection !== NULL) {
$this->_cellCollection->unsetWorksheetCells(); $this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = NULL; $this->_cellCollection = NULL;
} }
@ -620,7 +620,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getChartNames() public function getChartNames()
{ {
$chartNames = array(); $chartNames = array();
foreach($this->_chartCollection as $chart) { foreach ($this->_chartCollection as $chart) {
$chartNames[] = $chart->getName(); $chartNames[] = $chart->getName();
} }
return $chartNames; return $chartNames;
@ -639,7 +639,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ($chartCount == 0) { if ($chartCount == 0) {
return false; return false;
} }
foreach($this->_chartCollection as $index => $chart) { foreach ($this->_chartCollection as $index => $chart) {
if ($chart->getName() == $chartName) { if ($chart->getName() == $chartName) {
return $this->_chartCollection[$index]; return $this->_chartCollection[$index];
} }
@ -858,7 +858,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
} }
$altTitle = $pValue . ' ' . $i; $altTitle = $pValue . ' ' . $i;
return $this->setTitle($altTitle,$updateFormulaCellReferences); return $this->setTitle($altTitle, $updateFormulaCellReferences);
} }
} }
@ -1314,7 +1314,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return NULL; return NULL;
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow); $this->_cachedHighestRow = max($this->_cachedHighestRow, $pRow);
} }
return $this->_rowDimensions[$pRow]; return $this->_rowDimensions[$pRow];
} }
@ -1571,7 +1571,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '')
{ {
foreach($pCellStyle as $cellStyle) { foreach ($pCellStyle as $cellStyle) {
if (!($cellStyle instanceof PHPExcel_Style_Conditional)) { if (!($cellStyle instanceof PHPExcel_Style_Conditional)) {
throw new PHPExcel_Exception('Style is not a conditional style'); throw new PHPExcel_Exception('Style is not a conditional style');
} }
@ -1899,7 +1899,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if (is_string($pValue)) { if (is_string($pValue)) {
$this->_autoFilter->setRange($pValue); $this->_autoFilter->setRange($pValue);
} elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { } elseif (is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) {
$this->_autoFilter = $pValue; $this->_autoFilter = $pValue;
} }
return $this; return $this;
@ -2406,7 +2406,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Loop through $source // Loop through $source
foreach ($source as $rowData) { foreach ($source as $rowData) {
$currentColumn = $startColumn; $currentColumn = $startColumn;
foreach($rowData as $cellValue) { foreach ($rowData as $cellValue) {
if ($strictNullComparison) { if ($strictNullComparison) {
if ($cellValue !== $nullValue) { if ($cellValue !== $nullValue) {
// Set cell value // Set cell value
@ -2600,7 +2600,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Loop through row dimensions // Loop through row dimensions
foreach ($this->_rowDimensions as $dimension) { foreach ($this->_rowDimensions as $dimension) {
$highestRow = max($highestRow,$dimension->getRowIndex()); $highestRow = max($highestRow, $dimension->getRowIndex());
} }
// Cache values // Cache values
@ -2779,7 +2779,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$maxRow = $this->getHighestRow(); $maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
$rangeBlocks = explode(' ',$range); $rangeBlocks = explode(' ', $range);
foreach ($rangeBlocks as &$rangeSet) { foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
@ -2790,7 +2790,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1]; $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
} }
unset($rangeSet); unset($rangeSet);
$stRange = implode(' ',$rangeBlocks); $stRange = implode(' ', $rangeBlocks);
return $stRange; return $stRange;
} }
@ -2876,7 +2876,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return objWorksheet * @return objWorksheet
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setCodeName($pValue=null){ public function setCodeName($pValue=null) {
// Is this a 'rename' or not? // Is this a 'rename' or not?
if ($this->getCodeName() == $pValue) { if ($this->getCodeName() == $pValue) {
return $this; return $this;
@ -2912,7 +2912,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$pValue = $pValue . '_' . $i;// ok, we have a valid name $pValue = $pValue . '_' . $i;// ok, we have a valid name
//codeName is'nt used in formula : no need to call for an update //codeName is'nt used in formula : no need to call for an update
//return $this->setTitle($altTitle,$updateFormulaCellReferences); //return $this->setTitle($altTitle, $updateFormulaCellReferences);
} }
} }
@ -2924,14 +2924,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return null|string * @return null|string
*/ */
public function getCodeName(){ public function getCodeName() {
return $this->_codeName; return $this->_codeName;
} }
/** /**
* Sheet has a code name ? * Sheet has a code name ?
* @return boolean * @return boolean
*/ */
public function hasCodeName(){ public function hasCodeName() {
return !(is_null($this->_codeName)); return !(is_null($this->_codeName));
} }
} }

View File

@ -112,12 +112,12 @@ class PHPExcel_Worksheet_AutoFilter
// Uppercase coordinate // Uppercase coordinate
$cellAddress = explode('!',strtoupper($pRange)); $cellAddress = explode('!',strtoupper($pRange));
if (count($cellAddress) > 1) { if (count($cellAddress) > 1) {
list($worksheet,$pRange) = $cellAddress; list($worksheet, $pRange) = $cellAddress;
} }
if (strpos($pRange,':') !== FALSE) { if (strpos($pRange,':') !== FALSE) {
$this->_range = $pRange; $this->_range = $pRange;
} elseif(empty($pRange)) { } elseif (empty($pRange)) {
$this->_range = ''; $this->_range = '';
} else { } else {
throw new PHPExcel_Exception('Autofilter must be set on a range of cells.'); throw new PHPExcel_Exception('Autofilter must be set on a range of cells.');
@ -128,8 +128,8 @@ class PHPExcel_Worksheet_AutoFilter
$this->_columns = array(); $this->_columns = array();
} else { } else {
// Discard any column rules that are no longer valid within this range // Discard any column rules that are no longer valid within this range
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
foreach($this->_columns as $key => $value) { foreach ($this->_columns as $key => $value) {
$colIndex = PHPExcel_Cell::columnIndexFromString($key); $colIndex = PHPExcel_Cell::columnIndexFromString($key);
if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) { if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) {
unset($this->_columns[$key]); unset($this->_columns[$key]);
@ -163,7 +163,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) { if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) {
throw new PHPExcel_Exception("Column is outside of current autofilter range."); throw new PHPExcel_Exception("Column is outside of current autofilter range.");
} }
@ -207,7 +207,7 @@ class PHPExcel_Worksheet_AutoFilter
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getColumnByOffset($pColumnOffset = 0) { public function getColumnByOffset($pColumnOffset = 0) {
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
$pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); $pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1);
return $this->getColumn($pColumn); return $this->getColumn($pColumn);
@ -225,7 +225,7 @@ class PHPExcel_Worksheet_AutoFilter
{ {
if ((is_string($pColumn)) && (!empty($pColumn))) { if ((is_string($pColumn)) && (!empty($pColumn))) {
$column = $pColumn; $column = $pColumn;
} elseif(is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { } elseif (is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) {
$column = $pColumn->getColumnIndex(); $column = $pColumn->getColumnIndex();
} else { } else {
throw new PHPExcel_Exception("Column is not within the autofilter range."); throw new PHPExcel_Exception("Column is not within the autofilter range.");
@ -234,7 +234,7 @@ class PHPExcel_Worksheet_AutoFilter
if (is_string($pColumn)) { if (is_string($pColumn)) {
$this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this); $this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this);
} elseif(is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { } elseif (is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) {
$pColumn->setParent($this); $pColumn->setParent($this);
$this->_columns[$column] = $pColumn; $this->_columns[$column] = $pColumn;
} }
@ -271,7 +271,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param string $toColumn Column name (e.g. B) * @param string $toColumn Column name (e.g. B)
* @return PHPExcel_Worksheet_AutoFilter * @return PHPExcel_Worksheet_AutoFilter
*/ */
public function shiftColumn($fromColumn=NULL,$toColumn=NULL) { public function shiftColumn($fromColumn=NULL, $toColumn=NULL) {
$fromColumn = strtoupper($fromColumn); $fromColumn = strtoupper($fromColumn);
$toColumn = strtoupper($toColumn); $toColumn = strtoupper($toColumn);
@ -296,14 +296,14 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $dataSet * @param mixed[] $dataSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInSimpleDataSet($cellValue,$dataSet) private static function _filterTestInSimpleDataSet($cellValue, $dataSet)
{ {
$dataSetValues = $dataSet['filterValues']; $dataSetValues = $dataSet['filterValues'];
$blanks = $dataSet['blanks']; $blanks = $dataSet['blanks'];
if (($cellValue == '') || ($cellValue === NULL)) { if (($cellValue == '') || ($cellValue === NULL)) {
return $blanks; return $blanks;
} }
return in_array($cellValue,$dataSetValues); return in_array($cellValue, $dataSetValues);
} }
/** /**
@ -313,7 +313,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $dataSet * @param mixed[] $dataSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInDateGroupSet($cellValue,$dataSet) private static function _filterTestInDateGroupSet($cellValue, $dataSet)
{ {
$dateSet = $dataSet['filterValues']; $dateSet = $dataSet['filterValues'];
$blanks = $dataSet['blanks']; $blanks = $dataSet['blanks'];
@ -325,18 +325,18 @@ class PHPExcel_Worksheet_AutoFilter
$dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue); $dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue);
if ($cellValue < 1) { if ($cellValue < 1) {
// Just the time part // Just the time part
$dtVal = date('His',$dateValue); $dtVal = date('His', $dateValue);
$dateSet = $dateSet['time']; $dateSet = $dateSet['time'];
} elseif($cellValue == floor($cellValue)) { } elseif ($cellValue == floor($cellValue)) {
// Just the date part // Just the date part
$dtVal = date('Ymd',$dateValue); $dtVal = date('Ymd', $dateValue);
$dateSet = $dateSet['date']; $dateSet = $dateSet['date'];
} else { } else {
// date and time parts // date and time parts
$dtVal = date('YmdHis',$dateValue); $dtVal = date('YmdHis', $dateValue);
$dateSet = $dateSet['dateTime']; $dateSet = $dateSet['dateTime'];
} }
foreach($dateSet as $dateValue) { foreach ($dateSet as $dateValue) {
// Use of substr to extract value at the appropriate group level // Use of substr to extract value at the appropriate group level
if (substr($dtVal,0,strlen($dateValue)) == $dateValue) if (substr($dtVal,0,strlen($dateValue)) == $dateValue)
return TRUE; return TRUE;
@ -366,7 +366,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
} }
$returnVal = ($join == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); $returnVal = ($join == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND);
foreach($dataSet as $rule) { foreach ($dataSet as $rule) {
if (is_numeric($rule['value'])) { if (is_numeric($rule['value'])) {
// Numeric values are tested using the appropriate operator // Numeric values are tested using the appropriate operator
switch ($rule['operator']) { switch ($rule['operator']) {
@ -389,7 +389,7 @@ class PHPExcel_Worksheet_AutoFilter
$retVal = ($cellValue <= $rule['value']); $retVal = ($cellValue <= $rule['value']);
break; break;
} }
} elseif($rule['value'] == '') { } elseif ($rule['value'] == '') {
switch ($rule['operator']) { switch ($rule['operator']) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL :
$retVal = (($cellValue == '') || ($cellValue === NULL)); $retVal = (($cellValue == '') || ($cellValue === NULL));
@ -403,7 +403,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
} else { } else {
// String values are always tested for equality, factoring in for wildcards (hence a regexp test) // String values are always tested for equality, factoring in for wildcards (hence a regexp test)
$retVal = preg_match('/^'.$rule['value'].'$/i',$cellValue); $retVal = preg_match('/^'.$rule['value'].'$/i', $cellValue);
} }
// If there are multiple conditions, then we need to test both using the appropriate join operator // If there are multiple conditions, then we need to test both using the appropriate join operator
switch ($join) { switch ($join) {
@ -439,7 +439,7 @@ class PHPExcel_Worksheet_AutoFilter
if (is_numeric($cellValue)) { if (is_numeric($cellValue)) {
$dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue)); $dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue));
if (in_array($dateValue,$monthSet)) { if (in_array($dateValue, $monthSet)) {
return TRUE; return TRUE;
} }
} }
@ -474,28 +474,28 @@ class PHPExcel_Worksheet_AutoFilter
// Calculate start/end dates for the required date range based on current date // Calculate start/end dates for the required date range based on current date
switch ($dynamicRuleType) { switch ($dynamicRuleType) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
$baseDate = strtotime('-7 days',$baseDate); $baseDate = strtotime('-7 days', $baseDate);
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
$baseDate = strtotime('-7 days',$baseDate); $baseDate = strtotime('-7 days', $baseDate);
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
$baseDate = strtotime('-1 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('-1 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
$baseDate = strtotime('+1 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('+1 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
$baseDate = strtotime('-3 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('-3 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
$baseDate = strtotime('+3 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('+3 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
$baseDate = strtotime('-1 year',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('-1 year',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
$baseDate = strtotime('+1 year',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('+1 year',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
} }
@ -503,40 +503,40 @@ class PHPExcel_Worksheet_AutoFilter
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW :
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day',$baseDate)); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate); $val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate);
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE :
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day',$baseDate)); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
$maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,31,12,date('Y',$baseDate))); $maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,31,12,date('Y', $baseDate)));
++$maxVal; ++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
$thisMonth = date('m',$baseDate); $thisMonth = date('m', $baseDate);
$thisQuarter = floor(--$thisMonth / 3); $thisQuarter = floor(--$thisMonth / 3);
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t',$baseDate),(1+$thisQuarter)*3,date('Y',$baseDate))); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t', $baseDate),(1+$thisQuarter)*3,date('Y', $baseDate)));
++$maxVal; ++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1+$thisQuarter*3,date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1+$thisQuarter*3,date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t',$baseDate),date('m',$baseDate),date('Y',$baseDate))); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t', $baseDate),date('m', $baseDate),date('Y', $baseDate)));
++$maxVal; ++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
$dayOfWeek = date('w',$baseDate); $dayOfWeek = date('w', $baseDate);
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek; $val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek;
$maxVal = $val + 7; $maxVal = $val + 7;
break; break;
@ -577,7 +577,7 @@ class PHPExcel_Worksheet_AutoFilter
); );
} }
private function _calculateTopTenValue($columnID,$startRow,$endRow,$ruleType,$ruleValue) { private function _calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue) {
$range = $columnID.$startRow.':'.$columnID.$endRow; $range = $columnID.$startRow.':'.$columnID.$endRow;
$dataValues = PHPExcel_Calculation_Functions::flattenArray( $dataValues = PHPExcel_Calculation_Functions::flattenArray(
$this->_workSheet->rangeToArray($range,NULL,TRUE,FALSE) $this->_workSheet->rangeToArray($range,NULL,TRUE,FALSE)
@ -590,7 +590,7 @@ class PHPExcel_Worksheet_AutoFilter
sort($dataValues); sort($dataValues);
} }
return array_pop(array_slice($dataValues,0,$ruleValue)); return array_pop(array_slice($dataValues,0, $ruleValue));
} }
/** /**
@ -601,20 +601,20 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function showHideRows() public function showHideRows()
{ {
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
// The heading row should always be visible // The heading row should always be visible
// echo 'AutoFilter Heading Row ',$rangeStart[1],' is always SHOWN',PHP_EOL; // echo 'AutoFilter Heading Row ', $rangeStart[1],' is always SHOWN',PHP_EOL;
$this->_workSheet->getRowDimension($rangeStart[1])->setVisible(TRUE); $this->_workSheet->getRowDimension($rangeStart[1])->setVisible(TRUE);
$columnFilterTests = array(); $columnFilterTests = array();
foreach($this->_columns as $columnID => $filterColumn) { foreach ($this->_columns as $columnID => $filterColumn) {
$rules = $filterColumn->getRules(); $rules = $filterColumn->getRules();
switch ($filterColumn->getFilterType()) { switch ($filterColumn->getFilterType()) {
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER : case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER :
$ruleValues = array(); $ruleValues = array();
// Build a list of the filter value selections // Build a list of the filter value selections
foreach($rules as $rule) { foreach ($rules as $rule) {
$ruleType = $rule->getRuleType(); $ruleType = $rule->getRuleType();
$ruleValues[] = $rule->getValue(); $ruleValues[] = $rule->getValue();
} }
@ -638,26 +638,26 @@ class PHPExcel_Worksheet_AutoFilter
'time' => array(), 'time' => array(),
'dateTime' => array(), 'dateTime' => array(),
); );
foreach($ruleDataSet as $ruleValue) { foreach ($ruleDataSet as $ruleValue) {
$date = $time = ''; $date = $time = '';
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== ''))
$date .= sprintf('%04d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]); $date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != ''))
$date .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]); $date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== ''))
$date .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]); $date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== ''))
$time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== ''))
$time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== ''))
$time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
$dateTime = $date . $time; $dateTime = $date . $time;
$arguments['date'][] = $date; $arguments['date'][] = $date;
$arguments['time'][] = $time; $arguments['time'][] = $time;
@ -679,13 +679,13 @@ class PHPExcel_Worksheet_AutoFilter
$customRuleForBlanks = FALSE; $customRuleForBlanks = FALSE;
$ruleValues = array(); $ruleValues = array();
// Build a list of the filter value selections // Build a list of the filter value selections
foreach($rules as $rule) { foreach ($rules as $rule) {
$ruleType = $rule->getRuleType(); $ruleType = $rule->getRuleType();
$ruleValue = $rule->getValue(); $ruleValue = $rule->getValue();
if (!is_numeric($ruleValue)) { if (!is_numeric($ruleValue)) {
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards // Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
$ruleValue = preg_quote($ruleValue); $ruleValue = preg_quote($ruleValue);
$ruleValue = str_replace(self::$_fromReplace,self::$_toReplace,$ruleValue); $ruleValue = str_replace(self::$_fromReplace,self::$_toReplace, $ruleValue);
if (trim($ruleValue) == '') { if (trim($ruleValue) == '') {
$customRuleForBlanks = TRUE; $customRuleForBlanks = TRUE;
$ruleValue = trim($ruleValue); $ruleValue = trim($ruleValue);
@ -706,7 +706,7 @@ class PHPExcel_Worksheet_AutoFilter
break; break;
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER : case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER :
$ruleValues = array(); $ruleValues = array();
foreach($rules as $rule) { foreach ($rules as $rule) {
// We should only ever have one Dynamic Filter Rule anyway // We should only ever have one Dynamic Filter Rule anyway
$dynamicRuleType = $rule->getGrouping(); $dynamicRuleType = $rule->getGrouping();
if (($dynamicRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) || if (($dynamicRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) ||
@ -714,7 +714,7 @@ class PHPExcel_Worksheet_AutoFilter
// Number (Average) based // Number (Average) based
// Calculate the average // Calculate the average
$averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')'; $averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')';
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,NULL,$this->_workSheet->getCell('A1')); $average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,NULL, $this->_workSheet->getCell('A1'));
// Set above/below rule based on greaterThan or LessTan // Set above/below rule based on greaterThan or LessTan
$operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) $operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN
@ -757,7 +757,7 @@ class PHPExcel_Worksheet_AutoFilter
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER : case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER :
$ruleValues = array(); $ruleValues = array();
$dataRowCount = $rangeEnd[1] - $rangeStart[1]; $dataRowCount = $rangeEnd[1] - $rangeStart[1];
foreach($rules as $rule) { foreach ($rules as $rule) {
// We should only ever have one Dynamic Filter Rule anyway // We should only ever have one Dynamic Filter Rule anyway
$toptenRuleType = $rule->getGrouping(); $toptenRuleType = $rule->getGrouping();
$ruleValue = $rule->getValue(); $ruleValue = $rule->getValue();
@ -769,7 +769,7 @@ class PHPExcel_Worksheet_AutoFilter
if ($ruleValue < 1) $ruleValue = 1; if ($ruleValue < 1) $ruleValue = 1;
if ($ruleValue > 500) $ruleValue = 500; if ($ruleValue > 500) $ruleValue = 500;
$maxVal = $this->_calculateTopTenValue($columnID,$rangeStart[1]+1,$rangeEnd[1],$toptenRuleType,$ruleValue); $maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
$operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) $operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL
@ -795,16 +795,16 @@ class PHPExcel_Worksheet_AutoFilter
// //
// Execute the column tests for each row in the autoFilter range to determine show/hide, // Execute the column tests for each row in the autoFilter range to determine show/hide,
for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) { for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) {
// echo 'Testing Row = ',$row,PHP_EOL; // echo 'Testing Row = ', $row,PHP_EOL;
$result = TRUE; $result = TRUE;
foreach($columnFilterTests as $columnID => $columnFilterTest) { foreach ($columnFilterTests as $columnID => $columnFilterTest) {
// echo 'Testing cell ',$columnID.$row,PHP_EOL; // echo 'Testing cell ', $columnID.$row,PHP_EOL;
$cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue(); $cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue();
// echo 'Value is ',$cellValue,PHP_EOL; // echo 'Value is ', $cellValue,PHP_EOL;
// Execute the filter test // Execute the filter test
$result = $result && $result = $result &&
call_user_func_array( call_user_func_array(
array('PHPExcel_Worksheet_AutoFilter',$columnFilterTest['method']), array('PHPExcel_Worksheet_AutoFilter', $columnFilterTest['method']),
array( array(
$cellValue, $cellValue,
$columnFilterTest['arguments'] $columnFilterTest['arguments']

View File

@ -79,7 +79,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var PHPExcel_Worksheet_AutoFilter * @var PHPExcel_Worksheet_AutoFilter
*/ */
private $_parent = NULL; private $_parent = null;
/** /**
@ -128,7 +128,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @param string $pColumn Column (e.g. A) * @param string $pColumn Column (e.g. A)
* @param PHPExcel_Worksheet_AutoFilter $pParent Autofilter for this column * @param PHPExcel_Worksheet_AutoFilter $pParent Autofilter for this column
*/ */
public function __construct($pColumn, PHPExcel_Worksheet_AutoFilter $pParent = NULL) public function __construct($pColumn, PHPExcel_Worksheet_AutoFilter $pParent = null)
{ {
$this->_columnIndex = $pColumn; $this->_columnIndex = $pColumn;
$this->_parent = $pParent; $this->_parent = $pParent;
@ -139,7 +139,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @return string * @return string
*/ */
public function getColumnIndex() { public function getColumnIndex()
{
return $this->_columnIndex; return $this->_columnIndex;
} }
@ -150,10 +151,11 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setColumnIndex($pColumn) { public function setColumnIndex($pColumn)
{
// Uppercase coordinate // Uppercase coordinate
$pColumn = strtoupper($pColumn); $pColumn = strtoupper($pColumn);
if ($this->_parent !== NULL) { if ($this->_parent !== null) {
$this->_parent->testColumnInRange($pColumn); $this->_parent->testColumnInRange($pColumn);
} }
@ -167,7 +169,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @return PHPExcel_Worksheet_AutoFilter * @return PHPExcel_Worksheet_AutoFilter
*/ */
public function getParent() { public function getParent()
{
return $this->_parent; return $this->_parent;
} }
@ -177,7 +180,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @param PHPExcel_Worksheet_AutoFilter * @param PHPExcel_Worksheet_AutoFilter
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setParent(PHPExcel_Worksheet_AutoFilter $pParent = NULL) { public function setParent(PHPExcel_Worksheet_AutoFilter $pParent = null)
{
$this->_parent = $pParent; $this->_parent = $pParent;
return $this; return $this;
@ -188,7 +192,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @return string * @return string
*/ */
public function getFilterType() { public function getFilterType()
{
return $this->_filterType; return $this->_filterType;
} }
@ -199,8 +204,9 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setFilterType($pFilterType = self::AUTOFILTER_FILTERTYPE_FILTER) { public function setFilterType($pFilterType = self::AUTOFILTER_FILTERTYPE_FILTER)
if (!in_array($pFilterType,self::$_filterTypes)) { {
if (!in_array($pFilterType, self::$_filterTypes)) {
throw new PHPExcel_Exception('Invalid filter type for column AutoFilter.'); throw new PHPExcel_Exception('Invalid filter type for column AutoFilter.');
} }
@ -225,10 +231,11 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setJoin($pJoin = self::AUTOFILTER_COLUMN_JOIN_OR) { public function setJoin($pJoin = self::AUTOFILTER_COLUMN_JOIN_OR)
{
// Lowercase And/Or // Lowercase And/Or
$pJoin = strtolower($pJoin); $pJoin = strtolower($pJoin);
if (!in_array($pJoin,self::$_ruleJoins)) { if (!in_array($pJoin, self::$_ruleJoins)) {
throw new PHPExcel_Exception('Invalid rule connection for column AutoFilter.'); throw new PHPExcel_Exception('Invalid rule connection for column AutoFilter.');
} }
@ -244,7 +251,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setAttributes($pAttributes = array()) { public function setAttributes($pAttributes = array())
{
$this->_attributes = $pAttributes; $this->_attributes = $pAttributes;
return $this; return $this;
@ -258,7 +266,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setAttribute($pName, $pValue) { public function setAttribute($pName, $pValue)
{
$this->_attributes[$pName] = $pValue; $this->_attributes[$pName] = $pValue;
return $this; return $this;
@ -269,7 +278,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @return string * @return string
*/ */
public function getAttributes() { public function getAttributes()
{
return $this->_attributes; return $this->_attributes;
} }
@ -279,10 +289,12 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @param string $pName Attribute Name * @param string $pName Attribute Name
* @return string * @return string
*/ */
public function getAttribute($pName) { public function getAttribute($pName)
if (isset($this->_attributes[$pName])) {
if (isset($this->_attributes[$pName])) {
return $this->_attributes[$pName]; return $this->_attributes[$pName];
return NULL; }
return null;
} }
/** /**
@ -291,7 +303,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return array of PHPExcel_Worksheet_AutoFilter_Column_Rule * @return array of PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getRules() { public function getRules()
{
return $this->_ruleset; return $this->_ruleset;
} }
@ -301,7 +314,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @param integer $pIndex Rule index in the ruleset array * @param integer $pIndex Rule index in the ruleset array
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getRule($pIndex) { public function getRule($pIndex)
{
if (!isset($this->_ruleset[$pIndex])) { if (!isset($this->_ruleset[$pIndex])) {
$this->_ruleset[$pIndex] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this); $this->_ruleset[$pIndex] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this);
} }
@ -313,7 +327,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function createRule() { public function createRule()
{
$this->_ruleset[] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this); $this->_ruleset[] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this);
return end($this->_ruleset); return end($this->_ruleset);
@ -326,7 +341,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @param boolean $returnRule Flag indicating whether the rule object or the column object should be returned * @param boolean $returnRule Flag indicating whether the rule object or the column object should be returned
* @return PHPExcel_Worksheet_AutoFilter_Column|PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column|PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function addRule(PHPExcel_Worksheet_AutoFilter_Column_Rule $pRule, $returnRule=TRUE) { public function addRule(PHPExcel_Worksheet_AutoFilter_Column_Rule $pRule, $returnRule = true)
{
$pRule->setParent($this); $pRule->setParent($this);
$this->_ruleset[] = $pRule; $this->_ruleset[] = $pRule;
@ -340,7 +356,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* @param integer $pIndex Rule index in the ruleset array * @param integer $pIndex Rule index in the ruleset array
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function deleteRule($pIndex) { public function deleteRule($pIndex)
{
if (isset($this->_ruleset[$pIndex])) { if (isset($this->_ruleset[$pIndex])) {
unset($this->_ruleset[$pIndex]); unset($this->_ruleset[$pIndex]);
// If we've just deleted down to a single rule, then reset And/Or joining to Or // If we've just deleted down to a single rule, then reset And/Or joining to Or
@ -357,7 +374,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function clearRules() { public function clearRules()
{
$this->_ruleset = array(); $this->_ruleset = array();
$this->setJoin(self::AUTOFILTER_COLUMN_JOIN_OR); $this->setJoin(self::AUTOFILTER_COLUMN_JOIN_OR);
@ -367,13 +385,14 @@ class PHPExcel_Worksheet_AutoFilter_Column
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
if ($key == '_parent') { if ($key == '_parent') {
// Detach from autofilter parent // Detach from autofilter parent
$this->$key = NULL; $this->$key = null;
} else { } else {
$this->$key = clone $value; $this->$key = clone $value;
} }

View File

@ -234,7 +234,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @var PHPExcel_Worksheet_AutoFilter_Column * @var PHPExcel_Worksheet_AutoFilter_Column
*/ */
private $_parent = NULL; private $_parent = null;
/** /**
@ -272,7 +272,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @param PHPExcel_Worksheet_AutoFilter_Column $pParent * @param PHPExcel_Worksheet_AutoFilter_Column $pParent
*/ */
public function __construct(PHPExcel_Worksheet_AutoFilter_Column $pParent = NULL) public function __construct(PHPExcel_Worksheet_AutoFilter_Column $pParent = null)
{ {
$this->_parent = $pParent; $this->_parent = $pParent;
} }
@ -282,7 +282,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @return string * @return string
*/ */
public function getRuleType() { public function getRuleType()
{
return $this->_ruleType; return $this->_ruleType;
} }
@ -293,8 +294,9 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER) { public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER)
if (!in_array($pRuleType,self::$_ruleTypes)) { {
if (!in_array($pRuleType, self::$_ruleTypes)) {
throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.');
} }
@ -308,7 +310,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @return string * @return string
*/ */
public function getValue() { public function getValue()
{
return $this->_value; return $this->_value;
} }
@ -319,17 +322,18 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setValue($pValue = '') { public function setValue($pValue = '')
{
if (is_array($pValue)) { if (is_array($pValue)) {
$grouping = -1; $grouping = -1;
foreach($pValue as $key => $value) { foreach ($pValue as $key => $value) {
// Validate array entries // Validate array entries
if (!in_array($key,self::$_dateTimeGroups)) { if (!in_array($key, self::$_dateTimeGroups)) {
// Remove any invalid entries from the value array // Remove any invalid entries from the value array
unset($pValue[$key]); unset($pValue[$key]);
} else { } else {
// Work out what the dateTime grouping will be // Work out what the dateTime grouping will be
$grouping = max($grouping,array_search($key,self::$_dateTimeGroups)); $grouping = max($grouping, array_search($key,self::$_dateTimeGroups));
} }
} }
if (count($pValue) == 0) { if (count($pValue) == 0) {
@ -348,7 +352,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @return string * @return string
*/ */
public function getOperator() { public function getOperator()
{
return $this->_operator; return $this->_operator;
} }
@ -359,11 +364,13 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setOperator($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL) { public function setOperator($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL)
if (empty($pOperator)) {
if (empty($pOperator)) {
$pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL; $pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
if ((!in_array($pOperator,self::$_operators)) && }
(!in_array($pOperator,self::$_topTenValue))) { if ((!in_array($pOperator, self::$_operators)) &&
(!in_array($pOperator, self::$_topTenValue))) {
throw new PHPExcel_Exception('Invalid operator for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid operator for column AutoFilter Rule.');
} }
$this->_operator = $pOperator; $this->_operator = $pOperator;
@ -376,7 +383,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @return string * @return string
*/ */
public function getGrouping() { public function getGrouping()
{
return $this->_grouping; return $this->_grouping;
} }
@ -387,14 +395,14 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setGrouping($pGrouping = NULL) { public function setGrouping($pGrouping = null)
if (($pGrouping !== NULL) && {
(!in_array($pGrouping,self::$_dateTimeGroups)) && if (($pGrouping !== null) &&
(!in_array($pGrouping,self::$_dynamicTypes)) && (!in_array($pGrouping, self::$_dateTimeGroups)) &&
(!in_array($pGrouping,self::$_topTenType))) { (!in_array($pGrouping, self::$_dynamicTypes)) &&
(!in_array($pGrouping, self::$_topTenType))) {
throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.');
} }
$this->_grouping = $pGrouping; $this->_grouping = $pGrouping;
return $this; return $this;
@ -409,14 +417,16 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setRule($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL, $pValue = '', $pGrouping = NULL) { public function setRule($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL, $pValue = '', $pGrouping = null)
{
$this->setOperator($pOperator); $this->setOperator($pOperator);
$this->setValue($pValue); $this->setValue($pValue);
// Only set grouping if it's been passed in as a user-supplied argument, // Only set grouping if it's been passed in as a user-supplied argument,
// otherwise we're calculating it when we setValue() and don't want to overwrite that // otherwise we're calculating it when we setValue() and don't want to overwrite that
// If the user supplies an argumnet for grouping, then on their own head be it // If the user supplies an argumnet for grouping, then on their own head be it
if ($pGrouping !== NULL) if ($pGrouping !== null) {
$this->setGrouping($pGrouping); $this->setGrouping($pGrouping);
}
return $this; return $this;
} }
@ -426,7 +436,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getParent() { public function getParent()
{
return $this->_parent; return $this->_parent;
} }
@ -436,7 +447,8 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* @param PHPExcel_Worksheet_AutoFilter_Column * @param PHPExcel_Worksheet_AutoFilter_Column
* @return PHPExcel_Worksheet_AutoFilter_Column_Rule * @return PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setParent(PHPExcel_Worksheet_AutoFilter_Column $pParent = NULL) { public function setParent(PHPExcel_Worksheet_AutoFilter_Column $pParent = null)
{
$this->_parent = $pParent; $this->_parent = $pParent;
return $this; return $this;
@ -445,13 +457,14 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
if ($key == '_parent') { if ($key == '_parent') {
// Detach from autofilter column parent // Detach from autofilter column parent
$this->$key = NULL; $this->$key = null;
} else { } else {
$this->$key = clone $value; $this->$key = clone $value;
} }
@ -460,5 +473,4 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
} }
} }
} }
} }

View File

@ -154,7 +154,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return int * @return int
*/ */
public function getImageIndex() { public function getImageIndex()
{
return $this->_imageIndex; return $this->_imageIndex;
} }
@ -163,7 +164,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getName() { public function getName()
{
return $this->_name; return $this->_name;
} }
@ -173,7 +175,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param string $pValue * @param string $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setName($pValue = '') { public function setName($pValue = '')
{
$this->_name = $pValue; $this->_name = $pValue;
return $this; return $this;
} }
@ -183,7 +186,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getDescription() { public function getDescription()
{
return $this->_description; return $this->_description;
} }
@ -193,7 +197,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param string $pValue * @param string $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setDescription($pValue = '') { public function setDescription($pValue = '')
{
$this->_description = $pValue; $this->_description = $pValue;
return $this; return $this;
} }
@ -203,7 +208,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function getWorksheet() { public function getWorksheet()
{
return $this->_worksheet; return $this->_worksheet;
} }
@ -215,7 +221,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setWorksheet(PHPExcel_Worksheet $pValue = null, $pOverrideOld = false) { public function setWorksheet(PHPExcel_Worksheet $pValue = null, $pOverrideOld = false)
{
if (is_null($this->_worksheet)) { if (is_null($this->_worksheet)) {
// Add drawing to PHPExcel_Worksheet // Add drawing to PHPExcel_Worksheet
$this->_worksheet = $pValue; $this->_worksheet = $pValue;
@ -228,7 +235,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
while ($iterator->valid()) { while ($iterator->valid()) {
if ($iterator->current()->getHashCode() == $this->getHashCode()) { if ($iterator->current()->getHashCode() == $this->getHashCode()) {
$this->_worksheet->getDrawingCollection()->offsetUnset( $iterator->key() ); $this->_worksheet->getDrawingCollection()->offsetUnset($iterator->key());
$this->_worksheet = null; $this->_worksheet = null;
break; break;
} }
@ -248,7 +255,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getCoordinates() { public function getCoordinates()
{
return $this->_coordinates; return $this->_coordinates;
} }
@ -258,7 +266,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param string $pValue * @param string $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setCoordinates($pValue = 'A1') { public function setCoordinates($pValue = 'A1')
{
$this->_coordinates = $pValue; $this->_coordinates = $pValue;
return $this; return $this;
} }
@ -268,7 +277,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return int * @return int
*/ */
public function getOffsetX() { public function getOffsetX()
{
return $this->_offsetX; return $this->_offsetX;
} }
@ -278,7 +288,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setOffsetX($pValue = 0) { public function setOffsetX($pValue = 0)
{
$this->_offsetX = $pValue; $this->_offsetX = $pValue;
return $this; return $this;
} }
@ -288,7 +299,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return int * @return int
*/ */
public function getOffsetY() { public function getOffsetY()
{
return $this->_offsetY; return $this->_offsetY;
} }
@ -298,7 +310,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setOffsetY($pValue = 0) { public function setOffsetY($pValue = 0)
{
$this->_offsetY = $pValue; $this->_offsetY = $pValue;
return $this; return $this;
} }
@ -308,7 +321,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return int * @return int
*/ */
public function getWidth() { public function getWidth()
{
return $this->_width; return $this->_width;
} }
@ -318,7 +332,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setWidth($pValue = 0) { public function setWidth($pValue = 0)
{
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->_resizeProportional && $pValue != 0) {
$ratio = $this->_height / ($this->_width != 0 ? $this->_width : 1); $ratio = $this->_height / ($this->_width != 0 ? $this->_width : 1);
@ -336,7 +351,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return int * @return int
*/ */
public function getHeight() { public function getHeight()
{
return $this->_height; return $this->_height;
} }
@ -346,7 +362,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setHeight($pValue = 0) { public function setHeight($pValue = 0)
{
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->_resizeProportional && $pValue != 0) {
$ratio = $this->_width / ($this->_height != 0 ? $this->_height : 1); $ratio = $this->_width / ($this->_height != 0 ? $this->_height : 1);
@ -372,7 +389,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param int $height * @param int $height
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setWidthAndHeight($width = 0, $height = 0) { public function setWidthAndHeight($width = 0, $height = 0)
{
$xratio = $width / ($this->_width != 0 ? $this->_width : 1); $xratio = $width / ($this->_width != 0 ? $this->_width : 1);
$yratio = $height / ($this->_height != 0 ? $this->_height : 1); $yratio = $height / ($this->_height != 0 ? $this->_height : 1);
if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if ($this->_resizeProportional && !($width == 0 || $height == 0)) {
@ -396,7 +414,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getResizeProportional() { public function getResizeProportional()
{
return $this->_resizeProportional; return $this->_resizeProportional;
} }
@ -406,7 +425,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setResizeProportional($pValue = true) { public function setResizeProportional($pValue = true)
{
$this->_resizeProportional = $pValue; $this->_resizeProportional = $pValue;
return $this; return $this;
} }
@ -416,7 +436,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return int * @return int
*/ */
public function getRotation() { public function getRotation()
{
return $this->_rotation; return $this->_rotation;
} }
@ -426,7 +447,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setRotation($pValue = 0) { public function setRotation($pValue = 0)
{
$this->_rotation = $pValue; $this->_rotation = $pValue;
return $this; return $this;
} }
@ -436,7 +458,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet_Drawing_Shadow * @return PHPExcel_Worksheet_Drawing_Shadow
*/ */
public function getShadow() { public function getShadow()
{
return $this->_shadow; return $this->_shadow;
} }
@ -447,7 +470,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_BaseDrawing * @return PHPExcel_Worksheet_BaseDrawing
*/ */
public function setShadow(PHPExcel_Worksheet_Drawing_Shadow $pValue = null) { public function setShadow(PHPExcel_Worksheet_Drawing_Shadow $pValue = null)
{
$this->_shadow = $pValue; $this->_shadow = $pValue;
return $this; return $this;
} }
@ -457,26 +481,16 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
return md5( {
$this->_name return md5($this->_name.$this->_description.$this->_worksheet->getHashCode().$this->_coordinates.$this->_offsetX.$this->_offsetY.$this->_width.$this->_height.$this->_rotation.$this->_shadow->getHashCode().__CLASS__);
. $this->_description
. $this->_worksheet->getHashCode()
. $this->_coordinates
. $this->_offsetX
. $this->_offsetY
. $this->_width
. $this->_height
. $this->_rotation
. $this->_shadow->getHashCode()
. __CLASS__
);
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -92,11 +92,11 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
// Initialise values // Initialise values
$this->_path = ''; $this->_path = '';
$this->_name = ''; $this->_name = '';
$this->_offsetX = 0; $this->_offsetX = 0;
$this->_offsetY = 0; $this->_offsetY = 0;
$this->_width = 0; $this->_width = 0;
$this->_height = 0; $this->_height = 0;
$this->_resizeProportional = true; $this->_resizeProportional = true;
} }
/** /**
@ -104,7 +104,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return string * @return string
*/ */
public function getName() { public function getName()
{
return $this->_name; return $this->_name;
} }
@ -114,7 +115,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param string $pValue * @param string $pValue
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setName($pValue = '') { public function setName($pValue = '')
{
$this->_name = $pValue; $this->_name = $pValue;
return $this; return $this;
} }
@ -124,7 +126,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return int * @return int
*/ */
public function getOffsetX() { public function getOffsetX()
{
return $this->_offsetX; return $this->_offsetX;
} }
@ -134,7 +137,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setOffsetX($pValue = 0) { public function setOffsetX($pValue = 0)
{
$this->_offsetX = $pValue; $this->_offsetX = $pValue;
return $this; return $this;
} }
@ -144,7 +148,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return int * @return int
*/ */
public function getOffsetY() { public function getOffsetY()
{
return $this->_offsetY; return $this->_offsetY;
} }
@ -154,7 +159,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setOffsetY($pValue = 0) { public function setOffsetY($pValue = 0)
{
$this->_offsetY = $pValue; $this->_offsetY = $pValue;
return $this; return $this;
} }
@ -164,7 +170,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return int * @return int
*/ */
public function getWidth() { public function getWidth()
{
return $this->_width; return $this->_width;
} }
@ -174,7 +181,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setWidth($pValue = 0) { public function setWidth($pValue = 0)
{
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->_resizeProportional && $pValue != 0) {
$ratio = $this->_width / $this->_height; $ratio = $this->_width / $this->_height;
@ -192,7 +200,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return int * @return int
*/ */
public function getHeight() { public function getHeight()
{
return $this->_height; return $this->_height;
} }
@ -202,7 +211,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param int $pValue * @param int $pValue
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setHeight($pValue = 0) { public function setHeight($pValue = 0)
{
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->_resizeProportional && $pValue != 0) {
$ratio = $this->_width / $this->_height; $ratio = $this->_width / $this->_height;
@ -228,7 +238,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param int $height * @param int $height
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setWidthAndHeight($width = 0, $height = 0) { public function setWidthAndHeight($width = 0, $height = 0)
{
$xratio = $width / $this->_width; $xratio = $width / $this->_width;
$yratio = $height / $this->_height; $yratio = $height / $this->_height;
if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if ($this->_resizeProportional && !($width == 0 || $height == 0)) {
@ -248,7 +259,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return boolean * @return boolean
*/ */
public function getResizeProportional() { public function getResizeProportional()
{
return $this->_resizeProportional; return $this->_resizeProportional;
} }
@ -258,7 +270,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setResizeProportional($pValue = true) { public function setResizeProportional($pValue = true)
{
$this->_resizeProportional = $pValue; $this->_resizeProportional = $pValue;
return $this; return $this;
} }
@ -268,7 +281,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return string * @return string
*/ */
public function getFilename() { public function getFilename()
{
return basename($this->_path); return basename($this->_path);
} }
@ -277,7 +291,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return string * @return string
*/ */
public function getExtension() { public function getExtension()
{
$parts = explode(".", basename($this->_path)); $parts = explode(".", basename($this->_path));
return end($parts); return end($parts);
} }
@ -287,7 +302,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return string * @return string
*/ */
public function getPath() { public function getPath()
{
return $this->_path; return $this->_path;
} }
@ -299,7 +315,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_HeaderFooterDrawing * @return PHPExcel_Worksheet_HeaderFooterDrawing
*/ */
public function setPath($pValue = '', $pVerifyFile = true) { public function setPath($pValue = '', $pVerifyFile = true)
{
if ($pVerifyFile) { if ($pVerifyFile) {
if (file_exists($pValue)) { if (file_exists($pValue)) {
$this->_path = $pValue; $this->_path = $pValue;
@ -322,9 +339,10 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_path $this->_path
. $this->_name . $this->_name
. $this->_offsetX . $this->_offsetX
. $this->_offsetY . $this->_offsetY
@ -337,7 +355,8 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -81,10 +81,10 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_imageResource = null; $this->_imageResource = null;
$this->_renderingFunction = self::RENDERING_DEFAULT; $this->_renderingFunction = self::RENDERING_DEFAULT;
$this->_mimeType = self::MIMETYPE_DEFAULT; $this->_mimeType = self::MIMETYPE_DEFAULT;
$this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999)); $this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
// Initialize parent // Initialize parent
parent::__construct(); parent::__construct();
@ -95,7 +95,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* *
* @return resource * @return resource
*/ */
public function getImageResource() { public function getImageResource()
{
return $this->_imageResource; return $this->_imageResource;
} }
@ -105,7 +106,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* @param $value resource * @param $value resource
* @return PHPExcel_Worksheet_MemoryDrawing * @return PHPExcel_Worksheet_MemoryDrawing
*/ */
public function setImageResource($value = null) { public function setImageResource($value = null)
{
$this->_imageResource = $value; $this->_imageResource = $value;
if (!is_null($this->_imageResource)) { if (!is_null($this->_imageResource)) {
@ -121,7 +123,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* *
* @return string * @return string
*/ */
public function getRenderingFunction() { public function getRenderingFunction()
{
return $this->_renderingFunction; return $this->_renderingFunction;
} }
@ -131,7 +134,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* @param string $value * @param string $value
* @return PHPExcel_Worksheet_MemoryDrawing * @return PHPExcel_Worksheet_MemoryDrawing
*/ */
public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT) { public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT)
{
$this->_renderingFunction = $value; $this->_renderingFunction = $value;
return $this; return $this;
} }
@ -141,7 +145,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* *
* @return string * @return string
*/ */
public function getMimeType() { public function getMimeType()
{
return $this->_mimeType; return $this->_mimeType;
} }
@ -151,7 +156,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* @param string $value * @param string $value
* @return PHPExcel_Worksheet_MemoryDrawing * @return PHPExcel_Worksheet_MemoryDrawing
*/ */
public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT) { public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT)
{
$this->_mimeType = $value; $this->_mimeType = $value;
return $this; return $this;
} }
@ -161,7 +167,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* *
* @return string * @return string
*/ */
public function getIndexedFilename() { public function getIndexedFilename()
{
$extension = strtolower($this->getMimeType()); $extension = strtolower($this->getMimeType());
$extension = explode('/', $extension); $extension = explode('/', $extension);
$extension = $extension[1]; $extension = $extension[1];
@ -174,9 +181,10 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_renderingFunction $this->_renderingFunction
. $this->_mimeType . $this->_mimeType
. $this->_uniqueName . $this->_uniqueName
. parent::getHashCode() . parent::getHashCode()

View File

@ -89,7 +89,8 @@ class PHPExcel_Worksheet_PageMargins
* *
* @return double * @return double
*/ */
public function getLeft() { public function getLeft()
{
return $this->_left; return $this->_left;
} }
@ -99,7 +100,8 @@ class PHPExcel_Worksheet_PageMargins
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_PageMargins * @return PHPExcel_Worksheet_PageMargins
*/ */
public function setLeft($pValue) { public function setLeft($pValue)
{
$this->_left = $pValue; $this->_left = $pValue;
return $this; return $this;
} }
@ -109,7 +111,8 @@ class PHPExcel_Worksheet_PageMargins
* *
* @return double * @return double
*/ */
public function getRight() { public function getRight()
{
return $this->_right; return $this->_right;
} }
@ -119,7 +122,8 @@ class PHPExcel_Worksheet_PageMargins
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_PageMargins * @return PHPExcel_Worksheet_PageMargins
*/ */
public function setRight($pValue) { public function setRight($pValue)
{
$this->_right = $pValue; $this->_right = $pValue;
return $this; return $this;
} }
@ -129,7 +133,8 @@ class PHPExcel_Worksheet_PageMargins
* *
* @return double * @return double
*/ */
public function getTop() { public function getTop()
{
return $this->_top; return $this->_top;
} }
@ -139,7 +144,8 @@ class PHPExcel_Worksheet_PageMargins
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_PageMargins * @return PHPExcel_Worksheet_PageMargins
*/ */
public function setTop($pValue) { public function setTop($pValue)
{
$this->_top = $pValue; $this->_top = $pValue;
return $this; return $this;
} }
@ -149,7 +155,8 @@ class PHPExcel_Worksheet_PageMargins
* *
* @return double * @return double
*/ */
public function getBottom() { public function getBottom()
{
return $this->_bottom; return $this->_bottom;
} }
@ -159,7 +166,8 @@ class PHPExcel_Worksheet_PageMargins
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_PageMargins * @return PHPExcel_Worksheet_PageMargins
*/ */
public function setBottom($pValue) { public function setBottom($pValue)
{
$this->_bottom = $pValue; $this->_bottom = $pValue;
return $this; return $this;
} }
@ -169,7 +177,8 @@ class PHPExcel_Worksheet_PageMargins
* *
* @return double * @return double
*/ */
public function getHeader() { public function getHeader()
{
return $this->_header; return $this->_header;
} }
@ -179,7 +188,8 @@ class PHPExcel_Worksheet_PageMargins
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_PageMargins * @return PHPExcel_Worksheet_PageMargins
*/ */
public function setHeader($pValue) { public function setHeader($pValue)
{
$this->_header = $pValue; $this->_header = $pValue;
return $this; return $this;
} }
@ -189,7 +199,8 @@ class PHPExcel_Worksheet_PageMargins
* *
* @return double * @return double
*/ */
public function getFooter() { public function getFooter()
{
return $this->_footer; return $this->_footer;
} }
@ -199,7 +210,8 @@ class PHPExcel_Worksheet_PageMargins
* @param double $pValue * @param double $pValue
* @return PHPExcel_Worksheet_PageMargins * @return PHPExcel_Worksheet_PageMargins
*/ */
public function setFooter($pValue) { public function setFooter($pValue)
{
$this->_footer = $pValue; $this->_footer = $pValue;
return $this; return $this;
} }
@ -207,7 +219,8 @@ class PHPExcel_Worksheet_PageMargins
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -575,7 +575,7 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
return $this->_printArea; return $this->_printArea;
} }
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if (isset($printAreas[$index-1])) { if (isset($printAreas[$index-1])) {
return $printAreas[$index-1]; return $printAreas[$index-1];
} }
@ -595,7 +595,7 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
return !is_null($this->_printArea); return !is_null($this->_printArea);
} }
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
return isset($printAreas[$index-1]); return isset($printAreas[$index-1]);
} }
@ -612,10 +612,10 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
$this->_printArea = NULL; $this->_printArea = NULL;
} else { } else {
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if (isset($printAreas[$index-1])) { if (isset($printAreas[$index-1])) {
unset($printAreas[$index-1]); unset($printAreas[$index-1]);
$this->_printArea = implode(',',$printAreas); $this->_printArea = implode(',', $printAreas);
} }
} }
@ -656,29 +656,29 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
$this->_printArea = $value; $this->_printArea = $value;
} else { } else {
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if($index < 0) { if ($index < 0) {
$index = count($printAreas) - abs($index) + 1; $index = count($printAreas) - abs($index) + 1;
} }
if (($index <= 0) || ($index > count($printAreas))) { if (($index <= 0) || ($index > count($printAreas))) {
throw new PHPExcel_Exception('Invalid index for setting print range.'); throw new PHPExcel_Exception('Invalid index for setting print range.');
} }
$printAreas[$index-1] = $value; $printAreas[$index-1] = $value;
$this->_printArea = implode(',',$printAreas); $this->_printArea = implode(',', $printAreas);
} }
} elseif($method == self::SETPRINTRANGE_INSERT) { } elseif ($method == self::SETPRINTRANGE_INSERT) {
if ($index == 0) { if ($index == 0) {
$this->_printArea .= ($this->_printArea == '') ? $value : ','.$value; $this->_printArea .= ($this->_printArea == '') ? $value : ','.$value;
} else { } else {
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if($index < 0) { if ($index < 0) {
$index = abs($index) - 1; $index = abs($index) - 1;
} }
if ($index > count($printAreas)) { if ($index > count($printAreas)) {
throw new PHPExcel_Exception('Invalid index for setting print range.'); throw new PHPExcel_Exception('Invalid index for setting print range.');
} }
$printAreas = array_merge(array_slice($printAreas,0,$index),array($value),array_slice($printAreas,$index)); $printAreas = array_merge(array_slice($printAreas,0, $index),array($value),array_slice($printAreas, $index));
$this->_printArea = implode(',',$printAreas); $this->_printArea = implode(',', $printAreas);
} }
} else { } else {
throw new PHPExcel_Exception('Invalid method for setting print range.'); throw new PHPExcel_Exception('Invalid method for setting print range.');

View File

@ -86,7 +86,8 @@ class PHPExcel_Worksheet_SheetView
* *
* @return int * @return int
*/ */
public function getZoomScale() { public function getZoomScale()
{
return $this->_zoomScale; return $this->_zoomScale;
} }
@ -99,7 +100,8 @@ class PHPExcel_Worksheet_SheetView
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_SheetView * @return PHPExcel_Worksheet_SheetView
*/ */
public function setZoomScale($pValue = 100) { public function setZoomScale($pValue = 100)
{
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
// but it is apparently still able to handle any scale >= 1 // but it is apparently still able to handle any scale >= 1
if (($pValue >= 1) || is_null($pValue)) { if (($pValue >= 1) || is_null($pValue)) {
@ -115,7 +117,8 @@ class PHPExcel_Worksheet_SheetView
* *
* @return int * @return int
*/ */
public function getZoomScaleNormal() { public function getZoomScaleNormal()
{
return $this->_zoomScaleNormal; return $this->_zoomScaleNormal;
} }
@ -128,7 +131,8 @@ class PHPExcel_Worksheet_SheetView
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_SheetView * @return PHPExcel_Worksheet_SheetView
*/ */
public function setZoomScaleNormal($pValue = 100) { public function setZoomScaleNormal($pValue = 100)
{
if (($pValue >= 1) || is_null($pValue)) { if (($pValue >= 1) || is_null($pValue)) {
$this->_zoomScaleNormal = $pValue; $this->_zoomScaleNormal = $pValue;
} else { } else {
@ -142,7 +146,8 @@ class PHPExcel_Worksheet_SheetView
* *
* @return string * @return string
*/ */
public function getView() { public function getView()
{
return $this->_sheetviewType; return $this->_sheetviewType;
} }
@ -158,11 +163,12 @@ class PHPExcel_Worksheet_SheetView
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_SheetView * @return PHPExcel_Worksheet_SheetView
*/ */
public function setView($pValue = NULL) { public function setView($pValue = null)
// MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' {
// via the user interface // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface
if ($pValue === NULL) if ($pValue === null) {
$pValue = self::SHEETVIEW_NORMAL; $pValue = self::SHEETVIEW_NORMAL;
}
if (in_array($pValue, self::$_sheetViewTypes)) { if (in_array($pValue, self::$_sheetViewTypes)) {
$this->_sheetviewType = $pValue; $this->_sheetviewType = $pValue;
} else { } else {
@ -175,7 +181,8 @@ class PHPExcel_Worksheet_SheetView
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -98,7 +98,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex); $sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE); PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false);
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
@ -124,9 +124,9 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
$maxRow = $sheet->getHighestDataRow(); $maxRow = $sheet->getHighestDataRow();
// Write rows to file // Write rows to file
for($row = 1; $row <= $maxRow; ++$row) { for ($row = 1; $row <= $maxRow; ++$row) {
// Convert the row to an array... // Convert the row to an array...
$cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row,'', $this->_preCalculateFormulas); $cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row, '', $this->_preCalculateFormulas);
// ... and write to the file // ... and write to the file
$this->_writeLine($fileHandle, $cellsArray[0]); $this->_writeLine($fileHandle, $cellsArray[0]);
} }
@ -143,7 +143,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return string * @return string
*/ */
public function getDelimiter() { public function getDelimiter()
{
return $this->_delimiter; return $this->_delimiter;
} }
@ -153,7 +154,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param string $pValue Delimiter, defaults to , * @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setDelimiter($pValue = ',') { public function setDelimiter($pValue = ',')
{
$this->_delimiter = $pValue; $this->_delimiter = $pValue;
return $this; return $this;
} }
@ -163,7 +165,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return string * @return string
*/ */
public function getEnclosure() { public function getEnclosure()
{
return $this->_enclosure; return $this->_enclosure;
} }
@ -173,7 +176,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param string $pValue Enclosure, defaults to " * @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setEnclosure($pValue = '"') { public function setEnclosure($pValue = '"')
{
if ($pValue == '') { if ($pValue == '') {
$pValue = null; $pValue = null;
} }
@ -186,7 +190,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return string * @return string
*/ */
public function getLineEnding() { public function getLineEnding()
{
return $this->_lineEnding; return $this->_lineEnding;
} }
@ -196,7 +201,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL) * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setLineEnding($pValue = PHP_EOL) { public function setLineEnding($pValue = PHP_EOL)
{
$this->_lineEnding = $pValue; $this->_lineEnding = $pValue;
return $this; return $this;
} }
@ -206,7 +212,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return boolean * @return boolean
*/ */
public function getUseBOM() { public function getUseBOM()
{
return $this->_useBOM; return $this->_useBOM;
} }
@ -216,7 +223,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false * @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setUseBOM($pValue = false) { public function setUseBOM($pValue = false)
{
$this->_useBOM = $pValue; $this->_useBOM = $pValue;
return $this; return $this;
} }
@ -226,7 +234,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return boolean * @return boolean
*/ */
public function getExcelCompatibility() { public function getExcelCompatibility()
{
return $this->_excelCompatibility; return $this->_excelCompatibility;
} }
@ -237,7 +246,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* Note that this overrides other settings such as useBOM, enclosure and delimiter * Note that this overrides other settings such as useBOM, enclosure and delimiter
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setExcelCompatibility($pValue = false) { public function setExcelCompatibility($pValue = false)
{
$this->_excelCompatibility = $pValue; $this->_excelCompatibility = $pValue;
return $this; return $this;
} }
@ -247,7 +257,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return int * @return int
*/ */
public function getSheetIndex() { public function getSheetIndex()
{
return $this->_sheetIndex; return $this->_sheetIndex;
} }
@ -257,7 +268,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param int $pValue Sheet index * @param int $pValue Sheet index
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;
return $this; return $this;
} }
@ -269,7 +281,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param array $pValues Array containing values in a row * @param array $pValues Array containing values in a row
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeLine($pFileHandle = null, $pValues = null) { private function _writeLine($pFileHandle = null, $pValues = null)
{
if (is_array($pValues)) { if (is_array($pValues)) {
// No leading delimiter // No leading delimiter
$writeDelimiter = false; $writeDelimiter = false;
@ -301,5 +314,4 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer."); throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer.");
} }
} }
} }

View File

@ -125,18 +125,18 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
// Assign PHPExcel // Assign PHPExcel
$this->setPHPExcel($pPHPExcel); $this->setPHPExcel($pPHPExcel);
$writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable', $writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable',
'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes', 'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes',
'docprops' => 'PHPExcel_Writer_Excel2007_DocProps', 'docprops' => 'PHPExcel_Writer_Excel2007_DocProps',
'rels' => 'PHPExcel_Writer_Excel2007_Rels', 'rels' => 'PHPExcel_Writer_Excel2007_Rels',
'theme' => 'PHPExcel_Writer_Excel2007_Theme', 'theme' => 'PHPExcel_Writer_Excel2007_Theme',
'style' => 'PHPExcel_Writer_Excel2007_Style', 'style' => 'PHPExcel_Writer_Excel2007_Style',
'workbook' => 'PHPExcel_Writer_Excel2007_Workbook', 'workbook' => 'PHPExcel_Writer_Excel2007_Workbook',
'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet', 'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet',
'drawing' => 'PHPExcel_Writer_Excel2007_Drawing', 'drawing' => 'PHPExcel_Writer_Excel2007_Drawing',
'comments' => 'PHPExcel_Writer_Excel2007_Comments', 'comments' => 'PHPExcel_Writer_Excel2007_Comments',
'chart' => 'PHPExcel_Writer_Excel2007_Chart', 'chart' => 'PHPExcel_Writer_Excel2007_Chart',
'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA', 'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA',
'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon' 'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon'
); );
@ -163,7 +163,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @param string $pPartName Writer part name * @param string $pPartName Writer part name
* @return PHPExcel_Writer_Excel2007_WriterPart * @return PHPExcel_Writer_Excel2007_WriterPart
*/ */
public function getWriterPart($pPartName = '') { public function getWriterPart($pPartName = '')
{
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
return $this->_writerParts[strtolower($pPartName)]; return $this->_writerParts[strtolower($pPartName)];
} else { } else {
@ -179,7 +180,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
*/ */
public function save($pFilename = null) public function save($pFilename = null)
{ {
if ($this->_spreadSheet !== NULL) { if ($this->_spreadSheet !== null) {
// garbage collect // garbage collect
$this->_spreadSheet->garbageCollect(); $this->_spreadSheet->garbageCollect();
@ -193,7 +194,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog(); $saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog();
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE); PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(false);
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
@ -204,15 +205,15 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
// Create styles dictionaries // Create styles dictionaries
$this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) ); $this->_styleHashTable->addFromSource($this->getWriterPart('Style')->allStyles($this->_spreadSheet));
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) ); $this->_stylesConditionalHashTable->addFromSource($this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet));
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) ); $this->_fillHashTable->addFromSource($this->getWriterPart('Style')->allFills($this->_spreadSheet));
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) ); $this->_fontHashTable->addFromSource($this->getWriterPart('Style')->allFonts($this->_spreadSheet));
$this->_bordersHashTable->addFromSource( $this->getWriterPart('Style')->allBorders($this->_spreadSheet) ); $this->_bordersHashTable->addFromSource($this->getWriterPart('Style')->allBorders($this->_spreadSheet));
$this->_numFmtHashTable->addFromSource( $this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet) ); $this->_numFmtHashTable->addFromSource($this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet));
// Create drawing dictionary // Create drawing dictionary
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet) ); $this->_drawingHashTable->addFromSource($this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet));
// Create new ZIP file and open it for writing // Create new ZIP file and open it for writing
$zipClass = PHPExcel_Settings::getZipClass(); $zipClass = PHPExcel_Settings::getZipClass();
@ -235,60 +236,58 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
// Add [Content_Types].xml to ZIP file // Add [Content_Types].xml to ZIP file
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts)); $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts));
//if hasMacros, add the vbaProject.bin file, Certificate file(if exists) //if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
if($this->_spreadSheet->hasMacros()){ if ($this->_spreadSheet->hasMacros()) {
$macrosCode=$this->_spreadSheet->getMacrosCode(); $macrosCode=$this->_spreadSheet->getMacrosCode();
if(!is_null($macrosCode)){// we have the code ? if (!is_null($macrosCode)) {// we have the code ?
$objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin $objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin
if($this->_spreadSheet->hasMacrosCertificate()){//signed macros ? if ($this->_spreadSheet->hasMacrosCertificate()) {//signed macros ?
// Yes : add the certificate file and the related rels file // Yes : add the certificate file and the related rels file
$objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate()); $objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate());
$objZip->addFromString('xl/_rels/vbaProject.bin.rels', $objZip->addFromString('xl/_rels/vbaProject.bin.rels', $this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
$this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
} }
} }
} }
//a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels) //a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels)
if($this->_spreadSheet->hasRibbon()){ if ($this->_spreadSheet->hasRibbon()) {
$tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target'); $tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target');
$objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data')); $objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data'));
if($this->_spreadSheet->hasRibbonBinObjects()){ if ($this->_spreadSheet->hasRibbonBinObjects()) {
$tmpRootPath=dirname($tmpRibbonTarget).'/'; $tmpRootPath=dirname($tmpRibbonTarget).'/';
$ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write $ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write
foreach($ribbonBinObjects as $aPath=>$aContent){ foreach ($ribbonBinObjects as $aPath=>$aContent) {
$objZip->addFromString($tmpRootPath.$aPath, $aContent); $objZip->addFromString($tmpRootPath.$aPath, $aContent);
} }
//the rels for files //the rels for files
$objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels', $objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels', $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
$this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
} }
} }
// Add relationships to ZIP file // Add relationships to ZIP file
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet)); $objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet));
$objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet)); $objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet));
// Add document properties to ZIP file // Add document properties to ZIP file
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet)); $objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet)); $objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet); $customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
if ($customPropertiesPart !== NULL) { if ($customPropertiesPart !== null) {
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart); $objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
} }
// Add theme to ZIP file // Add theme to ZIP file
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet)); $objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
// Add string table to ZIP file // Add string table to ZIP file
$objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable)); $objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable));
// Add styles to ZIP file // Add styles to ZIP file
$objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet)); $objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet));
// Add workbook to ZIP file // Add workbook to ZIP file
$objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas)); $objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas));
$chartCount = 0; $chartCount = 0;
// Add worksheets // Add worksheets
@ -297,7 +296,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
if ($this->_includeCharts) { if ($this->_includeCharts) {
$charts = $this->_spreadSheet->getSheet($i)->getChartCollection(); $charts = $this->_spreadSheet->getSheet($i)->getChartCollection();
if (count($charts) > 0) { if (count($charts) > 0) {
foreach($charts as $chart) { foreach ($charts as $chart) {
$objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart)); $objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart));
$chartCount++; $chartCount++;
} }
@ -308,9 +307,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
$chartRef1 = $chartRef2 = 0; $chartRef1 = $chartRef2 = 0;
// Add worksheet relationships (drawings, ...) // Add worksheet relationships (drawings, ...)
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) { for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
// Add relationships // Add relationships
$objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts)); $objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts));
$drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection(); $drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection();
$drawingCount = count($drawings); $drawingCount = count($drawings);
@ -321,10 +319,10 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
// Add drawing and image relationship parts // Add drawing and image relationship parts
if (($drawingCount > 0) || ($chartCount > 0)) { if (($drawingCount > 0) || ($chartCount > 0)) {
// Drawing relationships // Drawing relationships
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i),$chartRef1, $this->_includeCharts)); $objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i), $chartRef1, $this->_includeCharts));
// Drawings // Drawings
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i),$chartRef2,$this->_includeCharts)); $objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i), $chartRef2, $this->_includeCharts));
} }
// Add comment relationship parts // Add comment relationship parts
@ -409,7 +407,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function getPHPExcel() { public function getPHPExcel()
{
if ($this->_spreadSheet !== null) { if ($this->_spreadSheet !== null) {
return $this->_spreadSheet; return $this->_spreadSheet;
} else { } else {
@ -424,7 +423,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
* @return PHPExcel_Writer_Excel2007 * @return PHPExcel_Writer_Excel2007
*/ */
public function setPHPExcel(PHPExcel $pPHPExcel = null) { public function setPHPExcel(PHPExcel $pPHPExcel = null)
{
$this->_spreadSheet = $pPHPExcel; $this->_spreadSheet = $pPHPExcel;
return $this; return $this;
} }
@ -434,7 +434,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return string[] * @return string[]
*/ */
public function getStringTable() { public function getStringTable()
{
return $this->_stringTable; return $this->_stringTable;
} }
@ -443,7 +444,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getStyleHashTable() { public function getStyleHashTable()
{
return $this->_styleHashTable; return $this->_styleHashTable;
} }
@ -452,7 +454,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getStylesConditionalHashTable() { public function getStylesConditionalHashTable()
{
return $this->_stylesConditionalHashTable; return $this->_stylesConditionalHashTable;
} }
@ -461,7 +464,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getFillHashTable() { public function getFillHashTable()
{
return $this->_fillHashTable; return $this->_fillHashTable;
} }
@ -470,7 +474,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getFontHashTable() { public function getFontHashTable()
{
return $this->_fontHashTable; return $this->_fontHashTable;
} }
@ -479,7 +484,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getBordersHashTable() { public function getBordersHashTable()
{
return $this->_bordersHashTable; return $this->_bordersHashTable;
} }
@ -488,7 +494,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getNumFmtHashTable() { public function getNumFmtHashTable()
{
return $this->_numFmtHashTable; return $this->_numFmtHashTable;
} }
@ -497,7 +504,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getDrawingHashTable() { public function getDrawingHashTable()
{
return $this->_drawingHashTable; return $this->_drawingHashTable;
} }
@ -506,7 +514,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return boolean * @return boolean
*/ */
public function getOffice2003Compatibility() { public function getOffice2003Compatibility()
{
return $this->_office2003compatibility; return $this->_office2003compatibility;
} }
@ -516,9 +525,9 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @param boolean $pValue Office2003 compatibility? * @param boolean $pValue Office2003 compatibility?
* @return PHPExcel_Writer_Excel2007 * @return PHPExcel_Writer_Excel2007
*/ */
public function setOffice2003Compatibility($pValue = false) { public function setOffice2003Compatibility($pValue = false)
{
$this->_office2003compatibility = $pValue; $this->_office2003compatibility = $pValue;
return $this; return $this;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Comments cache // Comments cache
$comments = $pWorksheet->getComments(); $comments = $pWorksheet->getComments();
@ -133,7 +133,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Comments cache // Comments cache
$comments = $pWorksheet->getComments(); $comments = $pWorksheet->getComments();

View File

@ -43,7 +43,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = FALSE) public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -54,87 +54,59 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Types // Types
$objWriter->startElement('Types'); $objWriter->startElement('Types');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
// Theme // Theme
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml');
$objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
);
// Styles // Styles
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml');
$objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
);
// Rels // Rels
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml');
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
);
// XML // XML
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'xml', 'application/xml');
$objWriter, 'xml', 'application/xml'
);
// VML // VML
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing');
$objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'
);
// Workbook // Workbook
if($pPHPExcel->hasMacros()){ //Macros in workbook ? if ($pPHPExcel->hasMacros()) { //Macros in workbook ?
// Yes : not standard content but "macroEnabled" // Yes : not standard content but "macroEnabled"
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml');
$objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml'
);
//... and define a new type for the VBA project //... and define a new type for the VBA project
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.ms-office.vbaProject');
$objWriter, 'bin', 'application/vnd.ms-office.vbaProject' if ($pPHPExcel->hasMacrosCertificate()) {// signed macros ?
);
if($pPHPExcel->hasMacrosCertificate()){// signed macros ?
// Yes : add needed information // Yes : add needed information
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature');
$objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature'
);
} }
}else{// no macros in workbook, so standard type } else {// no macros in workbook, so standard type
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml');
$objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
);
} }
// DocProps // DocProps
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml');
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
);
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml');
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
);
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
if (!empty($customPropertyList)) { if (!empty($customPropertyList)) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml');
$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
);
} }
// Worksheets // Worksheets
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml');
$objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
);
} }
// Shared strings // Shared strings
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml');
$objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
);
// Add worksheet relationship content types // Add worksheet relationship content types
$chart = 1; $chart = 1;
@ -145,17 +117,13 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
// We need a drawing relationship for the worksheet if we have either drawings or charts // We need a drawing relationship for the worksheet if we have either drawings or charts
if (($drawingCount > 0) || ($chartCount > 0)) { if (($drawingCount > 0) || ($chartCount > 0)) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml');
$objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml'
);
} }
// If we have charts, then we need a chart relationship for every individual chart // If we have charts, then we need a chart relationship for every individual chart
if ($chartCount > 0) { if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) { for ($c = 0; $c < $chartCount; ++$c) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml');
$objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
);
} }
} }
} }
@ -163,9 +131,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
// Comments // Comments
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
if (count($pPHPExcel->getSheet($i)->getComments()) > 0) { if (count($pPHPExcel->getSheet($i)->getComments()) > 0) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml');
$objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
);
} }
} }
@ -188,33 +154,27 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
} }
if (!isset( $aMediaContentTypes[$extension]) ) { if (!isset( $aMediaContentTypes[$extension]) ) {
$aMediaContentTypes[$extension] = $mimeType; $aMediaContentTypes[$extension] = $mimeType;
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, $extension, $mimeType);
$objWriter, $extension, $mimeType
);
} }
} }
if($pPHPExcel->hasRibbonBinObjects()){//Some additional objects in the ribbon ? if ($pPHPExcel->hasRibbonBinObjects()) {//Some additional objects in the ribbon ?
//we need to write "Extension" but not already write for media content //we need to write "Extension" but not already write for media content
$tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes)); $tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
foreach($tabRibbonTypes as $aRibbonType){ foreach ($tabRibbonTypes as $aRibbonType) {
$mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor $mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, $aRibbonType, $mimeType);
$objWriter, $aRibbonType, $mimeType }
);
}
} }
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) { if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) { foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) {
if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) { if (!isset( $aMediaContentTypes[strtolower($image->getExtension())])) {
$aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() ); $aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType($image->getPath());
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]);
$objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]
);
} }
} }
} }
@ -256,8 +216,8 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
if ($pPartname != '' && $pContentType != '') { if ($pPartname != '' && $pContentType != '') {
// Write content type // Write content type
$objWriter->startElement('Default'); $objWriter->startElement('Default');
$objWriter->writeAttribute('Extension', $pPartname); $objWriter->writeAttribute('Extension', $pPartname);
$objWriter->writeAttribute('ContentType', $pContentType); $objWriter->writeAttribute('ContentType', $pContentType);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
throw new PHPExcel_Writer_Exception("Invalid parameters passed."); throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
@ -277,8 +237,8 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
if ($pPartname != '' && $pContentType != '') { if ($pPartname != '' && $pContentType != '') {
// Write content type // Write content type
$objWriter->startElement('Override'); $objWriter->startElement('Override');
$objWriter->writeAttribute('PartName', $pPartname); $objWriter->writeAttribute('PartName', $pPartname);
$objWriter->writeAttribute('ContentType', $pContentType); $objWriter->writeAttribute('ContentType', $pContentType);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
throw new PHPExcel_Writer_Exception("Invalid parameters passed."); throw new PHPExcel_Writer_Exception("Invalid parameters passed.");

View File

@ -35,7 +35,7 @@
*/ */
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
{ {
/** /**
* Write docProps/app.xml to XML format * Write docProps/app.xml to XML format
* *
* @param PHPExcel $pPHPExcel * @param PHPExcel $pPHPExcel
@ -53,78 +53,78 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Properties // Properties
$objWriter->startElement('Properties'); $objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
// Application // Application
$objWriter->writeElement('Application', 'Microsoft Excel'); $objWriter->writeElement('Application', 'Microsoft Excel');
// DocSecurity // DocSecurity
$objWriter->writeElement('DocSecurity', '0'); $objWriter->writeElement('DocSecurity', '0');
// ScaleCrop // ScaleCrop
$objWriter->writeElement('ScaleCrop', 'false'); $objWriter->writeElement('ScaleCrop', 'false');
// HeadingPairs // HeadingPairs
$objWriter->startElement('HeadingPairs'); $objWriter->startElement('HeadingPairs');
// Vector // Vector
$objWriter->startElement('vt:vector'); $objWriter->startElement('vt:vector');
$objWriter->writeAttribute('size', '2'); $objWriter->writeAttribute('size', '2');
$objWriter->writeAttribute('baseType', 'variant'); $objWriter->writeAttribute('baseType', 'variant');
// Variant // Variant
$objWriter->startElement('vt:variant'); $objWriter->startElement('vt:variant');
$objWriter->writeElement('vt:lpstr', 'Worksheets'); $objWriter->writeElement('vt:lpstr', 'Worksheets');
$objWriter->endElement(); $objWriter->endElement();
// Variant // Variant
$objWriter->startElement('vt:variant'); $objWriter->startElement('vt:variant');
$objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount()); $objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// TitlesOfParts // TitlesOfParts
$objWriter->startElement('TitlesOfParts'); $objWriter->startElement('TitlesOfParts');
// Vector // Vector
$objWriter->startElement('vt:vector'); $objWriter->startElement('vt:vector');
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount()); $objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
$objWriter->writeAttribute('baseType', 'lpstr'); $objWriter->writeAttribute('baseType', 'lpstr');
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle()); $objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
} }
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// Company // Company
$objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany()); $objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany());
// Company // Company
$objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager()); $objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager());
// LinksUpToDate // LinksUpToDate
$objWriter->writeElement('LinksUpToDate', 'false'); $objWriter->writeElement('LinksUpToDate', 'false');
// SharedDoc // SharedDoc
$objWriter->writeElement('SharedDoc', 'false'); $objWriter->writeElement('SharedDoc', 'false');
// HyperlinksChanged // HyperlinksChanged
$objWriter->writeElement('HyperlinksChanged', 'false'); $objWriter->writeElement('HyperlinksChanged', 'false');
// AppVersion // AppVersion
$objWriter->writeElement('AppVersion', '12.0000'); $objWriter->writeElement('AppVersion', '12.0000');
$objWriter->endElement(); $objWriter->endElement();
@ -150,48 +150,48 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties // cp:coreProperties
$objWriter->startElement('cp:coreProperties'); $objWriter->startElement('cp:coreProperties');
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
// dc:creator // dc:creator
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator()); $objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
// cp:lastModifiedBy // cp:lastModifiedBy
$objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy()); $objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy());
// dcterms:created // dcterms:created
$objWriter->startElement('dcterms:created'); $objWriter->startElement('dcterms:created');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated())); $objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
$objWriter->endElement(); $objWriter->endElement();
// dcterms:modified // dcterms:modified
$objWriter->startElement('dcterms:modified'); $objWriter->startElement('dcterms:modified');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified())); $objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
$objWriter->endElement(); $objWriter->endElement();
// dc:title // dc:title
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle()); $objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
// dc:description // dc:description
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription()); $objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
// dc:subject // dc:subject
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject()); $objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
// cp:keywords // cp:keywords
$objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords()); $objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords());
// cp:category // cp:category
$objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory()); $objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory());
$objWriter->endElement(); $objWriter->endElement();
@ -222,51 +222,50 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties // cp:coreProperties
$objWriter->startElement('Properties'); $objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
foreach($customPropertyList as $key => $customProperty) { foreach ($customPropertyList as $key => $customProperty) {
$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty); $propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty); $propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
$objWriter->startElement('property'); $objWriter->startElement('property');
$objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}'); $objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
$objWriter->writeAttribute('pid', $key+2); $objWriter->writeAttribute('pid', $key+2);
$objWriter->writeAttribute('name', $customProperty); $objWriter->writeAttribute('name', $customProperty);
switch($propertyType) { switch ($propertyType) {
case 'i' : case 'i' :
$objWriter->writeElement('vt:i4', $propertyValue); $objWriter->writeElement('vt:i4', $propertyValue);
break; break;
case 'f' : case 'f' :
$objWriter->writeElement('vt:r8', $propertyValue); $objWriter->writeElement('vt:r8', $propertyValue);
break; break;
case 'b' : case 'b' :
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false'); $objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
break; break;
case 'd' : case 'd' :
$objWriter->startElement('vt:filetime'); $objWriter->startElement('vt:filetime');
$objWriter->writeRawData(date(DATE_W3C, $propertyValue)); $objWriter->writeRawData(date(DATE_W3C, $propertyValue));
$objWriter->endElement(); $objWriter->endElement();
break; break;
default : default :
$objWriter->writeElement('vt:lpwstr', $propertyValue); $objWriter->writeElement('vt:lpwstr', $propertyValue);
break; break;
}
$objWriter->endElement();
} }
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
// Return // Return
return $objWriter->getData(); return $objWriter->getData();
} }
} }

View File

@ -55,7 +55,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// xdr:wsDr // xdr:wsDr
$objWriter->startElement('xdr:wsDr'); $objWriter->startElement('xdr:wsDr');
@ -397,7 +397,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Header/footer images // Header/footer images
$images = $pWorksheet->getHeaderFooter()->getImages(); $images = $pWorksheet->getHeaderFooter()->getImages();

View File

@ -53,56 +53,56 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
if (!empty($customPropertyList)) { if (!empty($customPropertyList)) {
// Relationship docProps/app.xml
$this->_writeRelationship(
$objWriter,
4,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
'docProps/custom.xml'
);
}
// Relationship docProps/app.xml // Relationship docProps/app.xml
$this->_writeRelationship( $this->_writeRelationship(
$objWriter, $objWriter,
3, 4,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
'docProps/app.xml' 'docProps/custom.xml'
); );
// Relationship docProps/core.xml }
$this->_writeRelationship(
$objWriter,
2,
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
'docProps/core.xml'
);
// Relationship xl/workbook.xml // Relationship docProps/app.xml
$this->_writeRelationship( $this->_writeRelationship(
$objWriter,
3,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
'docProps/app.xml'
);
// Relationship docProps/core.xml
$this->_writeRelationship(
$objWriter,
2,
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
'docProps/core.xml'
);
// Relationship xl/workbook.xml
$this->_writeRelationship(
$objWriter,
1,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
'xl/workbook.xml'
);
// a custom UI in workbook ?
if ($pPHPExcel->hasRibbon()) {
$this->_writeRelationShip(
$objWriter, $objWriter,
1, 5,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
'xl/workbook.xml' $pPHPExcel->getRibbonXMLData('target')
); );
// a custom UI in workbook ? }
if($pPHPExcel->hasRibbon()){
$this->_writeRelationShip(
$objWriter,
5,
'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
$pPHPExcel->getRibbonXMLData('target')
);
}
$objWriter->endElement(); $objWriter->endElement();
@ -128,57 +128,57 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Relationship styles.xml // Relationship styles.xml
$this->_writeRelationship(
$objWriter,
1,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
'styles.xml'
);
// Relationship theme/theme1.xml
$this->_writeRelationship(
$objWriter,
2,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
'theme/theme1.xml'
);
// Relationship sharedStrings.xml
$this->_writeRelationship(
$objWriter,
3,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
'sharedStrings.xml'
);
// Relationships with sheets
$sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
$this->_writeRelationship( $this->_writeRelationship(
$objWriter, $objWriter,
1, ($i + 1 + 3),
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
'styles.xml' 'worksheets/sheet' . ($i + 1) . '.xml'
); );
}
// Relationship theme/theme1.xml // Relationships for vbaProject if needed
$this->_writeRelationship( // id : just after the last sheet
if ($pPHPExcel->hasMacros()) {
$this->_writeRelationShip(
$objWriter, $objWriter,
2, ($i + 1 + 3),
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
'theme/theme1.xml' 'vbaProject.bin'
); );
++$i;//increment i if needed for an another relation
// Relationship sharedStrings.xml }
$this->_writeRelationship(
$objWriter,
3,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
'sharedStrings.xml'
);
// Relationships with sheets
$sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
$this->_writeRelationship(
$objWriter,
($i + 1 + 3),
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
'worksheets/sheet' . ($i + 1) . '.xml'
);
}
// Relationships for vbaProject if needed
// id : just after the last sheet
if($pPHPExcel->hasMacros()){
$this->_writeRelationShip(
$objWriter,
($i + 1 + 3),
'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
'vbaProject.bin'
);
++$i;//increment i if needed for an another relation
}
$objWriter->endElement(); $objWriter->endElement();
@ -199,7 +199,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE) public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -210,35 +210,35 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Write drawing relationships? // Write drawing relationships?
$d = 0; $d = 0;
if ($includeCharts) { if ($includeCharts) {
$charts = $pWorksheet->getChartCollection(); $charts = $pWorksheet->getChartCollection();
} else { } else {
$charts = array(); $charts = array();
} }
if (($pWorksheet->getDrawingCollection()->count() > 0) || if (($pWorksheet->getDrawingCollection()->count() > 0) ||
(count($charts) > 0)) { (count($charts) > 0)) {
$this->_writeRelationship( $this->_writeRelationship(
$objWriter, $objWriter,
++$d, ++$d,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
'../drawings/drawing' . $pWorksheetId . '.xml' '../drawings/drawing' . $pWorksheetId . '.xml'
); );
} }
// Write chart relationships? // Write chart relationships?
// $chartCount = 0; // $chartCount = 0;
// $charts = $pWorksheet->getChartCollection(); // $charts = $pWorksheet->getChartCollection();
// echo 'Chart Rels: ' , count($charts) , '<br />'; // echo 'Chart Rels: ' , count($charts) , '<br />';
// if (count($charts) > 0) { // if (count($charts) > 0) {
// foreach($charts as $chart) { // foreach ($charts as $chart) {
// $this->_writeRelationship( // $this->_writeRelationship(
// $objWriter, // $objWriter,
// ++$d, // ++$d,
@ -248,50 +248,50 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
// } // }
// } // }
// //
// Write hyperlink relationships? // Write hyperlink relationships?
$i = 1; $i = 1;
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) { foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
if (!$hyperlink->isInternal()) { 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( $this->_writeRelationship(
$objWriter, $objWriter,
'_comments_vml' . $i, '_hyperlink_' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
'../drawings/vmlDrawing' . $pWorksheetId . '.vml' $hyperlink->getUrl(),
'External'
); );
$this->_writeRelationship( ++$i;
$objWriter,
'_comments' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
'../comments' . $pWorksheetId . '.xml'
);
} }
}
// Write header/footer relationship? // Write comments relationship?
$i = 1; $i = 1;
if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) { if (count($pWorksheet->getComments()) > 0) {
$this->_writeRelationship( $this->_writeRelationship(
$objWriter, $objWriter,
'_headerfooter_vml' . $i, '_comments_vml' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
'../drawings/vmlDrawingHF' . $pWorksheetId . '.vml' '../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(); $objWriter->endElement();
@ -308,7 +308,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE) public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -319,45 +319,45 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Loop through images and write relationships // Loop through images and write relationships
$i = 1; $i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator(); $iterator = $pWorksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) { while ($iterator->valid()) {
if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing
|| $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) { || $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) {
// Write relationship for image drawing // Write relationship for image drawing
$this->_writeRelationship(
$objWriter,
$i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
);
}
$iterator->next();
++$i;
}
if ($includeCharts) {
// Loop through charts and write relationships
$chartCount = $pWorksheet->getChartCount();
if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) {
$this->_writeRelationship( $this->_writeRelationship(
$objWriter, $objWriter,
$i, $i++,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename()) '../charts/chart' . ++$chartRef . '.xml'
); );
} }
$iterator->next();
++$i;
}
if ($includeCharts) {
// Loop through charts and write relationships
$chartCount = $pWorksheet->getChartCount();
if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) {
$this->_writeRelationship(
$objWriter,
$i++,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
'../charts/chart' . ++$chartRef . '.xml'
);
}
}
} }
}
$objWriter->endElement(); $objWriter->endElement();
@ -383,22 +383,22 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Loop through images and write relationships // Loop through images and write relationships
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) { foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
// Write relationship for image drawing // Write relationship for image drawing
$this->_writeRelationship( $this->_writeRelationship(
$objWriter, $objWriter,
$key, $key,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
'../media/' . $value->getIndexedFilename() '../media/' . $value->getIndexedFilename()
); );
} }
$objWriter->endElement(); $objWriter->endElement();
@ -421,12 +421,12 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
if ($pType != '' && $pTarget != '') { if ($pType != '' && $pTarget != '') {
// Write relationship // Write relationship
$objWriter->startElement('Relationship'); $objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', 'rId' . $pId); $objWriter->writeAttribute('Id', 'rId' . $pId);
$objWriter->writeAttribute('Type', $pType); $objWriter->writeAttribute('Type', $pType);
$objWriter->writeAttribute('Target', $pTarget); $objWriter->writeAttribute('Target', $pTarget);
if ($pTargetMode != '') { if ($pTargetMode != '') {
$objWriter->writeAttribute('TargetMode', $pTargetMode); $objWriter->writeAttribute('TargetMode', $pTargetMode);
} }
$objWriter->endElement(); $objWriter->endElement();

View File

@ -42,7 +42,8 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRibbonRelationships(PHPExcel $pPHPExcel = null){ public function writeRibbonRelationships(PHPExcel $pPHPExcel = null)
{
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -52,14 +53,14 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$localRels=$pPHPExcel->getRibbonBinObjects('names'); $localRels = $pPHPExcel->getRibbonBinObjects('names');
if(is_array($localRels)){ if (is_array($localRels)) {
foreach($localRels as $aId=>$aTarget){ foreach ($localRels as $aId => $aTarget) {
$objWriter->startElement('Relationship'); $objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', $aId); $objWriter->writeAttribute('Id', $aId);
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'); $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
@ -71,7 +72,5 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
// Return // Return
return $objWriter->getData(); return $objWriter->getData();
} }
} }

View File

@ -42,7 +42,8 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeVBARelationships(PHPExcel $pPHPExcel = null){ public function writeVBARelationships(PHPExcel $pPHPExcel = null)
{
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -52,7 +53,7 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
@ -68,5 +69,4 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
return $objWriter->getData(); return $objWriter->getData();
} }
} }

View File

@ -45,14 +45,14 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/ */
public function createStringTable($pSheet = null, $pExistingTable = null) public function createStringTable($pSheet = null, $pExistingTable = null)
{ {
if ($pSheet !== NULL) { if ($pSheet !== null) {
// Create string lookup table // Create string lookup table
$aStringTable = array(); $aStringTable = array();
$cellCollection = null; $cellCollection = null;
$aFlippedStringTable = null; // For faster lookup $aFlippedStringTable = null; // For faster lookup
// Is an existing table given? // Is an existing table given?
if (($pExistingTable !== NULL) && is_array($pExistingTable)) { if (($pExistingTable !== null) && is_array($pExistingTable)) {
$aStringTable = $pExistingTable; $aStringTable = $pExistingTable;
} }
@ -64,14 +64,14 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$cell = $pSheet->getCell($cellID); $cell = $pSheet->getCell($cellID);
$cellValue = $cell->getValue(); $cellValue = $cell->getValue();
if (!is_object($cellValue) && if (!is_object($cellValue) &&
($cellValue !== NULL) && ($cellValue !== null) &&
$cellValue !== '' && $cellValue !== '' &&
!isset($aFlippedStringTable[$cellValue]) && !isset($aFlippedStringTable[$cellValue]) &&
($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) { ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) {
$aStringTable[] = $cellValue; $aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue] = true; $aFlippedStringTable[$cellValue] = true;
} elseif ($cellValue instanceof PHPExcel_RichText && } elseif ($cellValue instanceof PHPExcel_RichText &&
($cellValue !== NULL) && ($cellValue !== null) &&
!isset($aFlippedStringTable[$cellValue->getHashCode()])) { !isset($aFlippedStringTable[$cellValue->getHashCode()])) {
$aStringTable[] = $cellValue; $aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue->getHashCode()] = true; $aFlippedStringTable[$cellValue->getHashCode()] = true;
@ -94,7 +94,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/ */
public function writeStringTable($pStringTable = null) public function writeStringTable($pStringTable = null)
{ {
if ($pStringTable !== NULL) { if ($pStringTable !== null) {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -104,32 +104,32 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// String table // String table
$objWriter->startElement('sst'); $objWriter->startElement('sst');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('uniqueCount', count($pStringTable)); $objWriter->writeAttribute('uniqueCount', count($pStringTable));
// Loop through string table // Loop through string table
foreach ($pStringTable as $textElement) { foreach ($pStringTable as $textElement) {
$objWriter->startElement('si'); $objWriter->startElement('si');
if (! $textElement instanceof PHPExcel_RichText) {
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement );
$objWriter->startElement('t');
if ($textToWrite !== trim($textToWrite)) {
$objWriter->writeAttribute('xml:space', 'preserve');
}
$objWriter->writeRawData($textToWrite);
$objWriter->endElement();
} else if ($textElement instanceof PHPExcel_RichText) {
$this->writeRichText($objWriter, $textElement);
}
if (! $textElement instanceof PHPExcel_RichText) {
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML($textElement);
$objWriter->startElement('t');
if ($textToWrite !== trim($textToWrite)) {
$objWriter->writeAttribute('xml:space', 'preserve');
}
$objWriter->writeRawData($textToWrite);
$objWriter->endElement(); $objWriter->endElement();
} else if ($textElement instanceof PHPExcel_RichText) {
$this->writeRichText($objWriter, $textElement);
} }
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
// Return // Return
@ -147,76 +147,78 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
* @param string $prefix Optional Namespace prefix * @param string $prefix Optional Namespace prefix
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL) public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix = null)
{ {
if ($prefix !== NULL) if ($prefix !== null) {
$prefix .= ':'; $prefix .= ':';
}
// Loop through rich text elements // Loop through rich text elements
$elements = $pRichText->getRichTextElements(); $elements = $pRichText->getRichTextElements();
foreach ($elements as $element) { foreach ($elements as $element) {
// r // r
$objWriter->startElement($prefix.'r'); $objWriter->startElement($prefix.'r');
// rPr
if ($element instanceof PHPExcel_RichText_Run) {
// rPr // rPr
if ($element instanceof PHPExcel_RichText_Run) { $objWriter->startElement($prefix.'rPr');
// rPr
$objWriter->startElement($prefix.'rPr');
// rFont // rFont
$objWriter->startElement($prefix.'rFont'); $objWriter->startElement($prefix.'rFont');
$objWriter->writeAttribute('val', $element->getFont()->getName()); $objWriter->writeAttribute('val', $element->getFont()->getName());
$objWriter->endElement(); $objWriter->endElement();
// Bold // Bold
$objWriter->startElement($prefix.'b'); $objWriter->startElement($prefix.'b');
$objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false')); $objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false'));
$objWriter->endElement(); $objWriter->endElement();
// Italic // Italic
$objWriter->startElement($prefix.'i'); $objWriter->startElement($prefix.'i');
$objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false')); $objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false'));
$objWriter->endElement(); $objWriter->endElement();
// Superscript / subscript
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
$objWriter->startElement($prefix.'vertAlign');
if ($element->getFont()->getSuperScript()) {
$objWriter->writeAttribute('val', 'superscript');
} else if ($element->getFont()->getSubScript()) {
$objWriter->writeAttribute('val', 'subscript');
}
$objWriter->endElement();
}
// Strikethrough
$objWriter->startElement($prefix.'strike');
$objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false'));
$objWriter->endElement();
// Color
$objWriter->startElement($prefix.'color');
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
$objWriter->endElement();
// Size
$objWriter->startElement($prefix.'sz');
$objWriter->writeAttribute('val', $element->getFont()->getSize());
$objWriter->endElement();
// Underline
$objWriter->startElement($prefix.'u');
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
$objWriter->endElement();
// Superscript / subscript
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
$objWriter->startElement($prefix.'vertAlign');
if ($element->getFont()->getSuperScript()) {
$objWriter->writeAttribute('val', 'superscript');
} else if ($element->getFont()->getSubScript()) {
$objWriter->writeAttribute('val', 'subscript');
}
$objWriter->endElement(); $objWriter->endElement();
} }
// t // Strikethrough
$objWriter->startElement($prefix.'t'); $objWriter->startElement($prefix.'strike');
$objWriter->writeAttribute('xml:space', 'preserve'); $objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false'));
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
$objWriter->endElement(); $objWriter->endElement();
// Color
$objWriter->startElement($prefix.'color');
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
$objWriter->endElement();
// Size
$objWriter->startElement($prefix.'sz');
$objWriter->writeAttribute('val', $element->getFont()->getSize());
$objWriter->endElement();
// Underline
$objWriter->startElement($prefix.'u');
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
$objWriter->endElement();
$objWriter->endElement();
}
// t
$objWriter->startElement($prefix.'t');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
$objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
} }
@ -229,7 +231,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
* @param string $prefix Optional Namespace prefix * @param string $prefix Optional Namespace prefix
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL) public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix = null)
{ {
if (!$pRichText instanceof PHPExcel_RichText) { if (!$pRichText instanceof PHPExcel_RichText) {
$textRun = $pRichText; $textRun = $pRichText;
@ -237,41 +239,43 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$pRichText->createTextRun($textRun); $pRichText->createTextRun($textRun);
} }
if ($prefix !== NULL) if ($prefix !== null) {
$prefix .= ':'; $prefix .= ':';
}
// Loop through rich text elements // Loop through rich text elements
$elements = $pRichText->getRichTextElements(); $elements = $pRichText->getRichTextElements();
foreach ($elements as $element) { foreach ($elements as $element) {
// r // r
$objWriter->startElement($prefix.'r'); $objWriter->startElement($prefix.'r');
// rPr // rPr
$objWriter->startElement($prefix.'rPr'); $objWriter->startElement($prefix.'rPr');
// Bold // Bold
$objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 1 : 0)); $objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 1 : 0));
// Italic // Italic
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0)); $objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0));
// Underline // Underline
$underlineType = $element->getFont()->getUnderline(); $underlineType = $element->getFont()->getUnderline();
switch($underlineType) { switch ($underlineType) {
case 'single' : case 'single' :
$underlineType = 'sng'; $underlineType = 'sng';
break; break;
case 'double' : case 'double' :
$underlineType = 'dbl'; $underlineType = 'dbl';
break; break;
} }
$objWriter->writeAttribute('u', $underlineType); $objWriter->writeAttribute('u', $underlineType);
// Strikethrough // Strikethrough
$objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike')); $objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
// rFont // rFont
$objWriter->startElement($prefix.'latin'); $objWriter->startElement($prefix.'latin');
$objWriter->writeAttribute('typeface', $element->getFont()->getName()); $objWriter->writeAttribute('typeface', $element->getFont()->getName());
$objWriter->endElement(); $objWriter->endElement();
// Superscript / subscript // Superscript / subscript
// if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) { // if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
// $objWriter->startElement($prefix.'vertAlign'); // $objWriter->startElement($prefix.'vertAlign');
// if ($element->getFont()->getSuperScript()) { // if ($element->getFont()->getSuperScript()) {
@ -282,13 +286,13 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
// $objWriter->endElement(); // $objWriter->endElement();
// } // }
// //
$objWriter->endElement(); $objWriter->endElement();
// t // t
$objWriter->startElement($prefix.'t'); $objWriter->startElement($prefix.'t');
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains // $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() )); $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($element->getText()));
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }

View File

@ -53,111 +53,111 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// styleSheet // styleSheet
$objWriter->startElement('styleSheet'); $objWriter->startElement('styleSheet');
$objWriter->writeAttribute('xml:space', 'preserve'); $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
// numFmts // numFmts
$objWriter->startElement('numFmts'); $objWriter->startElement('numFmts');
$objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count());
// numFmt // numFmt
for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) {
$this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i); $this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i);
} }
$objWriter->endElement(); $objWriter->endElement();
// fonts // fonts
$objWriter->startElement('fonts'); $objWriter->startElement('fonts');
$objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count());
// font // font
for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) {
$this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i)); $this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i));
} }
$objWriter->endElement(); $objWriter->endElement();
// fills // fills
$objWriter->startElement('fills'); $objWriter->startElement('fills');
$objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count());
// fill // fill
for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) {
$this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i)); $this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i));
} }
$objWriter->endElement(); $objWriter->endElement();
// borders // borders
$objWriter->startElement('borders'); $objWriter->startElement('borders');
$objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count());
// border // border
for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) {
$this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i)); $this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i));
} }
$objWriter->endElement(); $objWriter->endElement();
// cellStyleXfs // cellStyleXfs
$objWriter->startElement('cellStyleXfs'); $objWriter->startElement('cellStyleXfs');
$objWriter->writeAttribute('count', 1); $objWriter->writeAttribute('count', 1);
// xf // xf
$objWriter->startElement('xf'); $objWriter->startElement('xf');
$objWriter->writeAttribute('numFmtId', 0); $objWriter->writeAttribute('numFmtId', 0);
$objWriter->writeAttribute('fontId', 0); $objWriter->writeAttribute('fontId', 0);
$objWriter->writeAttribute('fillId', 0); $objWriter->writeAttribute('fillId', 0);
$objWriter->writeAttribute('borderId', 0); $objWriter->writeAttribute('borderId', 0);
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// cellXfs // cellXfs
$objWriter->startElement('cellXfs'); $objWriter->startElement('cellXfs');
$objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection())); $objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection()));
// xf // xf
foreach ($pPHPExcel->getCellXfCollection() as $cellXf) { foreach ($pPHPExcel->getCellXfCollection() as $cellXf) {
$this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel); $this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel);
} }
$objWriter->endElement(); $objWriter->endElement();
// cellStyles // cellStyles
$objWriter->startElement('cellStyles'); $objWriter->startElement('cellStyles');
$objWriter->writeAttribute('count', 1); $objWriter->writeAttribute('count', 1);
// cellStyle // cellStyle
$objWriter->startElement('cellStyle'); $objWriter->startElement('cellStyle');
$objWriter->writeAttribute('name', 'Normal'); $objWriter->writeAttribute('name', 'Normal');
$objWriter->writeAttribute('xfId', 0); $objWriter->writeAttribute('xfId', 0);
$objWriter->writeAttribute('builtinId', 0); $objWriter->writeAttribute('builtinId', 0);
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// dxfs // dxfs
$objWriter->startElement('dxfs'); $objWriter->startElement('dxfs');
$objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count());
// dxf // dxf
for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) {
$this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle()); $this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle());
} }
$objWriter->endElement(); $objWriter->endElement();
// tableStyles // tableStyles
$objWriter->startElement('tableStyles'); $objWriter->startElement('tableStyles');
$objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9'); $objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9');
$objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1'); $objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
@ -179,7 +179,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$pFill->getFillType() === PHPExcel_Style_Fill::FILL_GRADIENT_PATH) { $pFill->getFillType() === PHPExcel_Style_Fill::FILL_GRADIENT_PATH) {
// Gradient fill // Gradient fill
$this->_writeGradientFill($objWriter, $pFill); $this->_writeGradientFill($objWriter, $pFill);
} elseif($pFill->getFillType() !== NULL) { } elseif ($pFill->getFillType() !== null) {
// Pattern fill // Pattern fill
$this->_writePatternFill($objWriter, $pFill); $this->_writePatternFill($objWriter, $pFill);
} }
@ -197,34 +197,34 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// fill // fill
$objWriter->startElement('fill'); $objWriter->startElement('fill');
// gradientFill // gradientFill
$objWriter->startElement('gradientFill'); $objWriter->startElement('gradientFill');
$objWriter->writeAttribute('type', $pFill->getFillType()); $objWriter->writeAttribute('type', $pFill->getFillType());
$objWriter->writeAttribute('degree', $pFill->getRotation()); $objWriter->writeAttribute('degree', $pFill->getRotation());
// stop // stop
$objWriter->startElement('stop'); $objWriter->startElement('stop');
$objWriter->writeAttribute('position', '0'); $objWriter->writeAttribute('position', '0');
// color // color
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// stop // stop
$objWriter->startElement('stop'); $objWriter->startElement('stop');
$objWriter->writeAttribute('position', '1'); $objWriter->writeAttribute('position', '1');
// color // color
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -241,28 +241,28 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// fill // fill
$objWriter->startElement('fill'); $objWriter->startElement('fill');
// patternFill // patternFill
$objWriter->startElement('patternFill'); $objWriter->startElement('patternFill');
$objWriter->writeAttribute('patternType', $pFill->getFillType()); $objWriter->writeAttribute('patternType', $pFill->getFillType());
if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) { if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
// fgColor // fgColor
if ($pFill->getStartColor()->getARGB()) { if ($pFill->getStartColor()->getARGB()) {
$objWriter->startElement('fgColor'); $objWriter->startElement('fgColor');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
} }
} }
if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) { if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
// bgColor // bgColor
if ($pFill->getEndColor()->getARGB()) { if ($pFill->getEndColor()->getARGB()) {
$objWriter->startElement('bgColor'); $objWriter->startElement('bgColor');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
} }
} }
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -278,71 +278,71 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
{ {
// font // font
$objWriter->startElement('font'); $objWriter->startElement('font');
// Weird! The order of these elements actually makes a difference when opening Excel2007 // Weird! The order of these elements actually makes a difference when opening Excel2007
// files in Excel2003 with the compatibility pack. It's not documented behaviour, // files in Excel2003 with the compatibility pack. It's not documented behaviour,
// and makes for a real WTF! // and makes for a real WTF!
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does // Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
// for conditional formatting). Otherwise it will apparently not be picked up in conditional // for conditional formatting). Otherwise it will apparently not be picked up in conditional
// formatting style dialog // formatting style dialog
if ($pFont->getBold() !== NULL) { if ($pFont->getBold() !== null) {
$objWriter->startElement('b'); $objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0'); $objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
$objWriter->endElement(); $objWriter->endElement();
} }
// Italic // Italic
if ($pFont->getItalic() !== NULL) { if ($pFont->getItalic() !== null) {
$objWriter->startElement('i'); $objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0'); $objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
$objWriter->endElement(); $objWriter->endElement();
} }
// Strikethrough // Strikethrough
if ($pFont->getStrikethrough() !== NULL) { if ($pFont->getStrikethrough() !== null) {
$objWriter->startElement('strike'); $objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0'); $objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
$objWriter->endElement(); $objWriter->endElement();
} }
// Underline // Underline
if ($pFont->getUnderline() !== NULL) { if ($pFont->getUnderline() !== null) {
$objWriter->startElement('u'); $objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline()); $objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement(); $objWriter->endElement();
} }
// Superscript / subscript // Superscript / subscript
if ($pFont->getSuperScript() === TRUE || $pFont->getSubScript() === TRUE) { if ($pFont->getSuperScript() === true || $pFont->getSubScript() === true) {
$objWriter->startElement('vertAlign'); $objWriter->startElement('vertAlign');
if ($pFont->getSuperScript() === TRUE) { if ($pFont->getSuperScript() === true) {
$objWriter->writeAttribute('val', 'superscript'); $objWriter->writeAttribute('val', 'superscript');
} else if ($pFont->getSubScript() === TRUE) { } else if ($pFont->getSubScript() === true) {
$objWriter->writeAttribute('val', 'subscript'); $objWriter->writeAttribute('val', 'subscript');
}
$objWriter->endElement();
} }
$objWriter->endElement();
}
// Size // Size
if ($pFont->getSize() !== NULL) { if ($pFont->getSize() !== null) {
$objWriter->startElement('sz'); $objWriter->startElement('sz');
$objWriter->writeAttribute('val', $pFont->getSize()); $objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement(); $objWriter->endElement();
} }
// Foreground color // Foreground color
if ($pFont->getColor()->getARGB() !== NULL) { if ($pFont->getColor()->getARGB() !== null) {
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
} }
// Name // Name
if ($pFont->getName() !== NULL) { if ($pFont->getName() !== null) {
$objWriter->startElement('name'); $objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName()); $objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement(); $objWriter->endElement();
} }
$objWriter->endElement(); $objWriter->endElement();
} }
@ -358,28 +358,28 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
{ {
// Write border // Write border
$objWriter->startElement('border'); $objWriter->startElement('border');
// Diagonal? // Diagonal?
switch ($pBorders->getDiagonalDirection()) { switch ($pBorders->getDiagonalDirection()) {
case PHPExcel_Style_Borders::DIAGONAL_UP: case PHPExcel_Style_Borders::DIAGONAL_UP:
$objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'false'); $objWriter->writeAttribute('diagonalDown', 'false');
break; break;
case PHPExcel_Style_Borders::DIAGONAL_DOWN: case PHPExcel_Style_Borders::DIAGONAL_DOWN:
$objWriter->writeAttribute('diagonalUp', 'false'); $objWriter->writeAttribute('diagonalUp', 'false');
$objWriter->writeAttribute('diagonalDown', 'true'); $objWriter->writeAttribute('diagonalDown', 'true');
break; break;
case PHPExcel_Style_Borders::DIAGONAL_BOTH: case PHPExcel_Style_Borders::DIAGONAL_BOTH:
$objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'true'); $objWriter->writeAttribute('diagonalDown', 'true');
break; break;
} }
// BorderPr // BorderPr
$this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft()); $this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft());
$this->_writeBorderPr($objWriter, 'right', $pBorders->getRight()); $this->_writeBorderPr($objWriter, 'right', $pBorders->getRight());
$this->_writeBorderPr($objWriter, 'top', $pBorders->getTop()); $this->_writeBorderPr($objWriter, 'top', $pBorders->getTop());
$this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom()); $this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom());
$this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal()); $this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal());
$objWriter->endElement(); $objWriter->endElement();
} }
@ -395,66 +395,66 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
{ {
// xf // xf
$objWriter->startElement('xf'); $objWriter->startElement('xf');
$objWriter->writeAttribute('xfId', 0); $objWriter->writeAttribute('xfId', 0);
$objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode())); $objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
if ($pStyle->getQuotePrefix()) { if ($pStyle->getQuotePrefix()) {
$objWriter->writeAttribute('quotePrefix', 1); $objWriter->writeAttribute('quotePrefix', 1);
}
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164));
} else {
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
}
$objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
// Apply styles?
$objWriter->writeAttribute('applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('applyProtection', 'true');
}
// alignment
$objWriter->startElement('alignment');
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} else if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
$objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
$objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
if ($pStyle->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
}
if ($pStyle->getAlignment()->getReadorder() > 0) {
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
}
$objWriter->endElement();
// protection
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
} }
if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) { $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
} else {
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
} }
$objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
// Apply styles?
$objWriter->writeAttribute('applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('applyProtection', 'true');
}
// alignment
$objWriter->startElement('alignment');
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} else if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
$objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
$objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
if ($pStyle->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
}
if ($pStyle->getAlignment()->getReadorder() > 0) {
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
}
$objWriter->endElement(); $objWriter->endElement();
}
// protection
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
} }
@ -471,55 +471,54 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// dxf // dxf
$objWriter->startElement('dxf'); $objWriter->startElement('dxf');
// font // font
$this->_writeFont($objWriter, $pStyle->getFont()); $this->_writeFont($objWriter, $pStyle->getFont());
// numFmt // numFmt
$this->_writeNumFmt($objWriter, $pStyle->getNumberFormat()); $this->_writeNumFmt($objWriter, $pStyle->getNumberFormat());
// fill // fill
$this->_writeFill($objWriter, $pStyle->getFill()); $this->_writeFill($objWriter, $pStyle->getFill());
// alignment // alignment
$objWriter->startElement('alignment'); $objWriter->startElement('alignment');
if ($pStyle->getAlignment()->getHorizontal() !== NULL) { if ($pStyle->getAlignment()->getHorizontal() !== null) {
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal()); $objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
} }
if ($pStyle->getAlignment()->getVertical() !== NULL) { if ($pStyle->getAlignment()->getVertical() !== null) {
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical()); $objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
} }
if ($pStyle->getAlignment()->getTextRotation() !== NULL) { if ($pStyle->getAlignment()->getTextRotation() !== null) {
$textRotation = 0; $textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) { if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation(); $textRotation = $pStyle->getAlignment()->getTextRotation();
} else if ($pStyle->getAlignment()->getTextRotation() < 0) { } else if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation(); $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
}
$objWriter->endElement();
// border
$this->_writeBorder($objWriter, $pStyle->getBorders());
// protection
if (($pStyle->getProtection()->getLocked() !== NULL) ||
($pStyle->getProtection()->getHidden() !== NULL)) {
if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if (($pStyle->getProtection()->getLocked() !== NULL) &&
($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if (($pStyle->getProtection()->getHidden() !== NULL) &&
($pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
} }
$objWriter->writeAttribute('textRotation', $textRotation);
}
$objWriter->endElement();
// border
$this->_writeBorder($objWriter, $pStyle->getBorders());
// protection
if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) {
if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if (($pStyle->getProtection()->getLocked() !== null) &&
($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if (($pStyle->getProtection()->getHidden() !== null) &&
($pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
}
$objWriter->endElement(); $objWriter->endElement();
} }
@ -537,12 +536,12 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// Write BorderPr // Write BorderPr
if ($pBorder->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) { if ($pBorder->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
$objWriter->startElement($pName); $objWriter->startElement($pName);
$objWriter->writeAttribute('style', $pBorder->getBorderStyle()); $objWriter->writeAttribute('style', $pBorder->getBorderStyle());
// color // color
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB()); $objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -562,10 +561,10 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$formatCode = $pNumberFormat->getFormatCode(); $formatCode = $pNumberFormat->getFormatCode();
// numFmt // numFmt
if ($formatCode !== NULL) { if ($formatCode !== null) {
$objWriter->startElement('numFmt'); $objWriter->startElement('numFmt');
$objWriter->writeAttribute('numFmtId', ($pId + 164)); $objWriter->writeAttribute('numFmtId', ($pId + 164));
$objWriter->writeAttribute('formatCode', $formatCode); $objWriter->writeAttribute('formatCode', $formatCode);
$objWriter->endElement(); $objWriter->endElement();
} }
} }
@ -579,9 +578,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
*/ */
public function allStyles(PHPExcel $pPHPExcel = null) public function allStyles(PHPExcel $pPHPExcel = null)
{ {
$aStyles = $pPHPExcel->getCellXfCollection(); return $pPHPExcel->getCellXfCollection();
return $aStyles;
} }
/** /**
@ -594,7 +591,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allConditionalStyles(PHPExcel $pPHPExcel = null) public function allConditionalStyles(PHPExcel $pPHPExcel = null)
{ {
// Get an array of all styles // Get an array of all styles
$aStyles = array(); $aStyles = array();
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
@ -618,7 +615,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allFills(PHPExcel $pPHPExcel = null) public function allFills(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique fills // Get an array of unique fills
$aFills = array(); $aFills = array();
// Two first fills are predefined // Two first fills are predefined
$fill0 = new PHPExcel_Style_Fill(); $fill0 = new PHPExcel_Style_Fill();
@ -629,7 +626,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125); $fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125);
$aFills[] = $fill1; $aFills[] = $fill1;
// The remaining fills // The remaining fills
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) { if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) {
$aFills[ $style->getFill()->getHashCode() ] = $style->getFill(); $aFills[ $style->getFill()->getHashCode() ] = $style->getFill();
@ -649,8 +646,8 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allFonts(PHPExcel $pPHPExcel = null) public function allFonts(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique fonts // Get an array of unique fonts
$aFonts = array(); $aFonts = array();
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) { if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) {
@ -671,8 +668,8 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allBorders(PHPExcel $pPHPExcel = null) public function allBorders(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique borders // Get an array of unique borders
$aBorders = array(); $aBorders = array();
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) { if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) {
@ -693,8 +690,8 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allNumberFormats(PHPExcel $pPHPExcel = null) public function allNumberFormats(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique number formats // Get an array of unique number formats
$aNumFmts = array(); $aNumFmts = array();
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) { if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) {

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE) public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -54,7 +54,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// workbook // workbook
$objWriter->startElement('workbook'); $objWriter->startElement('workbook');
@ -62,28 +62,28 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
// fileVersion // fileVersion
$this->_writeFileVersion($objWriter); $this->_writeFileVersion($objWriter);
// workbookPr // workbookPr
$this->_writeWorkbookPr($objWriter); $this->_writeWorkbookPr($objWriter);
// workbookProtection // workbookProtection
$this->_writeWorkbookProtection($objWriter, $pPHPExcel); $this->_writeWorkbookProtection($objWriter, $pPHPExcel);
// bookViews // bookViews
if ($this->getParentWriter()->getOffice2003Compatibility() === false) { if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
$this->_writeBookViews($objWriter, $pPHPExcel); $this->_writeBookViews($objWriter, $pPHPExcel);
} }
// sheets // sheets
$this->_writeSheets($objWriter, $pPHPExcel); $this->_writeSheets($objWriter, $pPHPExcel);
// definedNames // definedNames
$this->_writeDefinedNames($objWriter, $pPHPExcel); $this->_writeDefinedNames($objWriter, $pPHPExcel);
// calcPr // calcPr
$this->_writeCalcPr($objWriter,$recalcRequired); $this->_writeCalcPr($objWriter, $recalcRequired);
$objWriter->endElement(); $objWriter->endElement();
@ -138,20 +138,20 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// bookViews // bookViews
$objWriter->startElement('bookViews'); $objWriter->startElement('bookViews');
// workbookView // workbookView
$objWriter->startElement('workbookView'); $objWriter->startElement('workbookView');
$objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex()); $objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex());
$objWriter->writeAttribute('autoFilterDateGrouping', '1'); $objWriter->writeAttribute('autoFilterDateGrouping', '1');
$objWriter->writeAttribute('firstSheet', '0'); $objWriter->writeAttribute('firstSheet', '0');
$objWriter->writeAttribute('minimized', '0'); $objWriter->writeAttribute('minimized', '0');
$objWriter->writeAttribute('showHorizontalScroll', '1'); $objWriter->writeAttribute('showHorizontalScroll', '1');
$objWriter->writeAttribute('showSheetTabs', '1'); $objWriter->writeAttribute('showSheetTabs', '1');
$objWriter->writeAttribute('showVerticalScroll', '1'); $objWriter->writeAttribute('showVerticalScroll', '1');
$objWriter->writeAttribute('tabRatio', '600'); $objWriter->writeAttribute('tabRatio', '600');
$objWriter->writeAttribute('visibility', 'visible'); $objWriter->writeAttribute('visibility', 'visible');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -167,16 +167,16 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
{ {
if ($pPHPExcel->getSecurity()->isSecurityEnabled()) { if ($pPHPExcel->getSecurity()->isSecurityEnabled()) {
$objWriter->startElement('workbookProtection'); $objWriter->startElement('workbookProtection');
$objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false')); $objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false'));
$objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false')); $objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false'));
$objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false')); $objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false'));
if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') { if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') {
$objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword()); $objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword());
} }
if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') { if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') {
$objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword()); $objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword());
} }
$objWriter->endElement(); $objWriter->endElement();
@ -190,18 +190,18 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing * @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = TRUE) private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = true)
{ {
$objWriter->startElement('calcPr'); $objWriter->startElement('calcPr');
// Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc // Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc
// If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit // If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit
// because the file has changed // because the file has changed
$objWriter->writeAttribute('calcId', '999999'); $objWriter->writeAttribute('calcId', '999999');
$objWriter->writeAttribute('calcMode', 'auto'); $objWriter->writeAttribute('calcMode', 'auto');
// fullCalcOnLoad isn't needed if we've recalculating for the save // fullCalcOnLoad isn't needed if we've recalculating for the save
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0); $objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0);
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1); $objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
$objWriter->endElement(); $objWriter->endElement();
} }
@ -247,12 +247,12 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
if ($pSheetname != '') { if ($pSheetname != '') {
// Write sheet // Write sheet
$objWriter->startElement('sheet'); $objWriter->startElement('sheet');
$objWriter->writeAttribute('name', $pSheetname); $objWriter->writeAttribute('name', $pSheetname);
$objWriter->writeAttribute('sheetId', $pSheetId); $objWriter->writeAttribute('sheetId', $pSheetId);
if ($sheetState != 'visible' && $sheetState != '') { if ($sheetState != 'visible' && $sheetState != '') {
$objWriter->writeAttribute('state', $sheetState); $objWriter->writeAttribute('state', $sheetState);
} }
$objWriter->writeAttribute('r:id', 'rId' . $pRelId); $objWriter->writeAttribute('r:id', 'rId' . $pRelId);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
throw new PHPExcel_Writer_Exception("Invalid parameters passed."); throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
@ -320,9 +320,9 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
{ {
// definedName for named range // definedName for named range
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', $pNamedRange->getName()); $objWriter->writeAttribute('name', $pNamedRange->getName());
if ($pNamedRange->getLocalOnly()) { if ($pNamedRange->getLocalOnly()) {
$objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope())); $objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
} }
// Create absolute coordinate and write as raw text // Create absolute coordinate and write as raw text
@ -354,16 +354,16 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$autoFilterRange = $pSheet->getAutoFilter()->getRange(); $autoFilterRange = $pSheet->getAutoFilter()->getRange();
if (!empty($autoFilterRange)) { if (!empty($autoFilterRange)) {
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm._FilterDatabase'); $objWriter->writeAttribute('name', '_xlnm._FilterDatabase');
$objWriter->writeAttribute('localSheetId', $pSheetId); $objWriter->writeAttribute('localSheetId', $pSheetId);
$objWriter->writeAttribute('hidden', '1'); $objWriter->writeAttribute('hidden', '1');
// Create absolute coordinate and write as raw text // Create absolute coordinate and write as raw text
$range = PHPExcel_Cell::splitRange($autoFilterRange); $range = PHPExcel_Cell::splitRange($autoFilterRange);
$range = $range[0]; $range = $range[0];
// Strip any worksheet ref so we can make the cell ref absolute // Strip any worksheet ref so we can make the cell ref absolute
if (strpos($range[0],'!') !== false) { if (strpos($range[0], '!') !== false) {
list($ws,$range[0]) = explode('!',$range[0]); list($ws, $range[0]) = explode('!', $range[0]);
} }
$range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]); $range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]);
@ -389,8 +389,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// definedName for PrintTitles // definedName for PrintTitles
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) { if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm.Print_Titles'); $objWriter->writeAttribute('name', '_xlnm.Print_Titles');
$objWriter->writeAttribute('localSheetId', $pSheetId); $objWriter->writeAttribute('localSheetId', $pSheetId);
// Setting string // Setting string
$settingString = ''; $settingString = '';
@ -432,8 +432,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// definedName for PrintArea // definedName for PrintArea
if ($pSheet->getPageSetup()->isPrintAreaSet()) { if ($pSheet->getPageSetup()->isPrintAreaSet()) {
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm.Print_Area'); $objWriter->writeAttribute('name', '_xlnm.Print_Area');
$objWriter->writeAttribute('localSheetId', $pSheetId); $objWriter->writeAttribute('localSheetId', $pSheetId);
// Setting string // Setting string
$settingString = ''; $settingString = '';

View File

@ -44,7 +44,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = FALSE) public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = false)
{ {
if (!is_null($pSheet)) { if (!is_null($pSheet)) {
// Create XML writer // Create XML writer
@ -56,7 +56,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Worksheet // Worksheet
$objWriter->startElement('worksheet'); $objWriter->startElement('worksheet');
@ -148,37 +148,37 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// sheetPr // sheetPr
$objWriter->startElement('sheetPr'); $objWriter->startElement('sheetPr');
//$objWriter->writeAttribute('codeName', $pSheet->getTitle()); //$objWriter->writeAttribute('codeName', $pSheet->getTitle());
if($pSheet->getParent()->hasMacros()){//if the workbook have macros, we need to have codeName for the sheet if ($pSheet->getParent()->hasMacros()) {//if the workbook have macros, we need to have codeName for the sheet
if($pSheet->hasCodeName()==false){ if ($pSheet->hasCodeName()==false) {
$pSheet->setCodeName($pSheet->getTitle()); $pSheet->setCodeName($pSheet->getTitle());
} }
$objWriter->writeAttribute('codeName', $pSheet->getCodeName()); $objWriter->writeAttribute('codeName', $pSheet->getCodeName());
}
$autoFilterRange = $pSheet->getAutoFilter()->getRange();
if (!empty($autoFilterRange)) {
$objWriter->writeAttribute('filterMode', 1);
$pSheet->getAutoFilter()->showHideRows();
} }
$autoFilterRange = $pSheet->getAutoFilter()->getRange();
if (!empty($autoFilterRange)) {
$objWriter->writeAttribute('filterMode', 1);
$pSheet->getAutoFilter()->showHideRows();
}
// tabColor // tabColor
if ($pSheet->isTabColorSet()) { if ($pSheet->isTabColorSet()) {
$objWriter->startElement('tabColor'); $objWriter->startElement('tabColor');
$objWriter->writeAttribute('rgb', $pSheet->getTabColor()->getARGB()); $objWriter->writeAttribute('rgb', $pSheet->getTabColor()->getARGB());
$objWriter->endElement();
}
// outlinePr
$objWriter->startElement('outlinePr');
$objWriter->writeAttribute('summaryBelow', ($pSheet->getShowSummaryBelow() ? '1' : '0'));
$objWriter->writeAttribute('summaryRight', ($pSheet->getShowSummaryRight() ? '1' : '0'));
$objWriter->endElement(); $objWriter->endElement();
}
// pageSetUpPr // outlinePr
if ($pSheet->getPageSetup()->getFitToPage()) { $objWriter->startElement('outlinePr');
$objWriter->startElement('pageSetUpPr'); $objWriter->writeAttribute('summaryBelow', ($pSheet->getShowSummaryBelow() ? '1' : '0'));
$objWriter->writeAttribute('fitToPage', '1'); $objWriter->writeAttribute('summaryRight', ($pSheet->getShowSummaryRight() ? '1' : '0'));
$objWriter->endElement(); $objWriter->endElement();
}
// pageSetUpPr
if ($pSheet->getPageSetup()->getFitToPage()) {
$objWriter->startElement('pageSetUpPr');
$objWriter->writeAttribute('fitToPage', '1');
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
} }
@ -205,28 +205,28 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
* @param PHPExcel_Worksheet $pSheet Worksheet * @param PHPExcel_Worksheet $pSheet Worksheet
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeSheetViews(PHPExcel_Shared_XMLWriter $objWriter = NULL, PHPExcel_Worksheet $pSheet = NULL) private function _writeSheetViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
{ {
// sheetViews // sheetViews
$objWriter->startElement('sheetViews'); $objWriter->startElement('sheetViews');
// Sheet selected? // Sheet selected?
$sheetSelected = false; $sheetSelected = false;
if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex()) {
$sheetSelected = true; $sheetSelected = true;
}
// sheetView // sheetView
$objWriter->startElement('sheetView'); $objWriter->startElement('sheetView');
$objWriter->writeAttribute('tabSelected', $sheetSelected ? '1' : '0'); $objWriter->writeAttribute('tabSelected', $sheetSelected ? '1' : '0');
$objWriter->writeAttribute('workbookViewId', '0'); $objWriter->writeAttribute('workbookViewId', '0');
// Zoom scales // Zoom scales
if ($pSheet->getSheetView()->getZoomScale() != 100) { if ($pSheet->getSheetView()->getZoomScale() != 100) {
$objWriter->writeAttribute('zoomScale', $pSheet->getSheetView()->getZoomScale()); $objWriter->writeAttribute('zoomScale', $pSheet->getSheetView()->getZoomScale());
} }
if ($pSheet->getSheetView()->getZoomScaleNormal() != 100) { if ($pSheet->getSheetView()->getZoomScaleNormal() != 100) {
$objWriter->writeAttribute('zoomScaleNormal', $pSheet->getSheetView()->getZoomScaleNormal()); $objWriter->writeAttribute('zoomScaleNormal', $pSheet->getSheetView()->getZoomScaleNormal());
} }
// View Layout Type // View Layout Type
@ -236,9 +236,9 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Gridlines // Gridlines
if ($pSheet->getShowGridlines()) { if ($pSheet->getShowGridlines()) {
$objWriter->writeAttribute('showGridLines', 'true'); $objWriter->writeAttribute('showGridLines', 'true');
} else { } else {
$objWriter->writeAttribute('showGridLines', 'false'); $objWriter->writeAttribute('showGridLines', 'false');
} }
// Row and column headers // Row and column headers
@ -250,7 +250,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Right-to-left // Right-to-left
if ($pSheet->getRightToLeft()) { if ($pSheet->getRightToLeft()) {
$objWriter->writeAttribute('rightToLeft', 'true'); $objWriter->writeAttribute('rightToLeft', 'true');
} }
$activeCell = $pSheet->getActiveCell(); $activeCell = $pSheet->getActiveCell();
@ -270,20 +270,24 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$pane = 'topRight'; $pane = 'topRight';
$objWriter->startElement('pane'); $objWriter->startElement('pane');
if ($xSplit > 1) if ($xSplit > 1)
$objWriter->writeAttribute('xSplit', $xSplit - 1); $objWriter->writeAttribute('xSplit', $xSplit - 1);
if ($ySplit > 1) { if ($ySplit > 1) {
$objWriter->writeAttribute('ySplit', $ySplit - 1); $objWriter->writeAttribute('ySplit', $ySplit - 1);
$pane = ($xSplit > 1) ? 'bottomRight' : 'bottomLeft'; $pane = ($xSplit > 1) ? 'bottomRight' : 'bottomLeft';
} }
$objWriter->writeAttribute('topLeftCell', $topLeftCell); $objWriter->writeAttribute('topLeftCell', $topLeftCell);
$objWriter->writeAttribute('activePane', $pane); $objWriter->writeAttribute('activePane', $pane);
$objWriter->writeAttribute('state', 'frozen'); $objWriter->writeAttribute('state', 'frozen');
$objWriter->endElement(); $objWriter->endElement();
if (($xSplit > 1) && ($ySplit > 1)) { if (($xSplit > 1) && ($ySplit > 1)) {
// Write additional selections if more than two panes (ie both an X and a Y split) // Write additional selections if more than two panes (ie both an X and a Y split)
$objWriter->startElement('selection'); $objWriter->writeAttribute('pane', 'topRight'); $objWriter->endElement(); $objWriter->startElement('selection');
$objWriter->startElement('selection'); $objWriter->writeAttribute('pane', 'bottomLeft'); $objWriter->endElement(); $objWriter->writeAttribute('pane', 'topRight');
$objWriter->endElement();
$objWriter->startElement('selection');
$objWriter->writeAttribute('pane', 'bottomLeft');
$objWriter->endElement();
} }
} }
@ -317,42 +321,42 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// sheetFormatPr // sheetFormatPr
$objWriter->startElement('sheetFormatPr'); $objWriter->startElement('sheetFormatPr');
// Default row height // Default row height
if ($pSheet->getDefaultRowDimension()->getRowHeight() >= 0) { if ($pSheet->getDefaultRowDimension()->getRowHeight() >= 0) {
$objWriter->writeAttribute('customHeight', 'true'); $objWriter->writeAttribute('customHeight', 'true');
$objWriter->writeAttribute('defaultRowHeight', PHPExcel_Shared_String::FormatNumber($pSheet->getDefaultRowDimension()->getRowHeight())); $objWriter->writeAttribute('defaultRowHeight', PHPExcel_Shared_String::FormatNumber($pSheet->getDefaultRowDimension()->getRowHeight()));
} else { } else {
$objWriter->writeAttribute('defaultRowHeight', '14.4'); $objWriter->writeAttribute('defaultRowHeight', '14.4');
} }
// Set Zero Height row // Set Zero Height row
if ((string)$pSheet->getDefaultRowDimension()->getZeroHeight() == '1' || if ((string)$pSheet->getDefaultRowDimension()->getZeroHeight() == '1' ||
strtolower((string)$pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true' ) { strtolower((string)$pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') {
$objWriter->writeAttribute('zeroHeight', '1'); $objWriter->writeAttribute('zeroHeight', '1');
} }
// Default column width // Default column width
if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) { if ($pSheet->getDefaultColumnDimension()->getWidth() >= 0) {
$objWriter->writeAttribute('defaultColWidth', PHPExcel_Shared_String::FormatNumber($pSheet->getDefaultColumnDimension()->getWidth())); $objWriter->writeAttribute('defaultColWidth', PHPExcel_Shared_String::FormatNumber($pSheet->getDefaultColumnDimension()->getWidth()));
} }
// Outline level - row // Outline level - row
$outlineLevelRow = 0; $outlineLevelRow = 0;
foreach ($pSheet->getRowDimensions() as $dimension) { foreach ($pSheet->getRowDimensions() as $dimension) {
if ($dimension->getOutlineLevel() > $outlineLevelRow) { if ($dimension->getOutlineLevel() > $outlineLevelRow) {
$outlineLevelRow = $dimension->getOutlineLevel(); $outlineLevelRow = $dimension->getOutlineLevel();
}
} }
$objWriter->writeAttribute('outlineLevelRow', (int)$outlineLevelRow); }
$objWriter->writeAttribute('outlineLevelRow', (int)$outlineLevelRow);
// Outline level - column // Outline level - column
$outlineLevelCol = 0; $outlineLevelCol = 0;
foreach ($pSheet->getColumnDimensions() as $dimension) { foreach ($pSheet->getColumnDimensions() as $dimension) {
if ($dimension->getOutlineLevel() > $outlineLevelCol) { if ($dimension->getOutlineLevel() > $outlineLevelCol) {
$outlineLevelCol = $dimension->getOutlineLevel(); $outlineLevelCol = $dimension->getOutlineLevel();
}
} }
$objWriter->writeAttribute('outlineLevelCol', (int)$outlineLevelCol); }
$objWriter->writeAttribute('outlineLevelCol', (int)$outlineLevelCol);
$objWriter->endElement(); $objWriter->endElement();
} }
@ -360,8 +364,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
/** /**
* Write Cols * Write Cols
* *
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param PHPExcel_Worksheet $pSheet Worksheet * @param PHPExcel_Worksheet $pSheet Worksheet
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
@ -370,54 +374,54 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
if (count($pSheet->getColumnDimensions()) > 0) { if (count($pSheet->getColumnDimensions()) > 0) {
$objWriter->startElement('cols'); $objWriter->startElement('cols');
$pSheet->calculateColumnWidths(); $pSheet->calculateColumnWidths();
// Loop through column dimensions // Loop through column dimensions
foreach ($pSheet->getColumnDimensions() as $colDimension) { foreach ($pSheet->getColumnDimensions() as $colDimension) {
// col // col
$objWriter->startElement('col'); $objWriter->startElement('col');
$objWriter->writeAttribute('min', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex())); $objWriter->writeAttribute('min', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
$objWriter->writeAttribute('max', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex())); $objWriter->writeAttribute('max', PHPExcel_Cell::columnIndexFromString($colDimension->getColumnIndex()));
if ($colDimension->getWidth() < 0) { if ($colDimension->getWidth() < 0) {
// No width set, apply default of 10 // No width set, apply default of 10
$objWriter->writeAttribute('width', '9.10'); $objWriter->writeAttribute('width', '9.10');
} else { } else {
// Width set // Width set
$objWriter->writeAttribute('width', PHPExcel_Shared_String::FormatNumber($colDimension->getWidth())); $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();
} }
// 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(); $objWriter->endElement();
} }
} }
@ -435,25 +439,25 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->startElement('sheetProtection'); $objWriter->startElement('sheetProtection');
if ($pSheet->getProtection()->getPassword() != '') { if ($pSheet->getProtection()->getPassword() != '') {
$objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword()); $objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword());
} }
$objWriter->writeAttribute('sheet', ($pSheet->getProtection()->getSheet() ? 'true' : 'false')); $objWriter->writeAttribute('sheet', ($pSheet->getProtection()->getSheet() ? 'true' : 'false'));
$objWriter->writeAttribute('objects', ($pSheet->getProtection()->getObjects() ? 'true' : 'false')); $objWriter->writeAttribute('objects', ($pSheet->getProtection()->getObjects() ? 'true' : 'false'));
$objWriter->writeAttribute('scenarios', ($pSheet->getProtection()->getScenarios() ? 'true' : 'false')); $objWriter->writeAttribute('scenarios', ($pSheet->getProtection()->getScenarios() ? 'true' : 'false'));
$objWriter->writeAttribute('formatCells', ($pSheet->getProtection()->getFormatCells() ? 'true' : 'false')); $objWriter->writeAttribute('formatCells', ($pSheet->getProtection()->getFormatCells() ? 'true' : 'false'));
$objWriter->writeAttribute('formatColumns', ($pSheet->getProtection()->getFormatColumns() ? 'true' : 'false')); $objWriter->writeAttribute('formatColumns', ($pSheet->getProtection()->getFormatColumns() ? 'true' : 'false'));
$objWriter->writeAttribute('formatRows', ($pSheet->getProtection()->getFormatRows() ? 'true' : 'false')); $objWriter->writeAttribute('formatRows', ($pSheet->getProtection()->getFormatRows() ? 'true' : 'false'));
$objWriter->writeAttribute('insertColumns', ($pSheet->getProtection()->getInsertColumns() ? 'true' : 'false')); $objWriter->writeAttribute('insertColumns', ($pSheet->getProtection()->getInsertColumns() ? 'true' : 'false'));
$objWriter->writeAttribute('insertRows', ($pSheet->getProtection()->getInsertRows() ? 'true' : 'false')); $objWriter->writeAttribute('insertRows', ($pSheet->getProtection()->getInsertRows() ? 'true' : 'false'));
$objWriter->writeAttribute('insertHyperlinks', ($pSheet->getProtection()->getInsertHyperlinks() ? 'true' : 'false')); $objWriter->writeAttribute('insertHyperlinks', ($pSheet->getProtection()->getInsertHyperlinks() ? 'true' : 'false'));
$objWriter->writeAttribute('deleteColumns', ($pSheet->getProtection()->getDeleteColumns() ? 'true' : 'false')); $objWriter->writeAttribute('deleteColumns', ($pSheet->getProtection()->getDeleteColumns() ? 'true' : 'false'));
$objWriter->writeAttribute('deleteRows', ($pSheet->getProtection()->getDeleteRows() ? 'true' : 'false')); $objWriter->writeAttribute('deleteRows', ($pSheet->getProtection()->getDeleteRows() ? 'true' : 'false'));
$objWriter->writeAttribute('selectLockedCells', ($pSheet->getProtection()->getSelectLockedCells() ? 'true' : 'false')); $objWriter->writeAttribute('selectLockedCells', ($pSheet->getProtection()->getSelectLockedCells() ? 'true' : 'false'));
$objWriter->writeAttribute('sort', ($pSheet->getProtection()->getSort() ? 'true' : 'false')); $objWriter->writeAttribute('sort', ($pSheet->getProtection()->getSort() ? 'true' : 'false'));
$objWriter->writeAttribute('autoFilter', ($pSheet->getProtection()->getAutoFilter() ? 'true' : 'false')); $objWriter->writeAttribute('autoFilter', ($pSheet->getProtection()->getAutoFilter() ? 'true' : 'false'));
$objWriter->writeAttribute('pivotTables', ($pSheet->getProtection()->getPivotTables() ? 'true' : 'false')); $objWriter->writeAttribute('pivotTables', ($pSheet->getProtection()->getPivotTables() ? 'true' : 'false'));
$objWriter->writeAttribute('selectUnlockedCells', ($pSheet->getProtection()->getSelectUnlockedCells() ? 'true' : 'false')); $objWriter->writeAttribute('selectUnlockedCells', ($pSheet->getProtection()->getSelectUnlockedCells() ? 'true' : 'false'));
$objWriter->endElement(); $objWriter->endElement();
} }
@ -473,54 +477,54 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
foreach ($pSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { foreach ($pSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
foreach ($conditionalStyles as $conditional) { foreach ($conditionalStyles as $conditional) {
// WHY was this again? // WHY was this again?
// if ($this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode( $conditional->getHashCode() ) == '') { // if ($this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode()) == '') {
// continue; // continue;
// } // }
if ($conditional->getConditionType() != PHPExcel_Style_Conditional::CONDITION_NONE) { if ($conditional->getConditionType() != PHPExcel_Style_Conditional::CONDITION_NONE) {
// conditionalFormatting // conditionalFormatting
$objWriter->startElement('conditionalFormatting'); $objWriter->startElement('conditionalFormatting');
$objWriter->writeAttribute('sqref', $cellCoordinate); $objWriter->writeAttribute('sqref', $cellCoordinate);
// cfRule // cfRule
$objWriter->startElement('cfRule'); $objWriter->startElement('cfRule');
$objWriter->writeAttribute('type', $conditional->getConditionType()); $objWriter->writeAttribute('type', $conditional->getConditionType());
$objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode( $conditional->getHashCode() )); $objWriter->writeAttribute('dxfId', $this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode($conditional->getHashCode()));
$objWriter->writeAttribute('priority', $id++); $objWriter->writeAttribute('priority', $id++);
if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
|| ||
$conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT) $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)
&& $conditional->getOperatorType() != PHPExcel_Style_Conditional::OPERATOR_NONE) { && $conditional->getOperatorType() != PHPExcel_Style_Conditional::OPERATOR_NONE) {
$objWriter->writeAttribute('operator', $conditional->getOperatorType()); $objWriter->writeAttribute('operator', $conditional->getOperatorType());
} }
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& !is_null($conditional->getText())) { && !is_null($conditional->getText())) {
$objWriter->writeAttribute('text', $conditional->getText()); $objWriter->writeAttribute('text', $conditional->getText());
} }
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT
&& !is_null($conditional->getText())) { && !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))'); $objWriter->writeElement('formula', 'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH
&& !is_null($conditional->getText())) { && !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); $objWriter->writeElement('formula', 'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH
&& !is_null($conditional->getText())) { && !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"'); $objWriter->writeElement('formula', 'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS && $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS
&& !is_null($conditional->getText())) { && !is_null($conditional->getText())) {
$objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))'); $objWriter->writeElement('formula', 'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))');
} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS } else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) { || $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) {
foreach ($conditional->getConditions() as $formula) { foreach ($conditional->getConditions() as $formula) {
// Formula // Formula
$objWriter->writeElement('formula', $formula); $objWriter->writeElement('formula', $formula);
} }
} }
@ -564,10 +568,10 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('operator', $dv->getOperator()); $objWriter->writeAttribute('operator', $dv->getOperator());
} }
$objWriter->writeAttribute('allowBlank', ($dv->getAllowBlank() ? '1' : '0')); $objWriter->writeAttribute('allowBlank', ($dv->getAllowBlank() ? '1' : '0'));
$objWriter->writeAttribute('showDropDown', (!$dv->getShowDropDown() ? '1' : '0')); $objWriter->writeAttribute('showDropDown', (!$dv->getShowDropDown() ? '1' : '0'));
$objWriter->writeAttribute('showInputMessage', ($dv->getShowInputMessage() ? '1' : '0')); $objWriter->writeAttribute('showInputMessage', ($dv->getShowInputMessage() ? '1' : '0'));
$objWriter->writeAttribute('showErrorMessage', ($dv->getShowErrorMessage() ? '1' : '0')); $objWriter->writeAttribute('showErrorMessage', ($dv->getShowErrorMessage() ? '1' : '0'));
if ($dv->getErrorTitle() !== '') { if ($dv->getErrorTitle() !== '') {
$objWriter->writeAttribute('errorTitle', $dv->getErrorTitle()); $objWriter->writeAttribute('errorTitle', $dv->getErrorTitle());
@ -622,10 +626,10 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('ref', $coordinate); $objWriter->writeAttribute('ref', $coordinate);
if (!$hyperlink->isInternal()) { if (!$hyperlink->isInternal()) {
$objWriter->writeAttribute('r:id', 'rId_hyperlink_' . $relationId); $objWriter->writeAttribute('r:id', 'rId_hyperlink_' . $relationId);
++$relationId; ++$relationId;
} else { } else {
$objWriter->writeAttribute('location', str_replace('sheet://', '', $hyperlink->getUrl())); $objWriter->writeAttribute('location', str_replace('sheet://', '', $hyperlink->getUrl()));
} }
if ($hyperlink->getTooltip() != '') { if ($hyperlink->getTooltip() != '') {
@ -656,8 +660,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
foreach ($pSheet->getProtectedCells() as $protectedCell => $passwordHash) { foreach ($pSheet->getProtectedCells() as $protectedCell => $passwordHash) {
// protectedRange // protectedRange
$objWriter->startElement('protectedRange'); $objWriter->startElement('protectedRange');
$objWriter->writeAttribute('name', 'p' . md5($protectedCell)); $objWriter->writeAttribute('name', 'p' . md5($protectedCell));
$objWriter->writeAttribute('sqref', $protectedCell); $objWriter->writeAttribute('sqref', $protectedCell);
if (!empty($passwordHash)) { if (!empty($passwordHash)) {
$objWriter->writeAttribute('password', $passwordHash); $objWriter->writeAttribute('password', $passwordHash);
} }
@ -705,8 +709,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// printOptions // printOptions
$objWriter->startElement('printOptions'); $objWriter->startElement('printOptions');
$objWriter->writeAttribute('gridLines', ($pSheet->getPrintGridlines() ? 'true': 'false')); $objWriter->writeAttribute('gridLines', ($pSheet->getPrintGridlines() ? 'true': 'false'));
$objWriter->writeAttribute('gridLinesSet', 'true'); $objWriter->writeAttribute('gridLinesSet', 'true');
if ($pSheet->getPageSetup()->getHorizontalCentered()) { if ($pSheet->getPageSetup()->getHorizontalCentered()) {
$objWriter->writeAttribute('horizontalCentered', 'true'); $objWriter->writeAttribute('horizontalCentered', 'true');
@ -730,12 +734,12 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
{ {
// pageMargins // pageMargins
$objWriter->startElement('pageMargins'); $objWriter->startElement('pageMargins');
$objWriter->writeAttribute('left', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft())); $objWriter->writeAttribute('left', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft()));
$objWriter->writeAttribute('right', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight())); $objWriter->writeAttribute('right', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight()));
$objWriter->writeAttribute('top', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop())); $objWriter->writeAttribute('top', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop()));
$objWriter->writeAttribute('bottom', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom())); $objWriter->writeAttribute('bottom', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom()));
$objWriter->writeAttribute('header', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getHeader())); $objWriter->writeAttribute('header', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getHeader()));
$objWriter->writeAttribute('footer', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getFooter())); $objWriter->writeAttribute('footer', PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getFooter()));
$objWriter->endElement(); $objWriter->endElement();
} }
@ -758,23 +762,23 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$range = $range[0]; $range = $range[0];
// Strip any worksheet ref // Strip any worksheet ref
if (strpos($range[0],'!') !== false) { if (strpos($range[0],'!') !== false) {
list($ws,$range[0]) = explode('!',$range[0]); list($ws, $range[0]) = explode('!', $range[0]);
} }
$range = implode(':', $range); $range = implode(':', $range);
$objWriter->writeAttribute('ref', str_replace('$','',$range)); $objWriter->writeAttribute('ref', str_replace('$','', $range));
$columns = $pSheet->getAutoFilter()->getColumns(); $columns = $pSheet->getAutoFilter()->getColumns();
if (count($columns > 0)) { if (count($columns > 0)) {
foreach($columns as $columnID => $column) { foreach ($columns as $columnID => $column) {
$rules = $column->getRules(); $rules = $column->getRules();
if (count($rules > 0)) { if (count($rules > 0)) {
$objWriter->startElement('filterColumn'); $objWriter->startElement('filterColumn');
$objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID)); $objWriter->writeAttribute('colId', $pSheet->getAutoFilter()->getColumnOffset($columnID));
$objWriter->startElement( $column->getFilterType()); $objWriter->startElement($column->getFilterType());
if ($column->getJoin() == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND) { if ($column->getJoin() == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND) {
$objWriter->writeAttribute('and', 1); $objWriter->writeAttribute('and', 1);
} }
foreach ($rules as $rule) { foreach ($rules as $rule) {
@ -783,37 +787,37 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
($rule->getValue() === '')) { ($rule->getValue() === '')) {
// Filter rule for Blanks // Filter rule for Blanks
$objWriter->writeAttribute('blank', 1); $objWriter->writeAttribute('blank', 1);
} elseif($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { } elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) {
// Dynamic Filter Rule // Dynamic Filter Rule
$objWriter->writeAttribute('type', $rule->getGrouping()); $objWriter->writeAttribute('type', $rule->getGrouping());
$val = $column->getAttribute('val'); $val = $column->getAttribute('val');
if ($val !== NULL) { if ($val !== null) {
$objWriter->writeAttribute('val', $val); $objWriter->writeAttribute('val', $val);
} }
$maxVal = $column->getAttribute('maxVal'); $maxVal = $column->getAttribute('maxVal');
if ($maxVal !== NULL) { if ($maxVal !== null) {
$objWriter->writeAttribute('maxVal', $maxVal); $objWriter->writeAttribute('maxVal', $maxVal);
} }
} elseif($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) { } elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) {
// Top 10 Filter Rule // Top 10 Filter Rule
$objWriter->writeAttribute('val', $rule->getValue()); $objWriter->writeAttribute('val', $rule->getValue());
$objWriter->writeAttribute('percent', (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0')); $objWriter->writeAttribute('percent', (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0'));
$objWriter->writeAttribute('top', (($rule->getGrouping() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1': '0')); $objWriter->writeAttribute('top', (($rule->getGrouping() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1': '0'));
} else { } else {
// Filter, DateGroupItem or CustomFilter // Filter, DateGroupItem or CustomFilter
$objWriter->startElement($rule->getRuleType()); $objWriter->startElement($rule->getRuleType());
if ($rule->getOperator() !== PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) { if ($rule->getOperator() !== PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) {
$objWriter->writeAttribute('operator', $rule->getOperator()); $objWriter->writeAttribute('operator', $rule->getOperator());
} }
if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) { if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) {
// Date Group filters // Date Group filters
foreach($rule->getValue() as $key => $value) { foreach ($rule->getValue() as $key => $value) {
if ($value > '') $objWriter->writeAttribute($key, $value); if ($value > '') $objWriter->writeAttribute($key, $value);
} }
$objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping()); $objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping());
} else { } else {
$objWriter->writeAttribute('val', $rule->getValue()); $objWriter->writeAttribute('val', $rule->getValue());
} }
$objWriter->endElement(); $objWriter->endElement();
@ -842,24 +846,24 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
{ {
// pageSetup // pageSetup
$objWriter->startElement('pageSetup'); $objWriter->startElement('pageSetup');
$objWriter->writeAttribute('paperSize', $pSheet->getPageSetup()->getPaperSize()); $objWriter->writeAttribute('paperSize', $pSheet->getPageSetup()->getPaperSize());
$objWriter->writeAttribute('orientation', $pSheet->getPageSetup()->getOrientation()); $objWriter->writeAttribute('orientation', $pSheet->getPageSetup()->getOrientation());
if (!is_null($pSheet->getPageSetup()->getScale())) { if (!is_null($pSheet->getPageSetup()->getScale())) {
$objWriter->writeAttribute('scale', $pSheet->getPageSetup()->getScale()); $objWriter->writeAttribute('scale', $pSheet->getPageSetup()->getScale());
} }
if (!is_null($pSheet->getPageSetup()->getFitToHeight())) { if (!is_null($pSheet->getPageSetup()->getFitToHeight())) {
$objWriter->writeAttribute('fitToHeight', $pSheet->getPageSetup()->getFitToHeight()); $objWriter->writeAttribute('fitToHeight', $pSheet->getPageSetup()->getFitToHeight());
} else { } else {
$objWriter->writeAttribute('fitToHeight', '0'); $objWriter->writeAttribute('fitToHeight', '0');
} }
if (!is_null($pSheet->getPageSetup()->getFitToWidth())) { if (!is_null($pSheet->getPageSetup()->getFitToWidth())) {
$objWriter->writeAttribute('fitToWidth', $pSheet->getPageSetup()->getFitToWidth()); $objWriter->writeAttribute('fitToWidth', $pSheet->getPageSetup()->getFitToWidth());
} else { } else {
$objWriter->writeAttribute('fitToWidth', '0'); $objWriter->writeAttribute('fitToWidth', '0');
} }
if (!is_null($pSheet->getPageSetup()->getFirstPageNumber())) { if (!is_null($pSheet->getPageSetup()->getFirstPageNumber())) {
$objWriter->writeAttribute('firstPageNumber', $pSheet->getPageSetup()->getFirstPageNumber()); $objWriter->writeAttribute('firstPageNumber', $pSheet->getPageSetup()->getFirstPageNumber());
$objWriter->writeAttribute('useFirstPageNumber', '1'); $objWriter->writeAttribute('useFirstPageNumber', '1');
} }
@ -877,17 +881,17 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
{ {
// headerFooter // headerFooter
$objWriter->startElement('headerFooter'); $objWriter->startElement('headerFooter');
$objWriter->writeAttribute('differentOddEven', ($pSheet->getHeaderFooter()->getDifferentOddEven() ? 'true' : 'false')); $objWriter->writeAttribute('differentOddEven', ($pSheet->getHeaderFooter()->getDifferentOddEven() ? 'true' : 'false'));
$objWriter->writeAttribute('differentFirst', ($pSheet->getHeaderFooter()->getDifferentFirst() ? 'true' : 'false')); $objWriter->writeAttribute('differentFirst', ($pSheet->getHeaderFooter()->getDifferentFirst() ? 'true' : 'false'));
$objWriter->writeAttribute('scaleWithDoc', ($pSheet->getHeaderFooter()->getScaleWithDocument() ? 'true' : 'false')); $objWriter->writeAttribute('scaleWithDoc', ($pSheet->getHeaderFooter()->getScaleWithDocument() ? 'true' : 'false'));
$objWriter->writeAttribute('alignWithMargins', ($pSheet->getHeaderFooter()->getAlignWithMargins() ? 'true' : 'false')); $objWriter->writeAttribute('alignWithMargins', ($pSheet->getHeaderFooter()->getAlignWithMargins() ? 'true' : 'false'));
$objWriter->writeElement('oddHeader', $pSheet->getHeaderFooter()->getOddHeader()); $objWriter->writeElement('oddHeader', $pSheet->getHeaderFooter()->getOddHeader());
$objWriter->writeElement('oddFooter', $pSheet->getHeaderFooter()->getOddFooter()); $objWriter->writeElement('oddFooter', $pSheet->getHeaderFooter()->getOddFooter());
$objWriter->writeElement('evenHeader', $pSheet->getHeaderFooter()->getEvenHeader()); $objWriter->writeElement('evenHeader', $pSheet->getHeaderFooter()->getEvenHeader());
$objWriter->writeElement('evenFooter', $pSheet->getHeaderFooter()->getEvenFooter()); $objWriter->writeElement('evenFooter', $pSheet->getHeaderFooter()->getEvenFooter());
$objWriter->writeElement('firstHeader', $pSheet->getHeaderFooter()->getFirstHeader()); $objWriter->writeElement('firstHeader', $pSheet->getHeaderFooter()->getFirstHeader());
$objWriter->writeElement('firstFooter', $pSheet->getHeaderFooter()->getFirstFooter()); $objWriter->writeElement('firstFooter', $pSheet->getHeaderFooter()->getFirstFooter());
$objWriter->endElement(); $objWriter->endElement();
} }
@ -914,15 +918,15 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// rowBreaks // rowBreaks
if (!empty($aRowBreaks)) { if (!empty($aRowBreaks)) {
$objWriter->startElement('rowBreaks'); $objWriter->startElement('rowBreaks');
$objWriter->writeAttribute('count', count($aRowBreaks)); $objWriter->writeAttribute('count', count($aRowBreaks));
$objWriter->writeAttribute('manualBreakCount', count($aRowBreaks)); $objWriter->writeAttribute('manualBreakCount', count($aRowBreaks));
foreach ($aRowBreaks as $cell) { foreach ($aRowBreaks as $cell) {
$coords = PHPExcel_Cell::coordinateFromString($cell); $coords = PHPExcel_Cell::coordinateFromString($cell);
$objWriter->startElement('brk'); $objWriter->startElement('brk');
$objWriter->writeAttribute('id', $coords[1]); $objWriter->writeAttribute('id', $coords[1]);
$objWriter->writeAttribute('man', '1'); $objWriter->writeAttribute('man', '1');
$objWriter->endElement(); $objWriter->endElement();
} }
@ -932,15 +936,15 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Second, write column breaks // Second, write column breaks
if (!empty($aColumnBreaks)) { if (!empty($aColumnBreaks)) {
$objWriter->startElement('colBreaks'); $objWriter->startElement('colBreaks');
$objWriter->writeAttribute('count', count($aColumnBreaks)); $objWriter->writeAttribute('count', count($aColumnBreaks));
$objWriter->writeAttribute('manualBreakCount', count($aColumnBreaks)); $objWriter->writeAttribute('manualBreakCount', count($aColumnBreaks));
foreach ($aColumnBreaks as $cell) { foreach ($aColumnBreaks as $cell) {
$coords = PHPExcel_Cell::coordinateFromString($cell); $coords = PHPExcel_Cell::coordinateFromString($cell);
$objWriter->startElement('brk'); $objWriter->startElement('brk');
$objWriter->writeAttribute('id', PHPExcel_Cell::columnIndexFromString($coords[0]) - 1); $objWriter->writeAttribute('id', PHPExcel_Cell::columnIndexFromString($coords[0]) - 1);
$objWriter->writeAttribute('man', '1'); $objWriter->writeAttribute('man', '1');
$objWriter->endElement(); $objWriter->endElement();
} }
@ -965,77 +969,72 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// sheetData // sheetData
$objWriter->startElement('sheetData'); $objWriter->startElement('sheetData');
// Get column count // Get column count
$colCount = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()); $colCount = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn());
// Highest row number // Highest row number
$highestRow = $pSheet->getHighestRow(); $highestRow = $pSheet->getHighestRow();
// Loop through cells // Loop through cells
$cellsByRow = array(); $cellsByRow = array();
foreach ($pSheet->getCellCollection() as $cellID) { foreach ($pSheet->getCellCollection() as $cellID) {
$cellAddress = PHPExcel_Cell::coordinateFromString($cellID); $cellAddress = PHPExcel_Cell::coordinateFromString($cellID);
$cellsByRow[$cellAddress[1]][] = $cellID; $cellsByRow[$cellAddress[1]][] = $cellID;
} }
$currentRow = 0; $currentRow = 0;
while($currentRow++ < $highestRow) { while ($currentRow++ < $highestRow) {
// Get row dimension // Get row dimension
$rowDimension = $pSheet->getRowDimension($currentRow); $rowDimension = $pSheet->getRowDimension($currentRow);
// Write current row? // Write current row?
$writeCurrentRow = isset($cellsByRow[$currentRow]) || $writeCurrentRow = isset($cellsByRow[$currentRow]) || $rowDimension->getRowHeight() >= 0 || $rowDimension->getVisible() == false || $rowDimension->getCollapsed() == true || $rowDimension->getOutlineLevel() > 0 || $rowDimension->getXfIndex() !== null;
$rowDimension->getRowHeight() >= 0 ||
$rowDimension->getVisible() == false ||
$rowDimension->getCollapsed() == true ||
$rowDimension->getOutlineLevel() > 0 ||
$rowDimension->getXfIndex() !== null;
if ($writeCurrentRow) { if ($writeCurrentRow) {
// Start a new row // Start a new row
$objWriter->startElement('row'); $objWriter->startElement('row');
$objWriter->writeAttribute('r', $currentRow); $objWriter->writeAttribute('r', $currentRow);
$objWriter->writeAttribute('spans', '1:' . $colCount); $objWriter->writeAttribute('spans', '1:' . $colCount);
// Row dimensions // Row dimensions
if ($rowDimension->getRowHeight() >= 0) { if ($rowDimension->getRowHeight() >= 0) {
$objWriter->writeAttribute('customHeight', '1'); $objWriter->writeAttribute('customHeight', '1');
$objWriter->writeAttribute('ht', PHPExcel_Shared_String::FormatNumber($rowDimension->getRowHeight())); $objWriter->writeAttribute('ht', PHPExcel_Shared_String::FormatNumber($rowDimension->getRowHeight()));
}
// Row visibility
if ($rowDimension->getVisible() == false) {
$objWriter->writeAttribute('hidden', 'true');
}
// Collapsed
if ($rowDimension->getCollapsed() == true) {
$objWriter->writeAttribute('collapsed', 'true');
}
// Outline level
if ($rowDimension->getOutlineLevel() > 0) {
$objWriter->writeAttribute('outlineLevel', $rowDimension->getOutlineLevel());
}
// Style
if ($rowDimension->getXfIndex() !== null) {
$objWriter->writeAttribute('s', $rowDimension->getXfIndex());
$objWriter->writeAttribute('customFormat', '1');
}
// Write cells
if (isset($cellsByRow[$currentRow])) {
foreach($cellsByRow[$currentRow] as $cellAddress) {
// Write cell
$this->_writeCell($objWriter, $pSheet, $cellAddress, $pStringTable, $aFlippedStringTable);
}
}
// End row
$objWriter->endElement();
} }
// Row visibility
if ($rowDimension->getVisible() == false) {
$objWriter->writeAttribute('hidden', 'true');
}
// Collapsed
if ($rowDimension->getCollapsed() == true) {
$objWriter->writeAttribute('collapsed', 'true');
}
// Outline level
if ($rowDimension->getOutlineLevel() > 0) {
$objWriter->writeAttribute('outlineLevel', $rowDimension->getOutlineLevel());
}
// Style
if ($rowDimension->getXfIndex() !== null) {
$objWriter->writeAttribute('s', $rowDimension->getXfIndex());
$objWriter->writeAttribute('customFormat', '1');
}
// Write cells
if (isset($cellsByRow[$currentRow])) {
foreach ($cellsByRow[$currentRow] as $cellAddress) {
// Write cell
$this->_writeCell($objWriter, $pSheet, $cellAddress, $pStringTable, $aFlippedStringTable);
}
}
// End row
$objWriter->endElement();
} }
}
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
@ -1095,7 +1094,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
switch (strtolower($mappedType)) { switch (strtolower($mappedType)) {
case 'inlinestr': // Inline string case 'inlinestr': // Inline string
if (! $cellValue instanceof PHPExcel_RichText) { if (! $cellValue instanceof PHPExcel_RichText) {
$objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($cellValue) ) ); $objWriter->writeElement('t', PHPExcel_Shared_String::ControlCharacterPHP2OOXML(htmlspecialchars($cellValue)));
} else if ($cellValue instanceof PHPExcel_RichText) { } else if ($cellValue instanceof PHPExcel_RichText) {
$objWriter->startElement('is'); $objWriter->startElement('is');
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue); $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $cellValue);
@ -1115,7 +1114,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
break; break;
case 'f': // Formula case 'f': // Formula
$attributes = $pCell->getFormulaAttributes(); $attributes = $pCell->getFormulaAttributes();
if($attributes['t'] == 'array') { if ($attributes['t'] == 'array') {
$objWriter->startElement('f'); $objWriter->startElement('f');
$objWriter->writeAttribute('t', 'array'); $objWriter->writeAttribute('t', 'array');
$objWriter->writeAttribute('ref', $pCellAddress); $objWriter->writeAttribute('ref', $pCellAddress);
@ -1172,7 +1171,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
* @param boolean $includeCharts Flag indicating if we should include drawing details for charts * @param boolean $includeCharts Flag indicating if we should include drawing details for charts
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeDrawings(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $includeCharts = FALSE) private function _writeDrawings(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $includeCharts = false)
{ {
$chartCount = ($includeCharts) ? $pSheet->getChartCollection()->count() : 0; $chartCount = ($includeCharts) ? $pSheet->getChartCollection()->count() : 0;
// If sheet contains drawings, add the relationships // If sheet contains drawings, add the relationships

View File

@ -333,7 +333,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$iNumColEnd = $rangeBounds[1][0]; $iNumColEnd = $rangeBounds[1][0];
$iInc = $iNumColStart; $iInc = $iNumColStart;
while($iInc <= $iNumColEnd) { while ($iInc <= $iNumColEnd) {
++$countShapes[$sheetIndex]; ++$countShapes[$sheetIndex];
// create an Drawing Object for the dropdown // create an Drawing Object for the dropdown
@ -467,7 +467,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
case 1: // GIF, not supported by BIFF8, we convert to PNG case 1: // GIF, not supported by BIFF8, we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
ob_start(); ob_start();
imagepng(imagecreatefromgif ($filename)); imagepng(imagecreatefromgif($filename));
$blipData = ob_get_contents(); $blipData = ob_get_contents();
ob_end_clean(); ob_end_clean();
break; break;
@ -679,21 +679,18 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x0B) { // Boolean
elseif ($dataProp['type']['data'] == 0x0B) { // Boolean
if ($dataProp['data']['data'] == false) { if ($dataProp['data']['data'] == false) {
$dataSection_Content .= pack('V', 0x0000); $dataSection_Content .= pack('V', 0x0000);
} else { } else {
$dataSection_Content .= pack('V', 0x0001); $dataSection_Content .= pack('V', 0x0001);
} }
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
$dataProp['data']['length'] += 1; $dataProp['data']['length'] += 1;
@ -705,13 +702,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
} } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 8; $dataSection_Content_Offset += 4 + 8;
} } else {
else {
// Data Type Not Used at the moment // Data Type Not Used at the moment
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
@ -867,13 +862,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
$dataProp['data']['length'] += 1; $dataProp['data']['length'] += 1;
@ -885,13 +878,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
} } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 8; $dataSection_Content_Offset += 4 + 8;
} } else {
else {
// Data Type Not Used at the moment // Data Type Not Used at the moment
} }
} }

View File

@ -105,7 +105,8 @@ class PHPExcel_Writer_Excel5_Escher
// dgg data // dgg data
$dggData = $dggData =
pack('VVVV', pack(
'VVVV',
$this->_object->getSpIdMax(), // maximum shape identifier increased by one $this->_object->getSpIdMax(), // maximum shape identifier increased by one
$this->_object->getCDgSaved() + 1, // number of file identifier clusters increased by one $this->_object->getCDgSaved() + 1, // number of file identifier clusters increased by one
$this->_object->getCSpSaved(), $this->_object->getCSpSaved(),
@ -187,7 +188,7 @@ class PHPExcel_Writer_Excel5_Escher
$btMacOS = $this->_object->getBlipType(); $btMacOS = $this->_object->getBlipType();
$data .= pack('CC', $btWin32, $btMacOS); $data .= pack('CC', $btWin32, $btMacOS);
$rgbUid = pack('VVVV', 0,0,0,0); // todo $rgbUid = pack('VVVV', 0, 0, 0, 0); // todo
$data .= $rgbUid; $data .= $rgbUid;
$tag = 0; $tag = 0;
@ -226,7 +227,7 @@ class PHPExcel_Writer_Excel5_Escher
// initialize // initialize
$innerData = ''; $innerData = '';
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo $rgbUid1 = pack('VVVV', 0, 0, 0, 0); // todo
$innerData .= $rgbUid1; $innerData .= $rgbUid1;
$tag = 0xFF; // todo $tag = 0xFF; // todo
@ -253,7 +254,7 @@ class PHPExcel_Writer_Excel5_Escher
// initialize // initialize
$innerData = ''; $innerData = '';
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo $rgbUid1 = pack('VVVV', 0, 0, 0, 0); // todo
$innerData .= $rgbUid1; $innerData .= $rgbUid1;
$tag = 0xFF; // todo $tag = 0xFF; // todo
@ -387,7 +388,7 @@ class PHPExcel_Writer_Excel5_Escher
$header = pack('vvV', $recVerInstance, $recType, $length); $header = pack('vvV', $recVerInstance, $recType, $length);
$data .= $header . pack('VVVV', 0,0,0,0); $data .= $header . pack('VVVV', 0, 0, 0, 0);
} }
$this->_spTypes[] = ($this->_object->getSpType()); $this->_spTypes[] = ($this->_object->getSpType());

View File

@ -1097,7 +1097,7 @@ class PHPExcel_Writer_Excel5_Parser
*/ */
private function _match($token) private function _match($token)
{ {
switch($token) { switch ($token) {
case "+": case "+":
case "-": case "-":
case "*": case "*":
@ -1130,60 +1130,39 @@ class PHPExcel_Writer_Excel5_Parser
break; break;
default: default:
// if it's a reference A1 or $A$1 or $A1 or A$1 // if it's a reference A1 or $A$1 or $A1 or A$1
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != '!')) {
!preg_match("/[0-9]/", $this->_lookahead) and return $token;
($this->_lookahead != ':') and ($this->_lookahead != '.') and } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
($this->_lookahead != '!')) { // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
return $token; return $token;
} }
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) {
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.')) {
return $token; return $token;
} } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) && !preg_match("/[0-9]/", $this->_lookahead)) {
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // if it's a range A1:A2 or $A$1:$A$2
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.')) {
return $token; return $token;
} } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) {
// if it's a range A1:A2 or $A$1:$A$2 // If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token; return $token;
} } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and !preg_match("/[0-9]/", $this->_lookahead)) {
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2 // If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token; return $token;
} } elseif (is_numeric($token) and (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and ($this->_lookahead != '!') and ($this->_lookahead != ':')) {
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2 // If it's a number (check that it's not a sheet name or range)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token; return $token;
} } elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0)) {
// If it's a number (check that it's not a sheet name or range) // If it's a string (of maximum 255 characters)
elseif (is_numeric($token) and
(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
($this->_lookahead != '!') and ($this->_lookahead != ':')) {
return $token; return $token;
} } elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
// If it's a string (of maximum 255 characters) // If it's an error code
elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0)) {
return $token; return $token;
} } elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->_lookahead == "(")) {
// If it's an error code // if it's a function call
elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
return $token; return $token;
} } elseif (substr($token, -1) == ')') {
// if it's a function call // It's an argument of some description (e.g. a named range),
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->_lookahead == "(")) { // precise nature yet to be determined
return $token;
}
// It's an argument of some description (e.g. a named range),
// precise nature yet to be determined
elseif(substr($token,-1) == ')') {
return $token; return $token;
} }
return ''; return '';
@ -1266,7 +1245,10 @@ class PHPExcel_Writer_Excel5_Parser
// If it's a string return a string node // If it's a string return a string node
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) { if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) {
$tmp = str_replace('""', '"', $this->_current_token); $tmp = str_replace('""', '"', $this->_current_token);
if (($tmp == '"') || ($tmp == '')) $tmp = '""'; // Trap for "" that has been used for an empty string if (($tmp == '"') || ($tmp == '')) {
// Trap for "" that has been used for an empty string
$tmp = '""';
}
$result = $this->_createTree($tmp, '', ''); $result = $this->_createTree($tmp, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
@ -1375,38 +1357,33 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// if it's a reference // if it's a reference
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $this->_current_token)) if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $this->_current_token)) {
{
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1) // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
{
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1) // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $this->_current_token)) {
{
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// if it's a range A1:B2 or $A$1:$B$2 // if it's a range A1:B2 or $A$1:$B$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token) or
preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token)) preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $this->_current_token)) {
{
// must be an error? // must be an error?
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
$this->_advance(); $this->_advance();
return $result; return $result;
} }
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2) // If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
{
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
@ -1414,8 +1391,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2) // If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $this->_current_token)) {
{
// must be an error? // must be an error?
//$result = $this->_current_token; //$result = $this->_current_token;
$result = $this->_createTree($this->_current_token, '', ''); $result = $this->_createTree($this->_current_token, '', '');
@ -1423,9 +1399,8 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// If it's a number or a percent // If it's a number or a percent
elseif (is_numeric($this->_current_token)) elseif (is_numeric($this->_current_token)) {
{ if ($this->_lookahead == '%') {
if($this->_lookahead == '%'){
$result = $this->_createTree('ptgPercent', $this->_current_token, ''); $result = $this->_createTree('ptgPercent', $this->_current_token, '');
$this->_advance(); // Skip the percentage operator once we've pre-built that tree $this->_advance(); // Skip the percentage operator once we've pre-built that tree
} else { } else {
@ -1435,8 +1410,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result; return $result;
} }
// if it's a function call // if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $this->_current_token)) {
{
$result = $this->_func(); $result = $this->_func();
return $result; return $result;
} }
@ -1462,13 +1436,10 @@ class PHPExcel_Writer_Excel5_Parser
while ($this->_current_token != ')') { while ($this->_current_token != ')') {
/**/ /**/
if ($num_args > 0) { if ($num_args > 0) {
if ($this->_current_token == "," or if ($this->_current_token == "," || $this->_current_token == ";") {
$this->_current_token == ";")
{
$this->_advance(); // eat the "," or ";" $this->_advance(); // eat the "," or ";"
} else { } else {
throw new PHPExcel_Writer_Exception("Syntax error: comma expected in ". throw new PHPExcel_Writer_Exception("Syntax error: comma expected in function $function, arg #{$num_args}");
"function $function, arg #{$num_args}");
} }
$result2 = $this->_condition(); $result2 = $this->_condition();
$result = $this->_createTree('arg', $result, $result2); $result = $this->_createTree('arg', $result, $result2);
@ -1560,8 +1531,7 @@ class PHPExcel_Writer_Excel5_Parser
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) and
!preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/", $tree['value']) and !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/", $tree['value']) and
!is_numeric($tree['value']) and !is_numeric($tree['value']) and
!isset($this->ptg[$tree['value']])) !isset($this->ptg[$tree['value']])) {
{
// left subtree for a function is always an array. // left subtree for a function is always an array.
if ($tree['left'] != '') { if ($tree['left'] != '') {
$left_tree = $this->toReversePolish($tree['left']); $left_tree = $this->toReversePolish($tree['left']);

View File

@ -845,7 +845,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// option flags // option flags
$options = ($isHidden ? 0x21 : 0x00); $options = ($isHidden ? 0x21 : 0x00);
$extra = pack('Cvvvvv', $extra = pack(
'Cvvvvv',
0x3B, 0x3B,
$sheetIndex - 1, $sheetIndex - 1,
$rangeBounds[0][1] - 1, $rangeBounds[0][1] - 1,
@ -906,7 +907,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$itabFirst = 0; // 1st displayed worksheet $itabFirst = 0; // 1st displayed worksheet
$itabCur = $this->_phpExcel->getActiveSheetIndex(); // Active worksheet $itabCur = $this->_phpExcel->getActiveSheetIndex(); // Active worksheet
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio); $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio);
$this->_append($header . $data); $this->_append($header . $data);
} }
@ -1275,7 +1276,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Pack the RGB data // Pack the RGB data
foreach ($aref as $color) { foreach ($aref as $color) {
foreach ($color as $byte) { foreach ($color as $byte) {
$data .= pack("C",$byte); $data .= pack("C", $byte);
} }
} }

View File

@ -1590,7 +1590,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// record data // record data
$recordData = pack( $recordData = pack(
'vVVCVVvv', 'vVVCVVvv',
0x0867, // repeated record identifier 0x0867, // repeated record identifier
0x0000, // not used 0x0000, // not used
0x0000, // not used 0x0000, // not used
@ -2736,7 +2736,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($spTypes[$i] == 0x00C9) { if ($spTypes[$i] == 0x00C9) {
// Add ftCmo (common object data) subobject // Add ftCmo (common object data) subobject
$objData .= $objData .=
pack('vvvvvVVV', pack(
'vvvvvVVV',
0x0015, // 0x0015 = ftCmo 0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data 0x0012, // length of ftCmo data
0x0014, // object type, 0x0014 = filter 0x0014, // object type, 0x0014 = filter
@ -2756,7 +2757,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
} else { } else {
// Add ftCmo (common object data) subobject // Add ftCmo (common object data) subobject
$objData .= $objData .=
pack('vvvvvVVV', pack(
'vvvvvVVV',
0x0015, // 0x0015 = ftCmo 0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data 0x0012, // length of ftCmo data
0x0008, // object type, 0x0008 = picture 0x0008, // object type, 0x0008 = picture
@ -2770,7 +2772,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// ftEnd // ftEnd
$objData .= $objData .=
pack('vv', pack(
'vv',
0x0000, // 0x0000 = ftEnd 0x0000, // 0x0000 = ftEnd
0x0000 // length of ftEnd data 0x0000 // length of ftEnd data
); );

View File

@ -105,7 +105,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
$objWriter->startElement('office:body'); $objWriter->startElement('office:body');
$objWriter->startElement('office:spreadsheet'); $objWriter->startElement('office:spreadsheet');
$objWriter->writeElement('table:calculation-settings'); $objWriter->writeElement('table:calculation-settings');
$this->_writeSheets($objWriter); $this->writeSheets($objWriter);
$objWriter->writeElement('table:named-expressions'); $objWriter->writeElement('table:named-expressions');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
@ -119,7 +119,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
* *
* @param PHPExcel_Shared_XMLWriter $objWriter * @param PHPExcel_Shared_XMLWriter $objWriter
*/ */
private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter) private function writeSheets(PHPExcel_Shared_XMLWriter $objWriter)
{ {
$pPHPExcel = $this->getParentWriter()->getPHPExcel(); /* @var $pPHPExcel PHPExcel */ $pPHPExcel = $this->getParentWriter()->getPHPExcel(); /* @var $pPHPExcel PHPExcel */
@ -132,7 +132,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
$objWriter->startElement('table:table-column'); $objWriter->startElement('table:table-column');
$objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX); $objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX);
$objWriter->endElement(); $objWriter->endElement();
$this->_writeRows($objWriter, $pPHPExcel->getSheet($i)); $this->writeRows($objWriter, $pPHPExcel->getSheet($i));
$objWriter->endElement(); $objWriter->endElement();
} }
} }
@ -143,7 +143,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
* @param PHPExcel_Shared_XMLWriter $objWriter * @param PHPExcel_Shared_XMLWriter $objWriter
* @param PHPExcel_Worksheet $sheet * @param PHPExcel_Worksheet $sheet
*/ */
private function _writeRows(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet $sheet) private function writeRows(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet $sheet)
{ {
$number_rows_repeated = self::NUMBER_ROWS_REPEATED_MAX; $number_rows_repeated = self::NUMBER_ROWS_REPEATED_MAX;
$span_row = 0; $span_row = 0;
@ -164,7 +164,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
$span_row = 0; $span_row = 0;
} }
$objWriter->startElement('table:table-row'); $objWriter->startElement('table:table-row');
$this->_writeCells($objWriter, $row); $this->writeCells($objWriter, $row);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
$span_row++; $span_row++;
@ -180,7 +180,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
* @param PHPExcel_Worksheet_Row $row * @param PHPExcel_Worksheet_Row $row
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeCells(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet_Row $row) private function writeCells(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet_Row $row)
{ {
$number_cols_repeated = self::NUMBER_COLS_REPEATED_MAX; $number_cols_repeated = self::NUMBER_COLS_REPEATED_MAX;
$prev_column = -1; $prev_column = -1;
@ -189,7 +189,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
$cell = $cells->current(); $cell = $cells->current();
$column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1; $column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
$this->_writeCellSpan($objWriter, $column, $prev_column); $this->writeCellSpan($objWriter, $column, $prev_column);
$objWriter->startElement('table:table-cell'); $objWriter->startElement('table:table-cell');
switch ($cell->getDataType()) { switch ($cell->getDataType()) {
@ -258,7 +258,7 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_
* @param integer $curColumn * @param integer $curColumn
* @param integer $prevColumn * @param integer $prevColumn
*/ */
private function _writeCellSpan(PHPExcel_Shared_XMLWriter $objWriter, $curColumn, $prevColumn) private function writeCellSpan(PHPExcel_Shared_XMLWriter $objWriter, $curColumn, $prevColumn)
{ {
$diff = $curColumn - $prevColumn - 1; $diff = $curColumn - $prevColumn - 1;
if (1 === $diff) { if (1 === $diff) {