在web页面上无法打开excel~~~~~~~
HttpResponse resp;
resp = myhr;
resp.ContentType = "application/vnd.ms-excel ";
resp.ContentEncoding = System.Text.Encoding.GetEncoding( "GB2312 ");
resp.AppendHeader( "Content-Disposition ", "attachment;filename= " + FileName);
string colHea = " ", ls_item = " ";
int i = 0;
System.Data.DataTable dt = datatable;
DataRow[] myRow = dt.Select();
if (typeid == "1 ")
{
int count = dt.Columns.Count;
for (i = 0; i < count - 1; i++)
{
colHea += dt.Columns[i].Caption.ToString() + "\t ";
}
colHea += dt.Columns[count - 1].Caption.ToString() + "\n ";
resp.Write(colHea);
foreach (DataRow row in myRow)
{
for (int j = 0; j < count - 1; j++)
{
ls_item += row[j].ToString() + "\t ";
}
ls_item += row[count - 1].ToString() + "\n ";
}
resp.Write(ls_item);
}
resp.End();
打开excel代码如上,是将一个Table导入excel并打开,可是奇怪的是在弹出excel打开窗口后我点击打开,窗口消失后就没有任何反应了,别人访问我的机器却可以打开excel,我的机器是win2000,没有任何的防火墙和工具条,郁闷中,请教达人!!!!!!
------解决方案--------------------修改你浏览器的安全设置即可
------解决方案--------------------浏览器安全设置
添加到本地站点试一下
------解决方案--------------------浏览器把弹出窗口过滤了
------解决方案--------------------应该是excel的进程已经打开了。你在任务管理器中看一下
------解决方案--------------------