在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); }} 请前辈帮我解释一下下面的语句是什么意思,谢谢 关于xuzuning版主发的非递归树形数组构造函数问题 php代码语法错误:意想不到的字符串!! 如何给数组增加内容 使用PHPEXCEL读取网络文件 分不多了啊!PHP数据库查询,用户信息验证 字符串处理的问题,欢迎高手进来指点。。 讨论一下PHP代码与效率的问题 发一个菜鸟安装vbulletin的安装笔记 大家幫忙想想辦法!!!怎樣能取得用戶離開的時間??? 我真的想要那個數據!!!! 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);
}
}