diff --git a/.gitignore b/.gitignore index 9b670cb..bac498d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store test -materials \ No newline at end of file +materials +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a09a9..591ca8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### v.0.5.12 2016-03-18 + +- Added a fix for recognising dates in XLS files created by LibreOffice + ### v.0.5.11 2015-04-30 - Added a special case for cells formatted as text in XLSX. Previously leading zeros would get truncated if a text cell contained only numbers. @@ -50,10 +54,10 @@ Currently only decimal number values are converted to PHP's floats. ### v.0.5.1 2013-06-27 -- Fixed file type choice when using mime-types (previously there were problems with +- Fixed file type choice when using mime-types (previously there were problems with XLSX and ODS mime-types) (Thanks to [incratec](https://github.com/incratec)) -- Fixed an error in XLSX iterator where `current()` would advance the iterator forward +- Fixed an error in XLSX iterator where `current()` would advance the iterator forward with each call. (Thanks to [osuwariboy](https://github.com/osuwariboy)) ### v.0.5.0 2013-06-17 @@ -62,19 +66,19 @@ with each call. (Thanks to [osuwariboy](https://github.com/osuwariboy)) - The `Sheets()` method lets you retrieve a list of all sheets present in the file. - `ChangeSheet($Index)` method changes the sheet in the reader to the one specified. -- Previously temporary files that were extracted, were deleted after the SpreadsheetReader -was destroyed but the empty directories remained. Now those are cleaned up as well. +- Previously temporary files that were extracted, were deleted after the SpreadsheetReader +was destroyed but the empty directories remained. Now those are cleaned up as well. ### v.0.4.3 2013-06-14 -- Bugfix for shared string caching in XLSX files. When the shared string count was larger -than the caching limit, instead of them being read from file, empty strings were returned. +- Bugfix for shared string caching in XLSX files. When the shared string count was larger +than the caching limit, instead of them being read from file, empty strings were returned. ### v.0.4.2 2013-06-02 -- XLS file reading relies on the external Spreadsheet_Excel_Reader class which, by default, -reads additional information about cells like fonts, styles, etc. Now that is disabled -to save some memory since the style data is unnecessary anyway. +- XLS file reading relies on the external Spreadsheet_Excel_Reader class which, by default, +reads additional information about cells like fonts, styles, etc. Now that is disabled +to save some memory since the style data is unnecessary anyway. (Thanks to [ChALkeR](https://github.com/ChALkeR) for the tip.) -Martins Pilsetnieks \ No newline at end of file +Martins Pilsetnieks diff --git a/README.md b/README.md index 6b1a451..1edac3c 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,15 @@ Example: If a sheet is changed to the same that is currently open, the position in the file still reverts to the beginning, so as to conform to the same behavior as when changed to a different sheet. +Passing options: + + "/tmp" + ); + $Reader = new SpreadsheetReader('example.xlsx', false, false, $Options); + ?> + ### Testing From the command line: diff --git a/SpreadsheetReader.php b/SpreadsheetReader.php index b019f8f..cbc288d 100644 --- a/SpreadsheetReader.php +++ b/SpreadsheetReader.php @@ -13,7 +13,7 @@ class SpreadsheetReader implements SeekableIterator, Countable const TYPE_ODS = 'ODS'; private $Options = array( - 'Delimiter' => '', + 'Delimiter' => ';', 'Enclosure' => '"' ); @@ -37,7 +37,7 @@ class SpreadsheetReader implements SeekableIterator, Countable * @param string Original filename (in case of an uploaded file), used to determine file type, optional * @param string MIME type from an upload, used to determine file type, optional */ - public function __construct($Filepath, $OriginalFilename = false, $MimeType = false) + public function __construct($Filepath, $OriginalFilename = false, $MimeType = false, $Options = array()) { if (!is_readable($Filepath)) { @@ -158,12 +158,15 @@ public function __construct($Filepath, $OriginalFilename = false, $MimeType = fa } } + // Get options before creating handle + $this -> Options = array_merge($this -> Options, $Options); + // 2. Create handle switch ($this -> Type) { case self::TYPE_XLSX: self::Load(self::TYPE_XLSX); - $this -> Handle = new SpreadsheetReader_XLSX($Filepath); + $this -> Handle = new SpreadsheetReader_XLSX($Filepath, $this -> Options); break; case self::TYPE_CSV: self::Load(self::TYPE_CSV); diff --git a/SpreadsheetReader_CSV.php b/SpreadsheetReader_CSV.php index 1cae82b..77e8986 100644 --- a/SpreadsheetReader_CSV.php +++ b/SpreadsheetReader_CSV.php @@ -11,7 +11,8 @@ class SpreadsheetReader_CSV implements Iterator, Countable */ private $Options = array( 'Delimiter' => ';', - 'Enclosure' => '"' + 'Enclosure' => '"', + 'Encoding' => 'auto' ); private $Encoding = 'UTF-8'; @@ -49,6 +50,43 @@ public function __construct($Filepath, array $Options = null) $this -> Options = array_merge($this -> Options, $Options); $this -> Handle = fopen($Filepath, 'r'); + if( $this -> Options['Encoding'] == "auto" ) + { + $this -> AutoDetectEncoding(); + } + else{ + $this -> Encoding = $this -> Options['Encoding']; + } + + // Checking for the delimiter if it should be determined automatically + if (!$this -> Options['Delimiter']) + { + // fgetcsv needs single-byte separators + $Semicolon = ';'; + $Tab = "\t"; + $Comma = ','; + + // Reading the first row and checking if a specific separator character + // has more columns than others (it means that most likely that is the delimiter). + $SemicolonCount = count(fgetcsv($this -> Handle, null, $Semicolon)); + fseek($this -> Handle, $this -> BOMLength); + $TabCount = count(fgetcsv($this -> Handle, null, $Tab)); + fseek($this -> Handle, $this -> BOMLength); + $CommaCount = count(fgetcsv($this -> Handle, null, $Comma)); + fseek($this -> Handle, $this -> BOMLength); + + $Delimiter = $Semicolon; + if ($TabCount > $SemicolonCount || $CommaCount > $SemicolonCount) + { + $Delimiter = $CommaCount > $TabCount ? $Comma : $Tab; + } + + $this -> Options['Delimiter'] = $Delimiter; + } + } + + private function AutoDetectEncoding() + { // Checking the file for byte-order mark to determine encoding $BOM16 = bin2hex(fread($this -> Handle, 2)); if ($BOM16 == 'fffe') @@ -95,32 +133,6 @@ public function __construct($Filepath, array $Options = null) { fseek($this -> Handle, $this -> BOMLength); } - - // Checking for the delimiter if it should be determined automatically - if (!$this -> Options['Delimiter']) - { - // fgetcsv needs single-byte separators - $Semicolon = ';'; - $Tab = "\t"; - $Comma = ','; - - // Reading the first row and checking if a specific separator character - // has more columns than others (it means that most likely that is the delimiter). - $SemicolonCount = count(fgetcsv($this -> Handle, null, $Semicolon)); - fseek($this -> Handle, $this -> BOMLength); - $TabCount = count(fgetcsv($this -> Handle, null, $Tab)); - fseek($this -> Handle, $this -> BOMLength); - $CommaCount = count(fgetcsv($this -> Handle, null, $Comma)); - fseek($this -> Handle, $this -> BOMLength); - - $Delimiter = $Semicolon; - if ($TabCount > $SemicolonCount || $CommaCount > $SemicolonCount) - { - $Delimiter = $CommaCount > $TabCount ? $Comma : $Tab; - } - - $this -> Options['Delimiter'] = $Delimiter; - } } /** diff --git a/SpreadsheetReader_XLSX.php b/SpreadsheetReader_XLSX.php index 9cf8d12..230349c 100644 --- a/SpreadsheetReader_XLSX.php +++ b/SpreadsheetReader_XLSX.php @@ -20,7 +20,7 @@ class SpreadsheetReader_XLSX implements Iterator, Countable * With large shared string caches there are huge performance gains, however a lot of memory could be used which * can be a problem, especially on shared hosting. */ - const SHARED_STRING_CACHE_LIMIT = 50000; + const SHARED_STRING_CACHE_LIMIT = null; private $Options = array( 'TempDir' => '', @@ -370,17 +370,29 @@ public function Sheets() $this -> Sheets = array(); foreach ($this -> WorkbookXML -> sheets -> sheet as $Index => $Sheet) { - $Attributes = $Sheet -> attributes('r', true); - foreach ($Attributes as $Name => $Value) + $AttributesWithPrefix = $Sheet -> attributes('r', true); + $Attributes = $Sheet -> attributes(); + + $rId = 0; + $sheetId = 0; + + foreach ($AttributesWithPrefix as $Name => $Value) { if ($Name == 'id') { - $SheetID = (int)str_replace('rId', '', (string)$Value); + $rId = (int)str_replace('rId', '', (string)$Value); + break; + } + } + foreach ($Attributes as $Name => $Value) + { + if ($Name == 'sheetId') { + $sheetId = (int)$Value; break; } } - $this -> Sheets[$SheetID] = (string)$Sheet['name']; + $this -> Sheets[min($rId, $sheetId)] = (string)$Sheet['name']; } ksort($this -> Sheets); } @@ -453,7 +465,7 @@ private function PrepareSharedStringCache() case 't': if ($this -> SharedStrings -> nodeType == XMLReader::END_ELEMENT) { - continue; + break; } $CacheValue .= $this -> SharedStrings -> readString(); break; @@ -556,7 +568,7 @@ private function GetSharedString($Index) $this -> SharedStrings -> next('si'); $this -> SSForwarded = true; $this -> SharedStringIndex++; - continue; + break; } else { @@ -578,7 +590,7 @@ private function GetSharedString($Index) case 't': if ($this -> SharedStrings -> nodeType == XMLReader::END_ELEMENT) { - continue; + break; } $Value .= $this -> SharedStrings -> readString(); break; @@ -891,7 +903,7 @@ private function FormatValue($Value, $Index) // Scaling $Value = $Value / $Format['Scale']; - if (!empty($Format['MinWidth']) && $Format['Decimals']) + if (!empty($Format['MinWidth'])) { if ($Format['Thousands']) { @@ -910,7 +922,7 @@ private function FormatValue($Value, $Index) // Currency/Accounting if ($Format['Currency']) { - $Value = preg_replace('', $Format['Currency'], $Value); + $Value = preg_replace('/\[.+\]/', $Format['Currency'], $Value); } } @@ -929,7 +941,7 @@ private function FormatValue($Value, $Index) public function GeneralFormat($Value) { // Numeric format - if (is_numeric($Value)) + if (is_numeric($Value) && $Value[0] != 0) { $Value = (float)$Value; } @@ -1046,7 +1058,7 @@ public function next() // If it is a closing tag, skip it if ($this -> Worksheet -> nodeType == XMLReader::END_ELEMENT) { - continue; + break; } $StyleId = (int)$this -> Worksheet -> getAttribute('s'); @@ -1080,7 +1092,7 @@ public function next() case 'is': if ($this -> Worksheet -> nodeType == XMLReader::END_ELEMENT) { - continue; + break; } $Value = $this -> Worksheet -> readString(); @@ -1099,6 +1111,14 @@ public function next() { $Value = $this -> GeneralFormat($Value); } + elseif ($Value) + { + $Value = $this -> GeneralFormat($Value); + } + elseif ($Value) + { + $Value = $this -> GeneralFormat($Value); + } $this -> CurrentRow[$Index] = $Value; break; diff --git a/composer.json b/composer.json index 0e64a78..a0e38e2 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,6 @@ "description": "Spreadsheet reader library for Excel, OpenOffice and structured text files", "keywords": ["spreadsheet", "xls", "xlsx", "ods", "csv", "excel", "openoffice"], "homepage": "https://github.com/nuovo/spreadsheet-reader", - "version": "0.5.11", - "time": "2015-04-30", "type": "library", "license": ["MIT"], "authors": [ diff --git a/php-excel-reader/excel_reader2.php b/php-excel-reader/excel_reader2.php index 75351b7..991e163 100644 --- a/php-excel-reader/excel_reader2.php +++ b/php-excel-reader/excel_reader2.php @@ -77,7 +77,7 @@ function GetInt4d($data, $pos) { function gmgetdate($ts = null){ $k = array('seconds','minutes','hours','mday','wday','mon','year','yday','weekday','month',0); return(array_comb($k,explode(":",gmdate('s:i:G:j:w:n:Y:z:l:F:U',is_null($ts)?time():$ts)))); - } + } // Added for PHP4 compatibility function array_comb($array1, $array2) { @@ -94,7 +94,7 @@ function v($data,$pos) { class OLERead { var $data = ''; - function OLERead(){ } + function __construct(){ } function read($sFileName){ // check if file exist and is readable (Darko Miljanovic) @@ -321,7 +321,7 @@ function myHex($d) { if ($d < 16) return "0" . dechex($d); return dechex($d); } - + function dumpHexData($data, $pos, $length) { $info = ""; for ($i = 0; $i <= $length; $i++) { @@ -394,7 +394,7 @@ function colcount($sheet=0) { } function colwidth($col,$sheet=0) { // Col width is actually the width of the number 0. So we have to estimate and come close - return $this->colInfo[$sheet][$col]['width']/9142*200; + return $this->colInfo[$sheet][$col]['width']/9142*200; } function colhidden($col,$sheet=0) { return !!$this->colInfo[$sheet][$col]['hidden']; @@ -405,7 +405,7 @@ function rowheight($row,$sheet=0) { function rowhidden($row,$sheet=0) { return !!$this->rowInfo[$sheet][$row]['hidden']; } - + // GET THE CSS FOR FORMATTING // ========================== function style($row,$col,$sheet=0,$properties='') { @@ -467,10 +467,10 @@ function style($row,$col,$sheet=0,$properties='') { if ($bRight!="" && $bRightCol!="") { $css .= "border-right-color:" . $bRightCol .";"; } if ($bTop!="" && $bTopCol!="") { $css .= "border-top-color:" . $bTopCol . ";"; } if ($bBottom!="" && $bBottomCol!="") { $css .= "border-bottom-color:" . $bBottomCol .";"; } - + return $css; } - + // FORMAT PROPERTIES // ================= function format($row,$col,$sheet=0) { @@ -482,7 +482,7 @@ function formatIndex($row,$col,$sheet=0) { function formatColor($row,$col,$sheet=0) { return $this->info($row,$col,'formatColor',$sheet); } - + // CELL (XF) PROPERTIES // ==================== function xfRecord($row,$col,$sheet=0) { @@ -581,7 +581,7 @@ function height($row,$col,$sheet=0) { function font($row,$col,$sheet=0) { return $this->fontProperty($row,$col,$sheet,'font'); } - + // DUMP AN HTML TABLE OF THE ENTIRE XLS DATA // ========================================= function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel') { @@ -600,7 +600,7 @@ function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel } $out .= "\n"; } - + $out .= "\n"; for($row=1;$row<=$this->rowcount($sheet);$row++) { $rowheight = $this->rowheight($row,$sheet); @@ -631,8 +631,8 @@ function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel $out .= "\n\t\t 1?" colspan=$colspan":"") . ($rowspan > 1?" rowspan=$rowspan":"") . ">"; $val = $this->val($row,$col,$sheet); if ($val=='') { $val=" "; } - else { - $val = htmlentities($val); + else { + $val = htmlentities($val); $link = $this->hyperlink($row,$col,$sheet); if ($link!='') { $val = "$val"; @@ -647,7 +647,7 @@ function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel $out .= ""; return $out; } - + // -------------- // END PUBLIC API @@ -658,7 +658,7 @@ function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel var $xfRecords = array(); var $colInfo = array(); var $rowInfo = array(); - + var $sst = array(); var $sheets = array(); @@ -807,35 +807,35 @@ function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel 0x0B => "Thin dash-dot-dotted", 0x0C => "Medium dash-dot-dotted", 0x0D => "Slanted medium dash-dotted" - ); + ); var $lineStylesCss = array( - "Thin" => "1px solid", - "Medium" => "2px solid", - "Dashed" => "1px dashed", - "Dotted" => "1px dotted", - "Thick" => "3px solid", - "Double" => "double", - "Hair" => "1px solid", - "Medium dashed" => "2px dashed", - "Thin dash-dotted" => "1px dashed", - "Medium dash-dotted" => "2px dashed", - "Thin dash-dot-dotted" => "1px dashed", - "Medium dash-dot-dotted" => "2px dashed", - "Slanted medium dash-dotte" => "2px dashed" + "Thin" => "1px solid", + "Medium" => "2px solid", + "Dashed" => "1px dashed", + "Dotted" => "1px dotted", + "Thick" => "3px solid", + "Double" => "double", + "Hair" => "1px solid", + "Medium dashed" => "2px dashed", + "Thin dash-dotted" => "1px dashed", + "Medium dash-dotted" => "2px dashed", + "Thin dash-dot-dotted" => "1px dashed", + "Medium dash-dot-dotted" => "2px dashed", + "Slanted medium dash-dotte" => "2px dashed" ); - + function read16bitstring($data, $start) { $len = 0; while (ord($data[$start + $len]) + ord($data[$start + $len + 1]) > 0) $len++; return substr($data, $start, $len); } - + // ADDED by Matt Kruse for better formatting function _format_value($format,$num,$f) { // 49==TEXT format // http://code.google.com/p/php-excel-reader/issues/detail?id=7 - if ( (!$f && $format=="%s") || ($f==49) || ($format=="GENERAL") ) { + if ( (!$f && $format=="%s") || ($f==49) || (strtoupper($format)=="GENERAL") ) { return array('string'=>$num, 'formatColor'=>null); } @@ -860,13 +860,13 @@ function _format_value($format,$num,$f) { $color = strtolower($matches[1]); $pattern = preg_replace($color_regex,"",$pattern); } - + // In Excel formats, "_" is used to add spacing, which we can't do in HTML $pattern = preg_replace("/_./","",$pattern); - + // Some non-number characters are escaped with \, which we don't need $pattern = preg_replace("/\\\/","",$pattern); - + // Some non-number strings are quoted, so we'll get rid of the quotes $pattern = preg_replace("/\"/","",$pattern); @@ -901,6 +901,15 @@ function _format_value($format,$num,$f) { $pattern = preg_replace($number_regex, $formatted, $pattern); } + // prevent changing of big integers to '@' + if ($pattern === '@') { + $pattern = strval($num); + } + + if (preg_match('/\$(?.*)-/', $pattern, $matches)) { + $pattern = preg_replace('/\[.+\]/', $matches['currency'], $pattern); + } + return array( 'string'=>$pattern, 'formatColor'=>$color @@ -912,10 +921,10 @@ function _format_value($format,$num,$f) { * * Some basic initialisation */ - function Spreadsheet_Excel_Reader($file='',$store_extended_info=true,$outputEncoding='') { + function __construct($file='',$store_extended_info=true,$outputEncoding='') { $this->_ole = new OLERead(); $this->setUTFEncoder('iconv'); - if ($outputEncoding != '') { + if ($outputEncoding != '') { $this->setOutputEncoding($outputEncoding); } for ($i=1; $i<245; $i++) { @@ -1163,7 +1172,7 @@ function _parse() { $font = substr($data, $pos+20, $numchars); } else { $font = substr($data, $pos+20, $numchars*2); - $font = $this->_encodeUTF16($font); + $font = $this->_encodeUTF16($font); } $this->fontRecords[] = array( 'height' => $height / 20, @@ -1216,14 +1225,14 @@ function _parse() { $xf['borderRight'] = $this->lineStyles[($border & 0xF0) >> 4]; $xf['borderTop'] = $this->lineStyles[($border & 0xF00) >> 8]; $xf['borderBottom'] = $this->lineStyles[($border & 0xF000) >> 12]; - + $xf['borderLeftColor'] = ($border & 0x7F0000) >> 16; $xf['borderRightColor'] = ($border & 0x3F800000) >> 23; $border = (ord($data[$pos+18]) | ord($data[$pos+19]) << 8); $xf['borderTopColor'] = ($border & 0x7F); $xf['borderBottomColor'] = ($border & 0x3F80) >> 7; - + if (array_key_exists($indexCode, $this->dateFormats)) { $xf['type'] = 'date'; $xf['format'] = $this->dateFormats[$indexCode]; @@ -1244,21 +1253,28 @@ function _parse() { if (preg_match("/[^hmsday\/\-:\s\\\,AMP]/i", $tmp) == 0) { // found day and time format $isdate = TRUE; $formatstr = $tmp; - $formatstr = str_replace(array('AM/PM','mmmm','mmm'), array('a','F','M'), $formatstr); - // m/mm are used for both minutes and months - oh SNAP! - // This mess tries to fix for that. - // 'm' == minutes only if following h/hh or preceding s/ss - $formatstr = preg_replace("/(h:?)mm?/","$1i", $formatstr); - $formatstr = preg_replace("/mm?(:?s)/","i$1", $formatstr); - // A single 'm' = n in PHP - $formatstr = preg_replace("/(^|[^m])m([^m]|$)/", '$1n$2', $formatstr); - $formatstr = preg_replace("/(^|[^m])m([^m]|$)/", '$1n$2', $formatstr); - // else it's months - $formatstr = str_replace('mm', 'm', $formatstr); - // Convert single 'd' to 'j' - $formatstr = preg_replace("/(^|[^d])d([^d]|$)/", '$1j$2', $formatstr); - $formatstr = str_replace(array('dddd','ddd','dd','yyyy','yy','hh','h'), array('l','D','d','Y','y','H','g'), $formatstr); - $formatstr = preg_replace("/ss?/", 's', $formatstr); + if ($formatstr === 'YYYY/MM/DD' || $formatstr === 'YYYY\-MM\-DD') { + // LibreOffice turns this pattern into invalid dates: + // 2015201520152015/OctOct/WedWed + // here we fix it + $formatstr = 'Y-m-d'; + } else { + $formatstr = str_replace(array('AM/PM','mmmm','mmm'), array('a','F','M'), $formatstr); + // m/mm are used for both minutes and months - oh SNAP! + // This mess tries to fix for that. + // 'm' == minutes only if following h/hh or preceding s/ss + $formatstr = preg_replace("/(h:?)mm?/","$1i", $formatstr); + $formatstr = preg_replace("/mm?(:?s)/","i$1", $formatstr); + // A single 'm' = n in PHP + $formatstr = preg_replace("/(^|[^m])m([^m]|$)/", '$1n$2', $formatstr); + $formatstr = preg_replace("/(^|[^m])m([^m]|$)/", '$1n$2', $formatstr); + // else it's months + $formatstr = str_replace('mm', 'm', $formatstr); + // Convert single 'd' to 'j' + $formatstr = preg_replace("/(^|[^d])d([^d]|$)/", '$1j$2', $formatstr); + $formatstr = str_replace(array('dddd','ddd','dd','yyyy','yy','hh','h'), array('l','D','d','Y','y','H','g'), $formatstr); + $formatstr = preg_replace("/ss?/", 's', $formatstr); + } } } } @@ -1553,24 +1569,24 @@ function _parsesheet($spos) { } $linkdata['desc'] = $udesc; $linkdata['link'] = $this->_encodeUTF16($ulink); - for ($r=$row; $r<=$row2; $r++) { + for ($r=$row; $r<=$row2; $r++) { for ($c=$column; $c<=$column2; $c++) { $this->sheets[$this->sn]['cellsInfo'][$r+1][$c+1]['hyperlink'] = $linkdata; } } break; case SPREADSHEET_EXCEL_READER_TYPE_DEFCOLWIDTH: - $this->defaultColWidth = ord($data[$spos+4]) | ord($data[$spos+5]) << 8; + $this->defaultColWidth = ord($data[$spos+4]) | ord($data[$spos+5]) << 8; break; case SPREADSHEET_EXCEL_READER_TYPE_STANDARDWIDTH: - $this->standardColWidth = ord($data[$spos+4]) | ord($data[$spos+5]) << 8; + $this->standardColWidth = ord($data[$spos+4]) | ord($data[$spos+5]) << 8; break; case SPREADSHEET_EXCEL_READER_TYPE_COLINFO: $colfrom = ord($data[$spos+0]) | ord($data[$spos+1]) << 8; $colto = ord($data[$spos+2]) | ord($data[$spos+3]) << 8; - $cw = ord($data[$spos+4]) | ord($data[$spos+5]) << 8; - $cxf = ord($data[$spos+6]) | ord($data[$spos+7]) << 8; - $co = ord($data[$spos+8]); + $cw = ord($data[$spos+4]) | ord($data[$spos+5]) << 8; + $cxf = ord($data[$spos+6]) | ord($data[$spos+7]) << 8; + $co = ord($data[$spos+8]); for ($coli = $colfrom; $coli <= $colto; $coli++) { $this->colInfo[$this->sn][$coli+1] = Array('width' => $cw, 'xf' => $cxf, 'hidden' => ($co & 0x01), 'collapsed' => ($co & 0x1000) >> 12); } @@ -1714,12 +1730,8 @@ function _GetIEEE754($rknum) { function _encodeUTF16($string) { $result = $string; if ($this->_defaultEncoding){ - switch ($this->_encoderFunction){ - case 'iconv' : $result = iconv('UTF-16LE', $this->_defaultEncoding, $string); - break; - case 'mb_convert_encoding' : $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' ); - break; - } + // iconv changed to mb_convert_encoding + $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE' ); } return $result; } @@ -1734,4 +1746,4 @@ function _GetInt4d($data, $pos) { } -?> \ No newline at end of file +?>