Phpexcel provides many methods to read xls files. I am using the phpexcel class. I am also wondering that the downloaded files are quite large, even if [img] [img] is what netizens say, the size is 18 MB. let's see how phpexcel reads xls files. Php code? Require? ExcelPHPExcel. php ;? Add phpexcel to read xls files
There are many ways to read xls files. we can master one of them. I am using the phpexcel class, and I am also wondering that the downloaded files are quite large, even if [img] [/img] is what netizens say, the size is 18 MB. let's see how phpexcel reads xls files.
Php code?
- Require? 'Excel/PHPExcel. php ';? // Load the file ??
- ?? $ Filename = "D:/wamp/www/test/sysoa.xls ";??
- ? // Read the xls files of Version 2003 and earlier versions ??
- $ Phpreader =New? PHPExcel_Reader_Excel5 ();??
- If($ Phpreader-> canRead ($ filename )){??
- ??
- ???? $ Excel = $ phpreader-> load ($ filename );??
- ???? // Get the current worksheet ??
- ?? ??
- ???? $ Cursheet = $ excel-> getSheet (0 );??
- ???? // How many columns are obtained. if this static method is not used, the obtained $ col is the maximum uppercase letter of the file column ??
- ???? $ Col = PHPExcel_Cell: columnIndexFromString ($ cursheet-> getHighestColumn ());??
- ???? ??
- ???? // How many rows are obtained ??
- ???? $ Row = $ cursheet-> getHighestRow ();??
- ??
- ???? // Obtain data cyclically. The xls file is expressed in B2 ??
- ??
- ????For($ Currow = 1; $ currow <= $ row; $ currow ++ ){??
- ??????For($ Curcol = 1; $ curcol <= $ col; $ curcol ++ ){??
- ??????????? $ Result = $ cursheet-> getCellByColumnAndRow ($ curcol, $ currow)-> getValue ();??
- ???????????If($ Result ){??
- ??????????? Echo? 'Column '. $ currow.' Row '. $ curcol.': '. $ result .'';??
- ???????????} ??
- ??????} ??
- ?????? Echo? '
';??
- ????} ??
- ????? ??
- }??
Require 'Excel/PHPExcel. php '; // load the file $ filename = "D:/wamp/www/test/sysoa.xls "; // read the xls files of Version 2003 and earlier $ phpreader = new PHPExcel_Reader_Excel5 (); if ($ phpreader-> canRead ($ filename )) {$ excel = $ phpreader-> load ($ filename); // Obtain the current worksheet $ cursheet = $ excel-> getSheet (0); // obtain the total number of columns, if you do not use this static method, the obtained $ col is the largest capital letter in the file column $ col = PHPExcel_Cell: columnIndexFromString ($ cursheet-> getHighestColumn ()); // obtain the total number of rows $ row = $ cursheet-> getHighestRow (); // Obtain data cyclically. The xls file is a column after it is placed forward, such as the second column in the first row, in fact, xls is expressed in B2. for ($ currow = 1; $ currow <= $ row; $ currow ++) {for ($ curcol = 1; $ curcol <= $ col; $ curcol ++) {$ result = $ cursheet-> getCellByColumnAndRow ($ curcol, $ currow)-> getValue (); if ($ result) {echo 'did '. $ currow. 'row name '. $ curcol. 'column :'. $ result. '';} echo'
';}}
? But there are still some problems that have not been solved. when I read another xls file, $ row = $ cursheet-> getHighestRow (); actually got 65522, which is really confusing, but the other one is better.
1 floor pz9042 2012-06-06
... This is what I wrote ..