D
D
Dmitry Sonko2013-05-08 08:56:56
PHP
Dmitry Sonko, 2013-05-08 08:56:56

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

5 answer(s)
S
Sergey Shchuchkin, 2018-12-28
@shuchkin

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
        )

)

D
Dialog, 2013-05-08
@Dialog

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.

S
startsevdenis, 2013-05-08
@startsevdenis

PHPExcel can work with multiple sheets and with the Russian language. What is your problem with him?

T
tushev, 2013-05-09
@tushev

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.

K
karpovigorok, 2014-06-16
@karpovigorok

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 question

Ask a Question

731 491 924 answers to any question