This article is mainly about the use of Spreadsheet_excel_reader to read Excel files, when you have a large amount of data on the site or have a lot of member data when it is necessary to import the day data into Excel backup, for which we provide a read Excel file instance.
Download a Spreadsheet_excel_reader class under the Web site.
*/
| The code is as follows |
Copy Code |
|
$reader =new Spreadsheet_excel_reader ();
$reader->setutfencoder (' iconv ');
$reader->setoutputencoding (' utf-8 '); Document encoding that can be set
$reader->read ($filename);
If we output it in tabular form, we use the traversal
foreach ($reader->boundsheets as $k => $sheet)
{
echo "N$k: $sheet";
}
The data in the table is stored in the table variable. Each table is a two-dimensional array. Here's how to print all the data
foreach ($reader->sheets as $k => $data)
{
echo "nn". $reader->boundsheets[$k]. " nn ";
foreach ($data [' cells '] as $row)
{
foreach ($row as $cell)
{
echo "$cellt";
}
echo "n";
}
}
|