Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird text appears instead of readable texts. #70

Closed
roiji opened this issue Sep 17, 2014 · 6 comments
Closed

Weird text appears instead of readable texts. #70

roiji opened this issue Sep 17, 2014 · 6 comments

Comments

@roiji
Copy link

roiji commented Sep 17, 2014

Hi!

I've recently came across this library due to my frustration in PHPExcel not being able to read large (wide) XLSX files. Thank you.

I've made it ran after fixing ZipArchive::extractTo(): Permission denied error on my Mac (just pass SpreadsheetReader() a 2nd parameter containing an array that includes "TempDir")..

But print_r($Row) shows this:

<br />
<b>Warning</b>:  pathinfo() expects parameter 1 to be string, array given in <b>/Applications/XAMPP/xamppfiles/htdocs/spreadsheet-reader-master/SpreadsheetReader.php</b> on line <b>60</b><br />
Array
(
    [0] => PK������ÆK1E�_rels/.rels­’ÏJ�1�‡ï}Š�{w¶�Dd³½ˆÐ›H}€˜Ìþa7™0�u}{ƒ�Z©¥��I~óÍ7CšÝ�fõŠœGŠFoªZ+ŒŽü�{£Ÿ�÷ë�½kWÍ#ÎVJ$�cʪÔÄlô ’n�²�0Ø\QÂX^:â`¥�¹‡dÝd{„m]_�ÿdèöˆ©öÞhÞû�V‡÷„—°©ëF‡wä^�F9ÑâW¢�-÷(F/3¼�OÏDSU �N»l/wù{N�(Ö[±àˆq�¸T³Œ˜¿u<¹‡r�?�ç„®þs9¸�F�þ¼’MéËhÕÀÑ'h?PK��fª‚·à
    [1] => �PK������ÆK1E�docProps/app.xml��QKÃ0�…ßý�%øº&­iÌFÚ!ˆOÊ�«ì­Ääv‹´IHâØþ½QÁíÙÇÃ9|÷œ+ÖÇy*��¢q¶EUIP�V9mì®E¯ý£"&iµœœ…�� ¢uw%žƒó�’�Xd‚�-Ú§äW�Gµ‡YÆ2Û6
    [2] => £�³LY†�vãh�Ü
    [3] => õ9ƒM¸&„a8&°�ôÂÿ�Ñ/quHÿ…j§¾ûÅ·þä3¯�½KrêÍ]E–�Ÿ¥¸ó~2J¦<¿{4ï�6?<LË›’”ôúIªÍËvØr60Z\$†\ø�T¬–ºá�çœÊzT54·œhM�Ê�g\ÓŠ�%("ðå-�Ï�ì¾PK���7tNù†�PK������ÆK1E�docProps/core.xml�’Qo‚0�Çß÷)HßK)¨¸�ða‹O[b"fËÞšrb3(¤­¢ß~�•9ãÃÞzýÿïwwí%‹c]y�ÐF6*EÔ���J4…TeŠ6ù�Ï‘g,W�¯��):�A‹ì)�-��†•nZÐV‚ñ�H�&Ú�í¬m�!Fì æÆw�åÄm£kn]¨KÒrñÍK a�ÌH
)

here is the code that i've used:

<?php
    require('SpreadsheetReader.php');
    $Reader = new SpreadsheetReader('gale.xlsx', array('TempDir' => 'xl'));
    $Sheets = $Reader -> Sheets();
        $Reader -> ChangeSheet(1);
        foreach ($Reader as $Row)
        {
            print_r($Row);
        }
?>

I am only interested in the 2nd sheet.
The XLSX used to have a password.
Other sheets are password protected from being edited.
Some cells on the 2nd sheet points to a reference column on another Excel file or points to a column on a protected sheet. (Sorry, I don't know how it's formally called. When I click on the cell, a drop down appears).
The sheet has a lot of styling because it is a report to the managements.

I tried issue #38 but it only displayed question marks (?????) on some parts.

Thank you!

@pilsetnieks
Copy link
Member

Hi,
styling isn't the problem but I think it's probably because of the password protection. So far password protection hasn't been considered in this library, sorry.

@roiji
Copy link
Author

roiji commented Sep 17, 2014

Yes,
But my target sheet isn't password protected...
I'll try to get tomorrow a sample excel for sharing.
Thanks for your reply'

@pilsetnieks
Copy link
Member

I meant that at least the other sheeds are password protected, maybe that has some impact as well. I'm also not sure what setting a password on the file and then removing it does to the internal structure.

I can take a look at the sample file, maybe I'll notice something there.

@roiji
Copy link
Author

roiji commented Sep 18, 2014

Hi,

I just found out this does not work as intended only on my Mac (MBA 2012) or perhaps all Macs?.
I have a local XAMPP for Mac 1.8.3-5:
PHP Version 5.5.15
Server version: Apache/2.4.10 (Unix)
Server built: Aug 20 2014 14:43:32

The text are extracted correctly on an old Windows laptop running WAMP 2.0i (5 year old software)
apacheVersion := '2.2.11';
phpVersion := '5.3.0' ;

I also have a webserver running the bundled Apache on Ubuntu (t1.micro server on Amazon).
Apache: 2.4.6 (Ubuntu)
PHP Version 5.5.3-1ubuntu2.1
And it works there as well..

Here is a sample Excel file https://dl.dropboxusercontent.com/u/10090786/sample.xlsx
Without the password protection to begin with.
Created using MS Excel 2010.
Untouched by LibreOffice. (2nd sheet could not be read if the xlsx is touched by LibreOffice)

I got this in a Mac

a����.�ߝ���"����t    ʕ��v��� ���1<���������b�i����]_�>�c�O8���#���"=��$I���`\��3�v#z̹���k��g���}����$8��(�N߅]d�ݹ'!�Q�>4�.�ޑ��t�o��ڼS�:�E���'���PK�����!�U0#�L����_rels/.rels ���(�����N�0��H�C���nH����LH�!T��$�����$@�����Jc�����?[���iT��b/Nú(A�3b{�jx��V��b"gi�����aW��l_x���b����������#b4�O����r��0Q�ahѓ��eܔ�=���P-<��j��{��>�<���4Mox/�}b�N�@�� �v�Cf���ۨ�B�I��������"c��&�\O���8q"K��H��<ߊs@���.�h����<⧄�Md�a���T_���PK�����!� �(�������xl/_rels/workbook.xml.rels ���(�����j�0���}q�ne�:��A�[�&Q���6��'o?�C�@�.���$�}?Ч�������j�U�%)����Z�(�8�><� ֶҝ��`@�Cq����Ns�D��$��%���襤�`�)q�m��.��c���uy�                                                                 
�

screenshot 2014-09-19 02 00 29

@coffebar
Copy link

roiji, i tested with your example

<?php
    require('SpreadsheetReader.php');
    $Reader = new SpreadsheetReader('gale.xlsx', array('TempDir' => 'xl'));
    $Sheets = $Reader -> Sheets();
    $Reader -> ChangeSheet(1);
    foreach ($Reader as $Row)
    {
        print_r($Row);
    }
?>

it does not work.
Second param of SpreadsheetReader class is $OriginalFilename
But next code works for me:

<?php
require('SpreadsheetReader.php');
$Spreadsheet = new SpreadsheetReader('sample.xlsx');

$Spreadsheet->ChangeSheet(0);
foreach ($Spreadsheet as $Row)
{
    //pass
}

$Spreadsheet->ChangeSheet(1);
foreach ($Spreadsheet as $Row)
    if ($Row)
        print_r($Row);

@pilsetnieks
Copy link
Member

@Hukuta is correct, it seems that simply the parameters to the SpreadsheetReader constructor were incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants