在PHP中如何将excel文件导入到mysql中?在线等待! 代码没有只有思路在php中调用com对象Excel.Application读取excel文件,循环读出每一行,再把每一行的各列写入mysql 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 同意樓上所說,我想在php中只在些方法了,還有如果你會在 php 中用 ado 你可以用它一試,我沒試過只是有此想法而已! 你只是要把Excel的数据转移到mysql而已吧,一把该文件设置为ODBC,然后怎么了........二是把Excel保存为txt格式,然后另行处理........ PHP生成名为test.xls的EXCEL代码如下:<?header("Content-type:application/vnd.ms-excel");header("Content-Disposition:filename=test.xls");echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";?> 至于反过来如何做,我再考虑一下,GZ!UP!! $conn=odbc_connect('ask4job','','',SQL_CUR_USE_ODBC);首先,把excel文件建立一个odbc连接,执行下面的程序$query = "SELECT * FROM tbl_name";$result = odbc_exec($conn, $query) or die('Select failed!');$i = 0;echo $fCount = odbc_num_fields($result);while (odbc_fetch_row($result)){ while ($i < $fCount) { $i++; echo $fName = odbc_field_name($result, $i); echo $fType = odbc_field_type($result, $i); echo $job[$fName] = odbc_result($result, $i); }} 是不是动态语言更适合Web编程 php结合mysql树状菜单问题 老是显示Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result php怎样定义二维数组? php菜鸟请教各位大虾 像这种水平可以找一个php网站制作的工作了吗? 微博的@功能的实现 关于目录权限修改为777后回产生的安全问题的讨论 cookie真的这么不可信? 有关session的问题 请大家指点! dll文件的路径问题 免费jsp、php、perl、cgi、mysql空间!!!!
<?header("Content-type:application/vnd.ms-excel");header("Content-Disposition:filename=test.xls");echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";?>
首先,把excel文件建立一个odbc连接,执行下面的程序
$query = "SELECT * FROM tbl_name";
$result = odbc_exec($conn, $query) or die('Select failed!');
$i = 0;
echo $fCount = odbc_num_fields($result);
while (odbc_fetch_row($result))
{
while ($i < $fCount)
{
$i++;
echo $fName = odbc_field_name($result, $i);
echo $fType = odbc_field_type($result, $i);
echo $job[$fName] = odbc_result($result, $i);
}
}