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

First sheet missing file reading xlsx file #56

Open
nagabhushan opened this issue Oct 18, 2013 · 3 comments
Open

First sheet missing file reading xlsx file #56

nagabhushan opened this issue Oct 18, 2013 · 3 comments

Comments

@nagabhushan
Copy link

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
Copy link
Author

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

@nagabhushan
Copy link
Author

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)
                            {
  •                                   $Attributes = $Sheet -> attributes('r', true);
    
  •                                   foreach ($Attributes as $Name => $Value)
    
  •                                   {
    
  •                                           if ($Name == 'id')
    
  •                                           {
    
  •                                                   $SheetID = (int)str_replace('rId', '', (string)$Value);
    
  •                                                   break;
    
  •                                           }
    

- }

  •                                   //$Attributes = $Sheet -> attributes('r', true);
    
  •                                   //foreach ($Attributes as $Name => $Value)
    
  •                                   //{
    
  •                                   //      if ($Name == 'id')
    
  •                                   //      {
    
  •                                   //              $SheetID = (int)str_replace('rId', '', (string)$Value);
    
  •                                   //              break;
    
  •                                   //      }
    
  •                                   //}
    
  •                                    $SheetID = (int)($Sheet['sheetId']);
                                    $this -> Sheets[$SheetID] = (string)$S
    

@storeman
Copy link

I can confirm this issue.

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

Should be changed to:

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

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

2 participants