原创作品,允许转载,转载时请务必以超链接形式标明文章
原始出处 、作者信息和本声明。否则将追究法律责任。
http://ustb80.blog.51cto.com/6139482/1066505
- $input_file = "data.xlsx";
- $objPHPExcel = PHPExcel_IOFactory::load($input_file);
- $sheetData = $objPHPExcel->getSheet(0)->toArray(null, true, true, true);
- set_time_limit(90);
- ini_set("memory_limit", "1024M");
- $input_file = "data.xlsx";
- $objPHPExcel = PHPExcel_IOFactory::load($input_file);
- $sheetData = $objPHPExcel->getSheet(0)->toArray(null, true, true, true);
- require 'lib/PHPExcel.php';
- set_time_limit(90);
- $input_file = "data.xlsx";
- $objPHPExcel = PHPExcel_IOFactory::load($input_file);
- // 读取规则
- $sheet_read_arr = array();
- $sheet_read_arr["sheet1"] = array("A","B","C","D","F");
- $sheet_read_arr["sheet2"] = array("A","B","C","D","F");
- // 循环所有的页
- foreach ($sheet_read_arr as $key => $val)
- {
- $currentSheet = $objPHPExcel->getSheetByName($key);// 通过页名称取得当前页
- $row_num = $currentSheet->getHighestRow();// 当前页行数
- // 循环从第二行开始,第一行往往是表头
- for ($i = 2; $i <= $row_num; $i++)
- {
- $cell_values = array();
- foreach ($val as $cell_val)
- {
- $address = $cell_val . $i;// 单元格坐标
- // 读取单元格内容
- $cell_values[] = $currentSheet->getCell($address)->getFormattedValue();
- }
- // 看看数据
- print_r($cell_values);
- }
- }
- require 'lib/PHPExcel.php';
- set_time_limit(90);
- $input_file = "data.xlsx";
- $objPHPExcel = PHPExcel_IOFactory::load($input_file);
- $sheet_count = $objPHPExcel->getSheetCount();
- for ($s = 0; $s < $sheet_count; $s++)
- {
- $currentSheet = $objPHPExcel->getSheet($s);// 当前页
- $row_num = $currentSheet->getHighestRow();// 当前页行数
- $col_max = $currentSheet->getHighestColumn(); // 当前页最大列号
- // 循环从第二行开始,第一行往往是表头
- for($i = 2; $i <= $row_num; $i++)
- {
- $cell_values = array();
- for($j = 'A'; $j < $col_max; $j++)
- {
- $address = $j . $i; // 单元格坐标
- $cell_values[] = $currentSheet->getCell($address)->getFormattedValue();
- }
- // 看看数据
- print_r($cell_values);
- }
- }