asp.net在本地导出excel正常,发布之后,导出按钮失效,点了没反应
本帖最后由 w_775728638 于 2013-03-31 09:47:35 编辑
protected void OUT_Click(object sender, EventArgs e)
{
string physicPath = Server.MapPath("WebShow\\");
EnterpriseOpration.WebShow.Z_student student = new EnterpriseOpration.WebShow.Z_student();
if (DDL_yuanxi.SelectedValue!="")
{
student.Yuanxi = DDL_yuanxi.SelectedValue.ToString();
}
if (DDL_PKlevel.SelectedValue!="")
{
student.Pklevel = DDL_PKlevel.SelectedValue.ToString();
}
System.Data.DataTable table = student.GetDataTable();//获得学生表
string fileName = "学生信息.Xls";
try
{
if (System.IO.File.Exists(physicPath + fileName))
{
System.IO.File.SetAttributes(physicPath + fileName, System.IO.FileAttributes.Normal);
System.IO.File.Delete(physicPath + fileName);
}
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + physicPath + fileName + ";Extended Properties=Excel 8.0;";
System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(connString);
System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand();
objCmd.Connection = objConn;
objCmd.Connection.Open();
#region 组织机构信息导出
//建立表结构
objCmd.CommandText = @"CREATE TABLE student(学号 varchar,姓名 varchar,性别 varchar,院系 varchar,专业 varchar,班级 varchar,贫困等级 varchar,勤工助学 varchar,励志奖学金 varchar,国家奖学金 varchar,绿色通道 varchar,身份证号 varchar,电话 varchar)";
objCmd.ExecuteNonQuery();
//建立插入动作的Command
&