简体   繁体   中英

Read excel data Sheet by sheet using codeigniter and mysql and phpexcel

I am done with basic import to database. I have explained in the following example where I got stuck up ...

For example,

I have an xls file named project.xls and it has 6 sheets. I have populated all 6 sheet names in dropdown. If I select sheet2 and click button, it should import sheet2 data into db and sheet3 so on.

How can I do this ...? please help me...

You can access to differents sheets of a file with PHPExcelReader this way:

$filename = "path/to/filename.xls";
$reader = new Spreadsheet_Excel_Reader(); // Your PHPEXCELREDER Class
$reader->setOutputEncoding('UTF8');
// Read XLS File
$reader->read($filename);
$sheet = 2; // Your sheet

// Then walk trough your wanted sheet:

for ($i = 2; $i <= $reader->sheets[$sheet]['numRows']; $i++) {
// Do something
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM