标题:请教各位:怎样访问excel文件的数据?
只看楼主
lilan1221
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-1-2
 问题点数:0 回复次数:0 
请教各位:怎样访问excel文件的数据?
我写代码如下,但总有问题,服务器通知我:无法识别的数据库格式c:\production.xls
using System.Data.OleDb;
using System.Drawing.Imaging;
namespace WebApplication1
{
public class 数据饼图 : System.Web.UI.Page
{
int [] Num=new int[12];
string [] Mon=new string[12];
int iIndex=0;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
OleDbConnection myconn=new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=c:\\production.xls;");
try
{
string str_sql="select month,number from [table1$] order by month";
OleDbCommand mycmd=new OleDbCommand(str_sql,myconn);
myconn.Open();
OleDbDataReader myreader=mycmd.ExecuteReader();
while(myreader.Read())
{
Num[iIndex]=myreader.GetInt32(1);
Mon[iIndex]=myreader.GetInt32(0).ToString()+"月";
iIndex++;
}
myreader.Close();
myconn.Close();
draw();
}
finally
{
myconn.Close();
}
}
}
搜索更多相关主题的帖子: excel 数据 文件 访问 
2007-02-10 14:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-120549-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.469315 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved