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

Throw new Exception("Invalid cell index") when upload Excel #7

Open
alisazhang opened this issue May 12, 2017 · 5 comments
Open

Throw new Exception("Invalid cell index") when upload Excel #7

alisazhang opened this issue May 12, 2017 · 5 comments

Comments

@alisazhang
Copy link

We have received the same problems many times from our customers, but we don't know the Excel content when they upload, so I want to know in which situation the Exception occurs.

vary thanks! Looking forward to your response!

@TheCloud
Copy link

TheCloud commented May 8, 2019

I have the same issue, but it's related to XLSX files generated via Google Sheet (using Export function)

@abhishekthanvi8
Copy link

@TheCloud how did you resolved it ?

@alexut
Copy link

alexut commented Feb 26, 2020

I have the same issue, but it's related to XLSX files generated via Google Sheet (using Export function)

Same here...

@Anyvie
Copy link

Anyvie commented Jul 23, 2020

When you open an .xlsx file generated by GoogleSheets, it doesn't have the node in xl/worksheets/sheetX.xml so it can't be loaded successfully.

I made a quick fix for my own purposes, in the XLSXWorksheet class.

protected function parse($xml) {
	$this->parseDimensions($xml->dimension, $xml);
	$this->parseData($xml->sheetData);
}

protected function parseDimensions($dimensions, $xml) {
	$range = (string) $dimensions['ref'];
	
	if (! strlen($range)) {
		$nbRows = count($xml->sheetData->row);
		$nbCells = count($xml->sheetData->row[$nbRows-1]);
		$min = (string) $xml->sheetData->row->c[0]['r'];
		$max = (string) $xml->sheetData->row[$nbRows-1]->c[$nbCells-1]['r'];
		$range = $min.':'.$max;
	}
	
	$cells = explode(':', $range);
	$maxValues = $this->getColumnIndex($cells[1]);
	$this->colCount = $maxValues[0] + 1;
	$this->rowCount = $maxValues[1] + 1;
}

@mcanepa
Copy link

mcanepa commented Mar 6, 2022

Thanks @Anyvie !

There's a pull request that was never merged: #2

In the mean time, your solution and @ahmednuaman's works great

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

6 participants