<%
...
@ Page Language="C#"
%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< script runat ="server" > ...
protected void Button1_Click(object sender, EventArgs e)
...{
string sql;
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|ASPNET20Book.mdb;Persist Security Info=True";
System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection(connstr);
System.Data.OleDb.OleDbCommand cmd;
cn.Open();
//先得到记录数目:
sql = "select Count(*) From Paging";
cmd = new System.Data.OleDb.OleDbCommand(sql, cn);
int RecordCount = (int)cmd.ExecuteScalar();
// TODO:计算Sheet数目,进行记录分段,将不同的数据段导入到不同的Sheet(Sheet数目不知道有没有限制:()
// TODO:文件名,Sheet名字的存在检测略
//每个Sheet只能最多保存65536条记录。
sql = @"select top 65535 * into [Excel 8.0;database=" + Server.MapPath(".") + @"ASPNET20Book.xls].[Sheet1] from Paging";
cmd = new System.Data.OleDb.OleDbCommand(sql, cn);
cmd.ExecuteNonQuery();
cn.Close();
cn.Dispose();
cn = null;
}
</ script >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< script runat ="server" > ...
protected void Button1_Click(object sender, EventArgs e)
...{
string sql;
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|ASPNET20Book.mdb;Persist Security Info=True";
System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection(connstr);
System.Data.OleDb.OleDbCommand cmd;
cn.Open();
//先得到记录数目:
sql = "select Count(*) From Paging";
cmd = new System.Data.OleDb.OleDbCommand(sql, cn);
int RecordCount = (int)cmd.ExecuteScalar();
// TODO:计算Sheet数目,进行记录分段,将不同的数据段导入到不同的Sheet(Sheet数目不知道有没有限制:()
// TODO:文件名,Sheet名字的存在检测略
//每个Sheet只能最多保存65536条记录。
sql = @"select top 65535 * into [Excel 8.0;database=" + Server.MapPath(".") + @"ASPNET20Book.xls].[Sheet1] from Paging";
cmd = new System.Data.OleDb.OleDbCommand(sql, cn);
cmd.ExecuteNonQuery();
cn.Close();
cn.Dispose();
cn = null;
}
</ script >