| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 510 人关注过本帖
标题:请教各位:怎样访问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
快速回复:请教各位:怎样访问excel文件的数据?
数据加载中...
 
   



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

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