how can I get some examples or help files of "reading data from excel file"?

Topics: Developer Forum
Jun 26, 2010 at 8:54 AM

I read the developer_documentation but it seems that hard to find such content, about "reading date from excel", I'll appreciate if someone adv some...thanks!

Jun 29, 2010 at 2:22 PM
Edited Jun 29, 2010 at 2:28 PM
Sorry, I cannot format the code to make it readeable!! Example with named range: /** PHPExcel */ require_once 'PHPExcel.php'; /** PHPExcel_IOFactory */ require_once 'PHPExcel/IOFactory.php'; // Create new PHPExcel object echo "
" . date('H:i:s') . " Create new PHPExcel object\n"; $objPHPExcel = PHPExcel_IOFactory::load("toolHipotecaCalcV0.1.xlsx"); $objPHPExcel->setActiveSheetIndexByName( 'InputParameters New' ) ; $key = "out_calc_filtersQuery" ; // READING ----------------------------------------------------- if( ! $objPHPExcel->getActiveSheet()->cellExists( $key ) ) { throw( new Exception( "Named Range not valid: $key") ); } $cellNamedRange = $objPHPExcel->getNamedRange( $key , $objPHPExcel->getActiveSheet() ) ; /* * read the cell range from its namedrange */ $range = $cellNamedRange->getRange() ; /* * Get the cell value */ $value = $objPHPExcel->getActiveSheet()->getCell( $range )->getCalculatedValue() ; echo "
" ;
print( $value ) ;
echo "
" ; echo "
" . date('H:i:s') . " End of execution\n";
Jul 3, 2010 at 10:23 AM

Thank you very much!

I think for reading data from EXCEL, maybe phpExcelReady is more easy......

anyway,I 'll keep this as another method which I may use next time!

Jul 9, 2010 at 3:17 PM
Edited Jul 9, 2010 at 3:18 PM
@kentyoo - Please explain better what you need. @bitsurs -- [quote]Sorry, I cannot format the code to make it readeable!! [/quote] USE THE [CODE] tag
Jul 10, 2010 at 3:49 AM

Frankly, I think you've made it quite nice already. In my opnion, PHPExcel is good at exporting xls file & phpExcelReader is easier using for fetching data.