GithubHelp home page GithubHelp logo

php-excel-reader's People

Watchers

 avatar

php-excel-reader's Issues

Undefined errors in version 2.2

What steps will reproduce the problem?
1. Import any xls file
2.
3.

What is the expected output? What do you see instead?
I expect to only see my data instead I see several undefined errors.

Please provide any additional information below.
The undefined errors have been fixed in the attached version. I hope you
will include them in the next release.

Original issue reported on code.google.com by [email protected] on 31 Mar 2009 at 6:38

Attachments:

Large file support not working

Hey there, just grabbed the newest version you had to test on a 15 meg file.
Before I did, I edited the example file and changed the class call to new
Spreadsheet_Excel_Reader("example.xls",false).

Added print_r($xls);
And checked the output for cellsinfo.  It was there.

It doesn't look like there is anything in the constructor for this change,
so maybe you uploaded a slighly older file.

Original issue reported on code.google.com by [email protected] on 27 Jan 2009 at 3:10

Missing data

Hey there, I have a slightly modified version of your script, but I checked
a default copy to make sure it was an issue instead of my problem.
For some reason, certain values are not being saved.
I know part of it is the way excel is saving the information.  I noticed a
few numbers aligned as if they were text, but I fixed those.

I'm attaching a sample file.  Specificly, the part number fields are not
showing up...

Original issue reported on code.google.com by [email protected] on 23 Feb 2009 at 8:56

Attachments:

Date output not standard

The standard date output is not in a standard format which can be read (for 
example) by the strtotime()-function.

The current output is days/months/years. This notation usually calls either 
for dots:
  days.months.years

Or for another order:
  months/days/years

I don't know if this is an Excel problem or a problem with the script 
interpreting the right date format.

Workaround:
 Change the date formats around lines 410-420 to your liking.

Original issue reported on code.google.com by 128625 on 17 Dec 2008 at 12:14

Code to dump only part of sheet or all the sheet

I added 4 more prams to optionally cut out only part of a sheet in a dump.

it adds nice functionality to simply display only part of a sheet.



---snip---

// DUMP AN HTML TABLE OF THE ENTIRE OR PART OF XLS DATA
    // =========================================
    function
dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel',$startr
ow=1,$endrow=0,$startcol=1,$endcol=0)
{
        $out = "<table class=\"$table_class\" cellspacing=0>";
        if ($endcol == 0 ){
                $endcol = $this->colcount($sheet);
        }
        if($endrow ==0){
            $endrow = $this->rowcount($sheet);
        }
        if ($col_letters) {
            $out .= "<thead>\n\t<tr>";
            if ($row_numbers) {
                $out .= "\n\t\t<th>&nbsp</th>";
            }

            for($i=$startcol;$i<=$endcol;$i++) {
                $style = "width:" . ($this->colwidth($i,$sheet)*1) . "px;";
                if ($this->colhidden($i,$sheet)) {
                    $style .= "display:none;";
                }
                $out .= "\n\t\t<th style=\"$style\">" .
strtoupper($this->colindexes[$i]) . "</th>";
            }
            $out .= "</tr></thead>\n";
        }

        $out .= "<tbody>\n";

        for($row=$startrow;$row<=$endrow;$row++) {
            $rowheight = $this->rowheight($row,$sheet);
            $style = "height:" . ($rowheight*(4/3)) . "px;";
            if ($this->rowhidden($row,$sheet)) {
                $style .= "display:none;";
            }
            $out .= "\n\t<tr style=\"$style\">";
            if ($row_numbers) {
                $out .= "\n\t\t<th>$row</th>";
            }
            for($col=$startcol;$col<=$endcol;$col++) {
                // Account for Rowspans/Colspans
                $rowspan = $this->rowspan($row,$col,$sheet);
                $colspan = $this->colspan($row,$col,$sheet);
                for($i=0;$i<$rowspan;$i++) {
                    for($j=0;$j<$colspan;$j++) {
                        if ($i>0 || $j>0) {
                            $this->sheets[$sheet]['cellsInfo'][$row+$i][$col+$j]['dontprint']=1;
                        }
                    }
                }
                if(!$this->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']) {
                    $style = $this->style($row,$col,$sheet);
                    if ($this->colhidden($col,$sheet)) {
                        $style .= "display:none;";
                    }
                    $out .= "\n\t\t<td style=\"$style\"" . ($colspan > 1?"
colspan=$colspan":"") . ($rowspan > 1?" rowspan=$rowspan":"") . ">";
                    $val = $this->val($row,$col,$sheet);
                    if ($val=='') { $val="&nbsp;"; }
                    else {
                        $val = htmlentities($val);
                        $link = $this->hyperlink($row,$col,$sheet);
                        if ($link!='') {
                            $val = "<a href=\"$link\">$val</a>";
                        }
                    }
                    $out .= "<nobr>".nl2br($val)."</nobr>";
                    $out .= "</td>";
                }
            }
            $out .= "</tr>\n";
        }
        $out .= "</tbody></table>";
        return $out;
    }


---snip---

Original issue reported on code.google.com by [email protected] on 30 Mar 2009 at 9:06

Dates are off

As with the original script I am experiencing wrong date conversion with 
the current version of php-excel-reader.

I am using a standard .XLS-file (Possibly created with Excel 2002 on 
Windows) on a Windows XP PC with PHP 5.2.6 running, everything with german 
localisation and in the timezone UTC+1.

For example: The date '03.10.2008 14:40' gets converted to the (Non 
standard format) '04/10/2008 16:50'.

All dates are 93600 seconds off.

I submit this workaround for line 1095:
    $utcValue = round(($utcDays+1) * SPREADSHEET_EXCEL_READER_MSINADAY - 
93600);

Original issue reported on code.google.com by 128625 on 17 Dec 2008 at 12:03

Support for caching results (patch included)

I don't think it's a good idea to process the spreadsheet file over and over 
again, especially as it 
may not change very frequently.

Here's a little function to cache the results of the spreadsheet read as a PHP 
object. Make sure 
you create the cache directory and make sure it can be written to.

best,
matt

function Cached_Spreadsheet($filename) {
    $cache_dir = './cache';     //set to null to disable cache
    $xlsmtime = filemtime($filename);
    $cached = false;

    // If CACHE ENABLED
    if ($cache_dir != '' && file_exists($cache_dir)) {
        $cache_file = $cache_dir . '/xlscache_' . md5($filename);
        $timediff = @($xlsmtime != filemtime($cache_file));
        if ($timediff && file_exists($cache_file)) {
            // cached file is fresh enough, return cached array
            $result = unserialize(join('', file($cache_file)));
            // set 'cached' to 1 only if cached file is correct
            if ($result) $cached = true;
        } else {
            // cached file is too old, create new
            $result = new Spreadsheet_Excel_Reader($filename, false);
            $serialized = serialize($result);
            if ($f = @fopen($cache_file, 'w')) {
                fwrite ($f, $serialized, strlen($serialized));
                fclose($f);
            }
            if ($result) $cached = false;
        }
    } else {
        // If CACHE DISABLED >> load and parse the file directly
        $result = new Spreadsheet_Excel_Reader($filename, false);
        if ($result) $cached = false;
    }

    if ($cached) echo "<!-- cached result -->\n";

    // return result
    return $result;
}

$xls = Cached_Spreadsheet("example.xls");

Original issue reported on code.google.com by [email protected] on 11 Mar 2009 at 3:53

Attachments:

Memory usage

Hi there,
good to see that somebody picked up development of this class.

For quite some time I was worried by the heavy memory usage Excel_Reader
shows when dealing with larget excel files.
Today I digged around a bit in the code, and I was able to reduce memory
usage (memory_get_peak_usage) down from 71MB to 16MB for a ~11.000 rows
excel file.
I removed / commented out 4 lines in function addcell(), namely
$this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col +
$this->_coloffset]['raw'] = $raw;
$this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col +
$this->_coloffset]['type'] = $type;
$this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col +
$this->_coloffset]['format'] = $format;
$this->sheets[$this->sn]['cellsInfo'][$row + $this->_rowoffset][$col +
$this->_coloffset]['formatIndex'] = $formatIndex;

Those 4 entries alone were responsible for such a huge overhead, and I
didn't really need those information for my further processing. And as it
seems, the class itself doesn't either.

What I'd really like to see and what I was already searching for, is a
'streaming' reading of excel files, where you don't need to have the whole
excel file in memory to process.
But alas, such thing doesn't seem to exist, so for the time being I'm
content with such a dramatic decrease in memory usage with the currently
available class.

Original issue reported on code.google.com by [email protected] on 5 Dec 2008 at 1:49

Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in [...]\xlsReader\excel_reader2.php on line 347

What steps will reproduce the problem?
1. Trying to access a certain xls file (other files are working)
2.
3.

What is the expected output? What do you see instead?
It should just list everything on the first sheet.

Please provide any additional information below.
The code is pretty simple and works with another xls-file, so the problem
somehow lies within the xls itself, but I can't figure out what it might be:
require_once 'pricelist/xlsReader/excel_reader2.php';
$file = $_REQUEST['sheet'];
$xls = new Spreadsheet_Excel_Reader('pricelist/files/'.$file.'');
$numcol = $xls->colcount();
$numrow = $xls->rowcount();

for ($row = 0; $row <= $numrow; $row++) {
 for ($col = 0; $col <= $numcol; $col++) {
  echo $xls->val($row, $col);
  echo ' : ';
 }
 echo '<br>';

}

Original issue reported on code.google.com by [email protected] on 2 Apr 2009 at 10:31

script freezing issue

I had a problem with this new version, and the older version of the Excel 
Reader, where on certain files the script would timeout, or exhuast all 
availible memory.

When i debugged the script and the xls file i was working with, i found the 
'name' of the file in the propery array was "WORKBOOK"

On line 246 of excel_reader2.php you have 
    if ($name == "Workbook")

Changed this to:
     if ((strtolower($name) == "workbook")


This fixed the problem.




Original issue reported on code.google.com by [email protected] on 14 Feb 2009 at 7:51

Wrong Encoding for values

In version 2.11, the line 771 decides whether or not a string is ascii
encoded or not. As it seems this is not working reliably, for only UTF16LE
strings are "decoded" to the requested defaultEncoding.

My workaround/hack for now is to replace line 771 with this:

$retstr = ($asciiEncoding) ? iconv('cp1250', $this->_defaultEncoding,
$retstr) : $this->_encodeUTF16($retstr);

I'm not fully convinced using an hardcoded encoding of cp1250 is a good
idea but it seems to work in my testcase.


Original issue reported on code.google.com by [email protected] on 4 Feb 2009 at 10:24

Little problem with a function in PHP4

The function array_combine does not exist in PHP4, so the library doesn't 
work with this PHP version.

I've replaced this function by the following:

function array_comb ($array1, $array2) {
 $out = array();
 foreach ($array1 as $key => $value) {
  $out[$value] = $array2[$key];
 }
 return $out;
}

And now it's work perfectly.

Thanks for sharing this library, it's very useful and easy to use. :)

Original issue reported on code.google.com by [email protected] on 30 Mar 2009 at 1:08

Boolean and String Formulas are not supported

What steps will reproduce the problem?
1. Put a formula in spreadsheet with boolean or string result

What is the expected output? What do you see instead?
Desired output is the result of the formula in the cells array. Instead, it
is as if the cell is empty.

What version of the product are you using? On what operating system?
NA

Please provide any additional information below.
I have a private version of the code in which I've made the necessary
changes to support boolean (see mmpbool) and string (see mmptext) strings.
Please note, this is based on an older version of the code when the
constants were not all uppercase. In any case, here is the code in case you
would like to incorporate it into the next release:


                case Spreadsheet_Excel_Reader_Type_FORMULA:
                case Spreadsheet_Excel_Reader_Type_FORMULA2:
                    $row    = ord($this->data[$spos]) |
ord($this->data[$spos+1])<<8;
                    $column = ord($this->data[$spos+2]) |
ord($this->data[$spos+3])<<8;
                    if ((ord($this->data[$spos+6])==0) &&
(ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
                        //String formula. Result follows in a STRING record
//mmptext begin                        
                        echo "FORMULA $row $column Formula with a
string<br>\n";
                        $SAVErow = $row; $SAVEcolumn = $column;
                        // the SAVE values are used in the STRING record
//mmptext end                        
                    } elseif ((ord($this->data[$spos+6])==1) &&
(ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
                        //Boolean formula. Result is in +2; 0=false,1=true
//mmpbool begin                       
                        if (ord($this->data[$spos+8])==1) {
                            $this->addcell($row, $column, "TRUE", 1);
                        } else {
                            $this->addcell($row, $column, "FALSE", 0);
                        }
//mmpbool end                       
                    } elseif ((ord($this->data[$spos+6])==2) &&
(ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
                        //Error formula. Error code is in +2;
                    } elseif ((ord($this->data[$spos+6])==3) &&
(ord($this->data[$spos+12])==255) && (ord($this->data[$spos+13])==255)) {
                        //Formula result is a null string.
//mmptext begin                        
                        $this->addcell($row, $column, '');
//mmptext end                        
                    } else {
                        // result is a number, so first 14 bytes are just
like a _NUMBER record
                        $tmp = unpack("ddouble", substr($this->data, $spos
+ 6, 8)); // It machine machine dependent
                        if ($this->isDate($spos)) {
                            list($string, $raw) =
$this->createDate($tmp['double']);
                         //   $this->addcell(DateRecord($r, 1));
                        }else{
                            //$raw = $tmp[''];
                            if (isset($this->_columnsFormat[$column + 1])){
                                    $this->curformat =
$this->_columnsFormat[$column + 1];
                            }
                            $raw = $this->createNumber($spos);
                            $string = sprintf($this->curformat, $raw *
$this->multiplier);

                         //   $this->addcell(NumberRecord($r));
                        }
                        $this->addcell($row, $column, $string, $raw);
                        //echo "Number $row $column $string\n";
                    }
                    break;                    
//mmptext begin                    
                case Spreadsheet_Excel_Reader_Type_STRING:
            echo "Found a STRING\n<br>";
            if ($version == Spreadsheet_Excel_Reader_BIFF8){
                // Unicode 16 string, like an SST record
            echo "In STRING section, BIFF8\n<br>";
                        $xpos = $spos;
                                                $numChars =
ord($this->data[$xpos]) | (ord($this->data[$xpos+1]) << 8);
                                                $xpos += 2;
                                                $optionFlags =
ord($this->data[$xpos]);
                                                $xpos++;
                                        $asciiEncoding = (($optionFlags &
0x01) == 0) ;
                                                $extendedString = (
($optionFlags & 0x04) != 0);

                                                // See if string contains
formatting information
                                                $richString = (
($optionFlags & 0x08) != 0);

                                                if ($richString) {
                                        // Read in the crun
                                                        $formattingRuns =
ord($this->data[$xpos]) | (ord($this->data[$xpos+1]) << 8);
                                                        $xpos += 2;
                                                }

                                                if ($extendedString) {
                                                  // Read in cchExtRst
                                                  $extendedRunLength =
$this->_GetInt4d($this->data, $xpos);
                                                  $xpos += 4;
                                                }

                                                $len = ($asciiEncoding)?
$numChars : $numChars*2;
                                                $retstr =
substr($this->data, $xpos, $len);
                                                $xpos += $len;

                                                $retstr = ($asciiEncoding)
? $retstr : $this->_encodeUTF16($retstr);
                                                echo "Str = $retstr\n<br>";
                                                //$this->sst[]=$retstr;
                    }elseif ($version == Spreadsheet_Excel_Reader_BIFF7){
                // Simple byte string
                echo "In STRING section, BIFF7\n<br>";
                        $xpos = $spos;
                                                $numChars =
ord($this->data[$xpos]) | (ord($this->data[$xpos+1]) << 8);
                                                $xpos += 2;
                                                $retstr =
substr($this->data, $xpos, $numChars);
                                                echo "Str = $retstr\n<br>";
                    }
                    $this->addcell($SAVErow, $SAVEcolumn, $retstr);
            break;
//mmptext end            
                case Spreadsheet_Excel_Reader_Type_BOOLERR:



Original issue reported on code.google.com by [email protected] on 19 Dec 2008 at 9:34

_format_value call on string overwrites value

In Method _getCellDetails() a call to _format_value() is performed on
string values (line 1133 on version 2.11). 

If the value in the cell happens to be a number but the format is
'GENERAL', the code overwrites the actual value by the FORMAT, effectively
destroying the original value.

Demo: a call to _format_values('GENERAL', 3, 0) returns 'GENERAL' rather
then '3'

This is probably due to line 474, where the predicted subpattern $part[0]
is used as pattern without checking if that makes any logical sense.

Original issue reported on code.google.com by [email protected] on 3 Feb 2009 at 7:12

Euro sign not working

What steps will reproduce the problem?
- Type a euro sign (alt-0128) in a spreadsheat cel and display this cel
using tge php-excel writer.

What is the expected output? What do you see instead?
- It outputs "¬" in stead of "€"

I think this is an encoding problem?!

Original issue reported on code.google.com by [email protected] on 13 Mar 2009 at 9:38

Does not work with a specific .xls file

What steps will reproduce the problem?
1. Read an excel file


What is the expected output? What do you see instead?
Data of excel. 
The filename /var/www/data.xls is not readable.

What version of the product are you using? On what operating system?
Latest currently available. CentOS

Please provide any additional information below.
It work with the example file.

Error occur at this point.
if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
            $this->error = 1;
            return false;
        }


Original issue reported on code.google.com by [email protected] on 4 Mar 2009 at 9:30

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.