乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>linux</em>下数据库输出到excel里面

<em>linux</em>下数据库输出到excel里面

作者:乔山办公网日期:

返回目录:excel表格制作


这和在什么系统下没有任何关系

<?php
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=test.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo '<table border="1" cellspacing="2" cellpadding="2" width="50%" align="center">';
echo '<tr bgcolor="#cccccc"><td colspan="3" align="center">' . $title . '</td></tr>';

$query="select * from test";
$result=mysql_query($query) or die(mysql_error());
$fields=mysql_num_fields($result);
// 输出字段e799bee5baa6e79fa5e98193e58685e5aeb9337
echo '<tr bgcolor="blue">';
for($i=0; $i < $fields; $i++) {
echo '<td>' . mysql_field_name($result,$i) . '</td>';
}
echo '</tr>';
// 输出内容
while($row=mysql_fetch_row($result)) {
echo '<tr>';
for($i=0; $i<$fields; $i++) {
echo '<td>' . $row[$i] . '</td>';
}
echo '</tr>';
}
echo '</table>';
?>

你好

网上有一个写好的类库了,你百度查找一下,

剩下的就是简单连接一下数据库和你的数据表

剩下的就可以导出了
bash擅长的是纯文本处理,而非这种带格式的文本处理。
你可以将excel另存为csv格式,然后再用bash处理。(csv格式中同一行的各单元格之间默认是以TAB分隔)

你好 网上有一个写好的类库了,你百度查找一下, 剩下的就是简单连接一下数据库和你的数据表 剩下的就可以导出了

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网