我有一个html表,里面有一些数据,现在我想将这些数据输出到e excel,但我不知道该怎么做。我搜索了一些帖子,但我无法弄清楚它是如何工作的。我如何导入数据?到目前为止这是我的代码..感谢您的帮助
echo "<table id='pagesat' style='width:1000px;margin-top:10px;'>
<thead>
<tr>
<th><img id='img' src='images/sort.png'>OPERATORI</th>
<th><img id='img' src='images/sort.png'>KONTRATA</th>
<th><img id='img' src='images/sort.png'>ORE PUNE</th>
<th><img id='img' src='images/sort.png'>REZE</th>
<th><img id='img' src='images/sort.png'>PAGA BRUTO</th>
<th><img id='img' src='images/sort.png'>SIGURIME<br>PUNE MARRESI</th>
<th><img id='img' src='images/sort.png'>TAP</th>
<th><img id='img' src='images/sort.png'>PAGA NETO</th>
</tr>
</thead>
";
$totPaga = 0;
foreach($kontratat as $key => $value){
echo "
<tr>
<td>".$fullName."</td>
<td>".$rezultati[$key]."</td>
<td>".$kontratat_ore[$key]."</td>
<td>".$rese."</td>
<td>".$Pagesa_ndare.' lek'."</td>
<td>".$sigurime_vlera.' lek'."</td>
<td>".$vlera_tap_perfund.' lek'."</td>
<td>".$paga_neto_perf.' lek'."</td>
</tr>";
}
echo "</table>";
}
}
if(isset($_POST['download'])){
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'OPERATORI')
->setCellValue('B1', 'KONTRATA')
->setCellValue('C1', 'ORE PUNE')
->setCellValue('D1', 'REZE')
->setCellValue('E1', 'PAGA BRUTO');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="EGEO_PAGA.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
$objWriter->save('php://output');
exit;
}