高分求助,不够可以再加,数据导入excel的问题,服务器端可以导客户端不能导,急!

lhyang761030 lhyang761030 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Excel.Application excel= new Excel.Application();
int rowIndex=1;
int colIndex=0;
excel.Application.Workbooks.Add(true);
Excel._Worksheet xSt;
Excel._Workbook xBk;
xBk = excel.Workbooks.Add(true);
xSt = (Excel._Worksheet)xBk.ActiveSheet;
DataTable table=new DataTable();
table=dat_Device.Device_Excel(Page.Request.QueryString.Get("ID"));
excel.Cells[1,1]="设备编号";
excel.Cells[1,2]="设备名称";
excel.Cells[1,3]="设备序列号";
excel.Cells[1,4]="使用时间";
//处理数据
foreach(DataRow row in table.Rows)
{
rowIndex++;
colIndex=0;
foreach(DataColumn col in table.Columns)
{
colIndex++;
excel.Cells[rowIndex,1]=table.Rows[0]["cDeviceNo"].ToString().Trim();
excel.Cells[rowIndex,2]=table.Rows[0]["cDeviceName"].ToString().Trim();
excel.Cells[rowIndex,3]=table.Rows[0]["cSerialNo"].ToString().Trim();
excel.Cells[rowIndex,4]=table.Rows[0]["dtUse"].ToString().Trim();
}
}
xSt.get_Range(excel.Cells[1,1],excel.Cells[rowIndex,11]).Borders.LineStyle = 1;

//不可见,即后台处理
excel.Visible=true;
我用了上面的代码导数据,但是服务器上可以,其他的机器来测试点了导入没有反映,也打不开excel,请帮忙.
...全文
评论 9
收藏 已收藏
分享
返回顶部
lhyang761030
.NET社区 62,271 成员 668,968 内容