Skip to content

Commit ab0d311

Browse files
committed
add ability to set codepage explicitly for BIFF5
If BIFF5 excel 95 file doesn't have codepage record, the default codepage CP1252 is used and can't be change. That causes to problems with decoding cyrillic text.
1 parent be415fa commit ab0d311

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
1111

1212
- Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292)
1313
- Support CSV files with data wrapping a lot of lines [#1468](https://github.com/PHPOffice/PhpSpreadsheet/pull/1468)
14+
- Add ability to set codepage explicitly for BIFF5 [#1018](https://github.com/PHPOffice/PhpSpreadsheet/issues/1018)
1415

1516
### Fixed
1617

src/PhpSpreadsheet/Reader/Xls.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ public function canRead($pFilename)
439439
}
440440
}
441441

442+
/**
443+
* @param string $codepage
444+
*/
445+
public function setCodepage($codepage): void
446+
{
447+
$this->codepage = $codepage;
448+
}
449+
442450
/**
443451
* Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object.
444452
*
@@ -640,7 +648,7 @@ public function load($pFilename)
640648

641649
// initialize
642650
$this->pos = 0;
643-
$this->codepage = 'CP1252';
651+
$this->codepage = $this->codepage == null ? 'CP1252' : $this->codepage;
644652
$this->formats = [];
645653
$this->objFonts = [];
646654
$this->palette = [];

0 commit comments

Comments
 (0)