首页 > Web开发 > 详细

asp.net excel 操作

时间:2014-04-23 14:28:10      阅读:550      评论:0      收藏:0      [点我收藏+]

/// <summary>
/// 数据操作
/// </summary>
/// <param name="fileName"></param>
/// <param name="savePath"></param>
private void DataOperator(string fileName, string savePath)
{
string myString = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + savePath + fileName + ";Extended Properties=Excel 8.0";
OleDbConnection oconn = new OleDbConnection(myString);
oconn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter oda = new OleDbDataAdapter("select * from [Sheet1$]", oconn);
oda.Fill(ds);
oconn.Close();
DataSetOperator(ds, savePath + fileName);
}
/// <summary>
/// 数据集操作
/// </summary>
/// <param name="ds"></param>
private void DataSetOperator(DataSet ds, string filePath)
{
string sqlStr = "";
int k = 0;
try
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{

 

try
{


k++;
}
catch
{
continue;
}
}

}
catch (Exception ex)
{
// Response.Write("发生异常,数据已回滚/n信息/n" + ex.Message);

}
finally
{

Response.Write(sqlStr + "共转换" + k + "条");

}
}
#endregion

asp.net excel 操作,布布扣,bubuko.com

asp.net excel 操作

原文:http://www.cnblogs.com/rongfengliang/p/3681802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!