您好我在IIS中部署了ASP.Net中的web_application,我的数据库是MySQL,我的Export_button正在使用Local但不是在部署时吗?下面是我在Export_button背后的代码,你能告诉我我错过了什么吗?
protected void Export_Click(object sender, EventArgs e)
{
try
{
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
excel.Visible = true;
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Add(System.Reflection.Missing.Value);
Microsoft.Office.Interop.Excel.Worksheet sheet1 = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
int StartCol = 1;
int StartRow = 1;
int j = 0, i = 0;
//Write Headers
for (j = 0; j < GridView1.Columns.Count; j++)
{
Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[StartRow, StartCol + j];
myRange.Value2 = GridView1.Columns[j].HeaderText;
}
StartRow++;
//Write datagridview content
for (i = 0; i < GridView1.Rows.Count; i++)
{
for (j = 0; j < GridView1.Columns.Count; j++)
{
try
{
Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[StartRow + i, StartCol + j];
myRange.Value2 = GridView1.Rows[i].Cells[j].Text == null ? "" : GridView1.Rows[i].Cells[j].Text;
}
catch
{
;
}
}
}
}
catch
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"alertMessage",
"alert('Unable to export, contact Administrator');", true);
}
}
更新: 我在DCOMCNFG中将Microsoft Excel的标识编辑为Interactive User,当用户单击Export_Button时,Exportfile显示但是在Host Server中,是否可以将其显示给单击Export_button的用户?