时间:2021-07-01 10:21:17 帮助过:4人阅读
getProperties()->setCreator(”Maarten Balliauw”); $objPHPExcel->getProperties()->setLastModifiedBy(”Maarten Balliauw”); $objPHPExcel->getProperties()->setTitle(”Office 2007 XLSX Test Document”); $objPHPExcel->getProperties()->setSubject(”Office 2007 XLSX Test Document”); $objPHPExcel->getProperties()->setDescrīption(”Test document for Office 2007 XLSX, generated using PHP classes.”); $objPHPExcel->getProperties()->setKeywords(”office 2007 openxml php”); $objPHPExcel->getProperties()->setCategory(”Test result file”); // Add some data echo date(’H:i:s’) . ” Add some data\n”; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setCellValue(’A1′, ‘Hello’); $objPHPExcel->getActiveSheet()->setCellValue(’B2′, ‘world!’); $objPHPExcel->getActiveSheet()->setCellValue(’C1′, ‘Hello’); $objPHPExcel->getActiveSheet()->setCellValue(’D2′, ‘world!’); // Rename sheet echo date(’H:i:s’) . ” Rename sheet\n”; $objPHPExcel->getActiveSheet()->setTitle(’Simple’); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Save Excel 2007 file echo date(’H:i:s’) . ” Write to Excel2007 format\n”; $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); $objWriter->save(str_replace(’.php’, ‘.xlsx’, __FILE__)); // Echo done echo date(’H:i:s’) . ” Done writing file.\r\n”;
send(’test.xls’); // Creating a worksheet $worksheet =& $workbook->addWorksheet(’My first worksheet’); // The actual data $worksheet->write(0, 0, ‘Name’); $worksheet->write(0, 1, ‘Age’); $worksheet->write(1, 0, ‘John Smith’); $worksheet->write(1, 1, 30); $worksheet->write(2, 0, ‘Johann Schmidt’); $worksheet->write(2, 1, 31); $worksheet->write(3, 0, ‘Juan Herrera’); $worksheet->write(3, 1, 32); // Let’s send the file $workbook->close(); ?>
Application->value}\n” ; print “Loaded version: {$excel_app->Application->version}\n”; $Workbook = $excel_app->Workbooks->Open(”$filename”) or Die(”Did not open $filename $Workbook”); $Worksheet = $Workbook->Worksheets($sheet1); $Worksheet->activate; $excel_cell = $Worksheet->Range(”C4″); $excel_cell->activate; $excel_result = $excel_cell->value; print “$excel_result\n”; $Worksheet = $Workbook->Worksheets($sheet2); $Worksheet->activate; $excel_cell = $Worksheet->Range(”C4″); $excel_cell->activate; $excel_result = $excel_cell->value; print “$excel_result\n”; #To close all instances of excel: $Workbook->Close; unset($Worksheet); unset($Workbook); $excel_app->Workbooks->Close(); $excel_app->Quit(); unset($excel_app); ?>
setOutputEncoding(’utf8′); $data->read(’ jxlrwtest.xls’); error_reporting(E_ALL ^ E_NOTICE); for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { echo “\”".$data->sheets[0]['cells'][$i][$j].”\”,”; } echo “\n”; } ?>