如何在后面的c#代码中连续打开2个excel
我想在 C# 中连续打开 2 个 Excel 工作簿(一个接着一个)。我怎样才能做到这一点? 我使用如下:
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + File1 + ".xls");
Response.TransmitFile(savepath);
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + File2 + ".xls");
Response.TransmitFile(savepath);
HttpContext.Current.ApplicationInstance.CompleteRequest();
但是,只传输了一个Excel,我怎样才能获得第二个Excel?
提前致谢
I want to open 2 excel workbooks continuously(one after the one) in c#. How can I achieve this??
I used like below:
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + File1 + ".xls");
Response.TransmitFile(savepath);
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + File2 + ".xls");
Response.TransmitFile(savepath);
HttpContext.Current.ApplicationInstance.CompleteRequest();
However, Only one excel is transmitted, How can I get the second one also???
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTTP 在这方面受到限制,每个请求只能处理单个响应 - 您需要考虑其他方法来解决此问题,例如通过客户端脚本发出多个请求,或者将文件合并到单个存档文件中(例如 ZIP 文件)在传输之前
HTTP is limited in this respect that each request can only handle a single response - you'd need to look at other ways of approaching this, such as issuing multiple requests via scripting from the client side, or combining your files into a single archive file (such as a ZIP file) prior to transmission
作为一个想法 - 您可以将两个 Excel 文件合并为一个作为单独的工作表。
As an idea - you can combine two excel files into one as separate sheets.