forked from PHPOffice/PhpSpreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve workbook bookview attributes on update
Fix for issue PHPOffice#523. When reading then writing a Xlsx spreadsheet, preserve the workbook bookview attributes for the spreadsheet, (e.g., the attribute that hides worksheet tabs.) Beforehand, these attributes were always being set to fixed constants.
- Loading branch information
Showing
5 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Xlsx; | ||
|
||
use PhpOffice\PhpSpreadsheet\Settings; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HiddenTabsTest extends TestCase | ||
{ | ||
/** | ||
* Test that the worksheet tabs remain hidden when reading and writing a XLSX document | ||
* with hidden worksheets tabs. | ||
*/ | ||
public function testUpdateWithHiddenTabs() | ||
{ | ||
$sourceFilename = __DIR__ . '/../../../data/Writer/XLSX/hidden_tabs.xlsx'; | ||
Settings::setLibXmlLoaderOptions(null); // reset to default options | ||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); | ||
$excel = $reader->load($sourceFilename); | ||
|
||
$targetFilename = tempnam(sys_get_temp_dir(), 'tst'); | ||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($excel); | ||
$writer->save($targetFilename); | ||
|
||
try { | ||
$excel2 = $reader->load($targetFilename); | ||
$this->assertEquals('0', $excel2->getWorkbookViewAttribute('showSheetTabs')); | ||
} finally { | ||
@unlink($targetFilename); | ||
} | ||
} | ||
} |
Binary file not shown.