码迷,mamicode.com
首页 > 数据库 > 详细

access数据库在线生成xls电子表格

时间:2020-02-05 13:31:34      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:sys   pos   data   cmd   provider   direct   access   cto   sheet   

protected void Button1_Click(object sender, EventArgs e)
{

OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|***.mdb;");
conn.Open();
string sql = "select count(*) from m";
OleDbCommand cmd = new OleDbCommand(sql, conn);
int rc = (int)cmd.ExecuteScalar();
try
{
sql = @"select top 65534 * into [Excel 8.0;database=" + Server.MapPath(".") + @"\**.xls].[Sheet1] from m";
cmd = new System.Data.OleDb.OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
conn.Dispose();
conn = null;
Response.Write("文件已经生成,请下载!");
}
catch (Exception ex)
{

Response.Write(ex.Message.ToString());
}

}

access数据库在线生成xls电子表格

标签:sys   pos   data   cmd   provider   direct   access   cto   sheet   

原文地址:https://www.cnblogs.com/houweidong/p/12263218.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!