Excel没有打开? [英] Excel is not opening ?

查看:76
本文介绍了Excel没有打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IIS上部署我的网站后。 Excel没有打开。但它与localhost一起工作正常。



After deploying my website on IIS. the Excel is not opening. but its working fine with localhost.

protected void LinkButton1_Click(object sender, EventArgs e)
    {
        string s = "~//Template/Aug.xlsx";
        
        string directoryPath = Path.Combine(Server.MapPath(s));

        System.Diagnostics.Process.Start(directoryPath);
    }





如何打开我在客户端PC上的WebFolder上传的excel。



How then can i open the excel which i uploaded in WebFolder in client PC.

推荐答案

路径名称错误,甚至无法编译。使用逐字字符串文字格式@.. \ ..,或使用\\转义每个\。使用相对或绝对路径,〜\ ..将不起作用。在操作系统用户的任何手册中阅读有效路径名称。



无论如何,在生产级软件中不存在硬编码路径名称的情况。



-SA
Path name is wrong and cannot even compile. Use verbatim string literal format @"..\..", or escape each \ with \\. Use relative or absolute path, "~\.." won't work. Read about valid path names in any manual for the OS users.

Anyway, there are no situations where hard-coded path name can be used in production-grade software.

—SA


除了解决方案1 ​​ -



您还需要考虑您的尝试。我希望您确实知道您正在尝试在服务器上打开Excel?想想它只有一秒钟,因为你的代码在服务器上运行然后它将尝试在服务器上打开Excel。



在你问为什么它可以工作之前localhost,原因是你的开发机器既是客户端又是服务器。
In addition to Solution 1 -

You also need to consider what you are attempting to do. I hope that you do know that you are attempting to open Excel on the server? Think about it for just one second, since your code runs on the server then it will attempt to open Excel on the server.

And before you ask why it works on the localhost, the reason is that you development machine is both the client and the server.


这篇关于Excel没有打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆