Skip to content

Commit 3bd2b89

Browse files
author
Mark Baker
committed
Bugfix: Work item PHPOfficeGH-130 - Single cell print area
1 parent 9de3d5a commit 3bd2b89

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Classes/PHPExcel/Reader/Excel2007.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function listWorksheetInfo($pFilename)
203203
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
204204

205205
$xml = new XMLReader();
206-
$res = $xml->open('zip://'.realpath($pFilename).'#'."$dir/$fileWorksheet");
206+
$res = $xml->open('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet");
207207
$xml->setParserProperty(2,true);
208208

209209
$currCells = 0;
@@ -1361,7 +1361,7 @@ public function load($pFilename)
13611361
$hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );
13621362
}
13631363

1364-
$hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false);
1364+
$hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false);
13651365
$hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
13661366
$hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
13671367
$hfImages[ (string)$shape['id'] ]->setHeight($style['height']);
@@ -1416,7 +1416,7 @@ public function load($pFilename)
14161416
$objDrawing = new PHPExcel_Worksheet_Drawing;
14171417
$objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
14181418
$objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
1419-
$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
1419+
$objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
14201420
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
14211421
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
14221422
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
@@ -1456,7 +1456,7 @@ public function load($pFilename)
14561456
$objDrawing = new PHPExcel_Worksheet_Drawing;
14571457
$objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
14581458
$objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
1459-
$objDrawing->setPath("zip://$pFilename#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
1459+
$objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
14601460
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));
14611461
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
14621462
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
@@ -1560,6 +1560,9 @@ public function load($pFilename)
15601560
foreach($rangeSets as $rangeSet) {
15611561
$range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark?
15621562
$rangeSet = isset($range[1]) ? $range[1] : $range[0];
1563+
if (strpos($rangeSet, ':') === FALSE) {
1564+
$rangeSet = $rangeSet . ':' . $rangeSet;
1565+
}
15631566
$newRangeSets[] = str_replace('$', '', $rangeSet);
15641567
}
15651568
$docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets));

Classes/PHPExcel/Reader/Excel5.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,6 @@ public function load($pFilename)
956956
case pack('C', 0x06):
957957
// print area
958958
// in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2
959-
960959
$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
961960
962961
$extractedRanges = array();
@@ -966,9 +965,12 @@ public function load($pFilename)
966965
// Bar!$A$1:$IV$2
967966

968967
$explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark?
969-
$sheetName = $explodes[0];
968+
$sheetName = trim($explodes[0], "'");
970969

971970
if (count($explodes) == 2) {
971+
if (strpos($explodes[1], ':') === FALSE) {
972+
$explodes[1] = $explodes[1] . ':' . $explodes[1];
973+
}
972974
$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
973975
}
974976
}

Classes/PHPExcel/Writer/Excel2007.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ public function save($pFilename = null)
313313
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
314314
$imageContents = null;
315315
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
316-
317316
if (strpos($imagePath, 'zip://') !== false) {
318317
$imagePath = substr($imagePath, 6);
319318
$imagePathSplitted = explode('#', $imagePath);

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Fixed in develop branch:
3232
- Bugfix: (MBaker) Work item GH-67 - Cache directory for DiscISAM cache storage cannot be set
3333
- Bugfix: (MBaker) Work item 17976 - Fix to Excel2007 Reader for hyperlinks with an anchor fragment (following a #), otherwise they were treated as sheet references
3434
- Bugfix: (MBaker) Work item 18963 - getSheetNames() fails on numeric (floating point style) names with trailing zeroes
35+
- Bugfix: (MBaker) Work item GH-130 - Single cell print area
3536
- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency
3637
- General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir
3738
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

0 commit comments

Comments
 (0)