Giter VIP home page Giter VIP logo

Comments (11)

shuchkin avatar shuchkin commented on August 15, 2024 1

try this hack

if ( $xlsx = SimpleXLSX::parse('book.xlsx') ) {
	$sheet_names = $xlsx->sheetNames();
	reset( $sheet_names);
	$first_sheet_id = key( $sheet_names );
	print_r( $xlsx->rows( $first_sheet_id ) );
} else {
	echo SimpleXLSX::parse_error();
}

from simplexlsx.

shuchkin avatar shuchkin commented on August 15, 2024

from simplexlsx.

Kukulkano avatar Kukulkano commented on August 15, 2024

I can confirm the issue. Most recent simplexlsx version is still having troubles to open some xlsx file created by LibreOffice (LibreOffice V5.3.1.2 on Kubuntu 16.04).
upload_template.xlsx

from simplexlsx.

mandito67 avatar mandito67 commented on August 15, 2024

Hello! Excelente work!!

In my case the sheet id was number 3, I found that when print_r the sheet names, the only one was [3]=>Hoja1.
So, I add after the solution Pedro (but in another function) post a second check for id 3. I worked for me to solve quickly.

public function worksheet( $worksheet_id ) {

	if(!isset($this->sheets[1]) && isset($this->sheets[2])){
        $this->sheets[1] = $this->sheets[2];
        $worksheet_id = 2;
    }else if(!isset($this->sheets[2]) && isset($this->sheets[3])){
    	$this->sheets[1] = $this->sheets[3];
        $worksheet_id = 3;
    }

	if ( isset( $this->sheets[ $worksheet_id ] ) ) {
		$ws = $this->sheets[ $worksheet_id ];
		
		if (isset($ws->hyperlinks)) {
			$this->hyperlinks = array();
			foreach( $ws->hyperlinks->hyperlink as $hyperlink ) {
				$this->hyperlinks[ (string) $hyperlink['ref'] ] = (string) $hyperlink['display'];
			}
		}
		
		return $ws;
	} else {
		$this->error( 'Worksheet '.$worksheet_id.' not found.');
		return false;
	}
}

Thanks!

from simplexlsx.

itsmebasti avatar itsmebasti commented on August 15, 2024

Hi @shuchkin why is this closed? after saving xlsx in libre, the script won't work for me.

if ( $xlsx = SimpleXLSX::parse($tmp_file) ) {
	print_r( $xlsx->rows() );
} else {
	echo SimpleXLSX::parse_error();
}

does not throw a message. just a blank page :(
Thanks for the work you have done! saved in excel it worked just perfect :)

from simplexlsx.

shuchkin avatar shuchkin commented on August 15, 2024
ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);
if ( $xlsx = SimpleXLSX::parse($tmp_file) ) {
	print_r( $xlsx->rows() );
} else {
	echo SimpleXLSX::parse_error();
}

from simplexlsx.

itsmebasti avatar itsmebasti commented on August 15, 2024

thanks for your fast response, it didn't show any errors either, sorry. Were you able to read the upload_template.xlsx Kukulkano uploaded? I am not.

from simplexlsx.

itsmebasti avatar itsmebasti commented on August 15, 2024

great, thank you, this worked! 💯 I don't really understand what these lines do, are you able to patch this? or can you provide me any if statement that tells me if the file is a Libre file?

from simplexlsx.

Kukulkano avatar Kukulkano commented on August 15, 2024

I'm also interested in a generic solution. It should be able to handle both Microsoft Excel and LibreOffice Calc saved xlsx files out of the box. If parsing the sheets solves the issue, maybe it can be done in general?

from simplexlsx.

itsmebasti avatar itsmebasti commented on August 15, 2024

@Kukulkano It's fixed in the latest version 👍

from simplexlsx.

Kukulkano avatar Kukulkano commented on August 15, 2024

Oh, 9 days ago. Great! Thanks! :)

from simplexlsx.

Related Issues (20)

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.