40.
return true;
41.
}
42.
catch (Exception err)
43.
{
44.
MessageBox.Show("导出 Excel 出错!错误原因:" + err.Message,
"提示信息",
45.
MessageBoxButtons.OK, MessageBoxIcon.Information);
46.
return false;
47.
}
48.
finally
49.
{
50.
}
51.
}
Error: Reference source not found
转载的朋友请一定注明出处谢谢!
http://blog.csdn.net/gisfarmer/
我们在做 excel 资料的时候,通常有以下方法。
一.导入导出 excel 常用方法:
1.用查询表的方式查询并 show 在数据集控件上。
§§代码
public
static
string
strCon =
" Provider = Microsoft.Jet.OLEDB.4.0 ;
Data Source =C:\\08.xls;Extended Properties=Excel 8.0"
;
public
static
DataSet ds;
protected
void
Page_Load(
object
sender, EventArgs e)
{
OleDbConnection conn =
new
OleDbConnection(strCon);
string
sql =
"select * from [Sheet1$]"
;
conn.Open();
OleDbDataAdapter myCommand =
new
OleDbDataAdapter(sql,
strCon);
ds =
new
DataSet();
myCommand.Fill(ds,
"[Sheet1$]"
);