Bugfix: Work item GH-130 - Single cell print area

This commit is contained in:
Mark Baker 2013-01-22 21:43:31 +00:00
parent 9de3d5a62b
commit 3bd2b89ff6
4 changed files with 12 additions and 7 deletions

View File

@ -203,7 +203,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xml = new XMLReader(); $xml = new XMLReader();
$res = $xml->open('zip://'.realpath($pFilename).'#'."$dir/$fileWorksheet"); $res = $xml->open('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet");
$xml->setParserProperty(2,true); $xml->setParserProperty(2,true);
$currCells = 0; $currCells = 0;
@ -1361,7 +1361,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] ); $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );
} }
$hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false); $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(false); $hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
$hfImages[ (string)$shape['id'] ]->setWidth($style['width']); $hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
$hfImages[ (string)$shape['id'] ]->setHeight($style['height']); $hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
@ -1416,7 +1416,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing = new PHPExcel_Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); $objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1)); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
@ -1456,7 +1456,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing = new PHPExcel_Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); $objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1)); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
@ -1560,6 +1560,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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) {
$rangeSet = $rangeSet . ':' . $rangeSet;
}
$newRangeSets[] = str_replace('$', '', $rangeSet); $newRangeSets[] = str_replace('$', '', $rangeSet);
} }
$docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets)); $docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets));

View File

@ -956,7 +956,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
case pack('C', 0x06): case pack('C', 0x06):
// print area // print area
// in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2 // in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2
$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
$extractedRanges = array(); $extractedRanges = array();
@ -966,9 +965,12 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// Bar!$A$1:$IV$2 // Bar!$A$1:$IV$2
$explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark?
$sheetName = $explodes[0]; $sheetName = trim($explodes[0], "'");
if (count($explodes) == 2) { if (count($explodes) == 2) {
if (strpos($explodes[1], ':') === FALSE) {
$explodes[1] = $explodes[1] . ':' . $explodes[1];
}
$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
} }
} }

View File

@ -313,7 +313,6 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) { if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
$imageContents = null; $imageContents = null;
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath(); $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
if (strpos($imagePath, 'zip://') !== false) { if (strpos($imagePath, 'zip://') !== false) {
$imagePath = substr($imagePath, 6); $imagePath = substr($imagePath, 6);
$imagePathSplitted = explode('#', $imagePath); $imagePathSplitted = explode('#', $imagePath);

View File

@ -32,6 +32,7 @@ Fixed in develop branch:
- Bugfix: (MBaker) Work item GH-67 - Cache directory for DiscISAM cache storage cannot be set - Bugfix: (MBaker) Work item GH-67 - Cache directory for DiscISAM cache storage cannot be set
- Bugfix: (MBaker) Work item 17976 - Fix to Excel2007 Reader for hyperlinks with an anchor fragment (following a #), otherwise they were treated as sheet references - Bugfix: (MBaker) Work item 17976 - Fix to Excel2007 Reader for hyperlinks with an anchor fragment (following a #), otherwise they were treated as sheet references
- Bugfix: (MBaker) Work item 18963 - getSheetNames() fails on numeric (floating point style) names with trailing zeroes - Bugfix: (MBaker) Work item 18963 - getSheetNames() fails on numeric (floating point style) names with trailing zeroes
- Bugfix: (MBaker) Work item GH-130 - Single cell print area
- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency - General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency
- General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir - General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir
Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used