programming4:module:framework
Đây là một phiên bản cũ của tài liệu!
Mục lục
Hướng dẫn sử dụng các framework trong lập trình module
phpExcel
1. Điều kiện sử dụng PHPExcel
Để sử dụng được bộ thư viện viết bằng php này thì đòi hỏi cấu hình Server bạn phải như sau:
PHP version 5.2.0 hoặc mới hơn PHP extension php_zip enabled PHP extension php_xml enabled PHP extension php_gd2 enabled
2. Download PHPExcel
Lấy từ: https://github.com/PHPOffice/PHPExcel Cần lọc ra từ thư mục: Classes lưu trữ vào để có được: - file /includes/class/PHPExcel.php - Thư mục: /includes/class/PHPExcel/
Hoặc download từ http://nukeviet.vn/vi/store/other/phpexcel/
Hoặc có sẵn trong module scores. https://vinades.org/nukeviet/module-scores
3. Sử dụng
Đoạn code sau để kiểm tra thư viện và đọc file excel, tìm số dòng, số cột của file
if( ! file_exists( NV_ROOTDIR . "/includes/class/PHPExcel.php" ) ) { die( 'Error: No class PHPExcel' ); } require_once (NV_ROOTDIR . "/includes/class/PHPExcel.php"); $objPHPExcel = PHPExcel_IOFactory::load( NV_UPLOADS_REAL_DIR . "/" . $module_name . "/" . $file_name ); $objWorksheet = $objPHPExcel->getActiveSheet( ); $highestRow = $objWorksheet->getHighestRow( ); // e.g. 10 $highestColumn = $objWorksheet->getHighestColumn( ); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString( $highestColumn );
programming4/module/framework.1466497315.txt.gz · Sửa đổi lần cuối: 2016/06/21 15:21 bởi hoaquynhtim99