2016-08-04 57 views
0

我的表格里面有输入类型文本,我得到空白值。使用jquery.table2excel.js导出表格。 下面是示例代码在php中导出表格为excel

<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> 
+0

使用PHPExcel库 –

+0

的问题是客户想要编辑的价值,并得到了Excel飞。 –

+0

没问题你也可以用这个库来实现,可以通过https://github.com/PHPOffice/PHPExcel生成excel –

回答

0

你有几个选项,您可以将您的数据转换成CSV,或使用PHPExcel Library

你可以把你的数据到阵列和使用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);