[英]Export table as excel in php
我的表在表的td內有輸入類型的文本,我得到空值。使用jquery.table2excel.js導出表。 這是示例代碼
<tr>
<td class="DG_table">
<span class="left">Total Revenue ($)</span>
</td>
<td class="DG_table">
<input class="form-control" type="text" value="2779695.009431"/>
</td>
<td class="DG_table">
<input class="form-control" type="text" value="2779695.009431"/>
</td>
</tr>
您有兩種選擇,可以將數據轉換為CSV,或使用PHPExcel庫
您可以將數據放入數組並使用fputcsv函數。
CSV范例
$data = array (
array('row 1 col 1', 'row 1 col 2', 'row 1 col 3'),
array('row 2 col 1', 'row 2 col 2', 'row 2 col 3'),
array('row 3 col 1', 'row 3 col 2', 'row 3 col 3'),
);
$file = fopen('mycsv.csv', 'w');
foreach ($data as $cells) {
fputcsv($file, $cells);
}
fclose($file);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.