nuovo / spreadsheet-reader

A PHP spreadsheet reader (Excel XLS and XLSX, OpenOffice ODS, and variously separated text files) with a singular goal of getting the data out, efficiently
http://www.nuovo.lv/
Other
673 stars 498 forks source link

First sheet missing file reading xlsx file #56

Open nagabhushan opened 10 years ago

nagabhushan commented 10 years ago

Hi, When Print all sheets it says 3 sheets are present. but whne I print Temp Directory only two are there. please help me to resolve this issue.

Following is the object;

SpreadsheetReader_XLSX Object ( [Options:private] => Array ( [TempDir] => [ReturnDateTimeObjects] => )

[Valid:private] => 1
[Handle:private] =>
[WorksheetPath:private] => /tmp/5261b72f2c247/xl/worksheets/sheet2.xml
[Worksheet:private] => XMLReader Object
    (
    )

[SharedStringsPath:private] =>
[SharedStrings:private] =>
[SharedStringCache:private] => Array
    (
    )

[WorkbookXML:private] => SimpleXMLElement Object
    (
        [fileVersion] => SimpleXMLElement Object
            (
                [@attributes] => Array
                    (
                        [appName] => Calc
                    )

            )

        [workbookPr] => SimpleXMLElement Object
            (
                [@attributes] => Array
                    (
                        [backupFile] => false
                        [showObjects] => all
                        [date1904] => false
                    )

            )

        [workbookProtection] => SimpleXMLElement Object
            (
            )

        [bookViews] => SimpleXMLElement Object
            (
                [workbookView] => SimpleXMLElement Object
                    (
                        [@attributes] => Array
                            (
                                [activeTab] => 2
                                [firstSheet] => 0
                                [showHorizontalScroll] => true
                                [showSheetTabs] => true
                                [showVerticalScroll] => true
                                [tabRatio] => 208
                                [windowHeight] => 8192
                                [windowWidth] => 16384
                                [xWindow] => 0
                                [yWindow] => 0
                            )

                    )

            )

        [sheets] => SimpleXMLElement Object
            (
                [sheet] => Array
                    (
                        [0] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [name] => Sheet1
                                        [sheetId] => 1
                                        [state] => visible
                                    )

                            )

                        [1] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [name] => Sheet2
                                        [sheetId] => 2
                                        [state] => visible
                                    )

                            )

                        [2] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [name] => Sheet3
                                        [sheetId] => 3
                                        [state] => visible
                                    )

                            )

                    )

            )

        [calcPr] => SimpleXMLElement Object
            (
                [@attributes] => Array
                    (
                        [iterateCount] => 100
                        [refMode] => A1
                        [iterate] => false
                        [iterateDelta] => 0.001
                    )

            )

    )

[Styles:private] => Array
    (
        [0] =>
    )

[TempDir:private] => /tmp/5261b72f2c247/
[TempFiles:private] => Array
    (
        [0] => /tmp/5261b72f2c247/xl/worksheets/sheet2.xml
        [1] => /tmp/5261b72f2c247/xl/worksheets/sheet3.xml
    )

[totalRowCount:private] => 20
[CurrentRow:private] =>
[Index:private] => 0
[Sheets:private] => Array
    (
        [2] => Sheet1
        [3] => Sheet2
        [4] => Sheet3
    )

[SharedStringCount:private] => 0
[SharedStringIndex:private] => 0
[LastSharedStringValue:private] =>
[RowOpen:private] =>
[SSOpen:private] =>
[SSForwarded:private] =>
[Formats:private] => Array
    (
        [164] => GENERAL
    )

[ParsedFormatCache:private] => Array
    (
    )

)

nagabhushan commented 10 years ago

I created xlsx in ubuntu os and tried by giving path of the file.

nagabhushan commented 10 years ago

the sheet storing in temp directory is interepreted is incorrect. its correct for windows but not for google spreqad sheet xlsx files. following are my chnages: SpreadsheetReader_XLSX.php (working copy) @@ -338,7 +338,7 @@ /* * Destructor, destroys all that remains (closes and deletes temp files) / public function __destruct()

            {
                    foreach ($this -> TempFiles as $TempFile)
                    {
                            $this -> Sheets = array();
                            foreach ($this -> WorkbookXML -> sheets -> sheet as $Index => $Sheet)
                            {

- }

storeman commented 10 years ago

I can confirm this issue.

$SheetID = (int)str_replace('rId', '', (string)$Value);

Should be changed to:

$SheetID = (int)($Sheet['sheetId']);