SetOutputEncoding (& #39; GB2312 & #39;); set text input to php
Header ("Content-Type: text/html; charset = GB2312 ");
// This is the excel_reader2.php package for download! Baidu!
Require_once 'Excel/excel_reader2.php ';
$ Dir = "wps/"; // folder name
$ Handle = opendir ($ dir. "."); // open the Directory
$ Row = array ();
While (false! ==( $ File = readdir ($ handle )))
{
If ($ file! = "." & $ File! = ".."){
$ Row [] = $ dir. $ file; // output file name
// Echo $ file;
}
}
Closedir ($ handle); // Close The OpenEd directory
// Print_r ($ row );
$ Data = new Spreadsheet_Excel_Reader ();
$ Data-> setOutputEncoding ('gb2312'); // sets the text output encoding.
// Read the Excel file
// The problem starts from here. The following is a loop of excel documents, but the output content remains unchanged!
// For ($ k = 0; $ k $ data-> read ($ row [0]); // This is a function in the package that reads the excel document
// $ Data-> sheets [0] ['numrows '] indicates the number of rows in Excel
For ($ I = 1; $ I <= $ data-> sheets [0] ['numrows ']; $ I ++ ){
}
//}
// $ Data-> sheets [0] ['numrows '] is an array, $ data-> sheets [0] ['numrows '] [2] contents of each row (two rows in my table in total, all tables are the same! The title of the first behavior. the content of the second row is to be read, so it is 2). after the loop here, the array will remain unchanged, and the loop content will always be the first read content! Please loop through all the content in the document!
print_r($data->sheets[0]['cells'][2]);
?>