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

Speed up getCell() #102

Closed
Jonowa opened this issue Apr 25, 2021 · 1 comment
Closed

Speed up getCell() #102

Jonowa opened this issue Apr 25, 2021 · 1 comment

Comments

@Jonowa
Copy link

Jonowa commented Apr 25, 2021

Hi Sergey,

it's possible to speed up the function getCell() using straight access via xpath instead of foreach loops. Try this:

public function getCell( $worksheetIndex = 0, $cell = 'A1' ) 
{
    if ( ( $ws = $this->worksheet( $worksheetIndex ) ) === false ) {
        return false;
    }
    $idx = is_array( $cell ) ? $cell : $this->getIndex( (string) $cell );
    $C   = $idx[0];
    $R   = $idx[1];
    return $this->value($ws->sheetData->row[$R]->c[$C]);
}

Best regards
Joerg

@shuchkin
Copy link
Owner

$ws->sheetData->xpath( "row/c[@r='" . $cell . "']" );

try 0.8.23 and thx

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