Answer the question
In order to leave comments, you need to log in
Parsing XLS with PHP
Good afternoon. Faced a problem, it is necessary to update the catalog on the site. All nomenclature comes in the form of XLS files. From the libraries I tried both simple-excel and PHPExcel and spreadsheet-reader. The second problem is that each file can have multiple sheets. Formulas will not be there, so you need a minimal simple tool for parsing this. Perhaps someone came across convenient readers working with the Russian language and several sheets in the file. I will be extremely grateful.
Answer the question
In order to leave comments, you need to log in
https://github.com/shuchkin/simplexls
if ( $xls = SimpleXLS::parse('book.xls') ) {
print_r( $xls->rows() );
} else {
echo SimpleXLS::parseError();
}
Array
(
[0] => Array
(
[0] => ISBN
[1] => title
[2] => author
[3] => publisher
[4] => ctry
)
[1] => Array
(
[0] => 618260307
[1] => The Hobbit
[2] => J. R. R. Tolkien
[3] => Houghton Mifflin
[4] => USA
)
)
From personal experience of parsing:
- github.com/faisalman/simple-excel-php - I came across this one not so long ago, I have not had time to try it yet. Did you use this one (sometimes they use the same names)?
- you can get by with exporting from excel to csv and then you can parse out of the box.
PHPExcel can work with multiple sheets and with the Russian language. What is your problem with him?
Another Excel document can be saved in some kind of XML format. For example in ODF-like (OpenOffice also uses it). In this case, unlike CSV, you will not lose sheets, formatting, formulas, etc. This feature seems to be present in all modern versions of Excel by default. Then you can parse such a file in PHP through an XML parser, such as SimpleXML.
I did this because parsing the native Excel format on PHPExcel required a lot of machine time and RAM. And the method I described consumes few resources and works quickly.
PS: You shouldn't be afraid of manual ODF XML parsing. You can understand at a level sufficient to read sheets and values in half an hour, even without documentation. Everything is obvious there.
if you have problems with parsing large files, you can try the noxls.net/documentation
parsing API,
but they want little money
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question