asp.net excel 操作

/// <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 操作

上一篇:一道js面试题看变量的作用域


下一篇:开机提示: Booting system without full network configuration