如果默认应用为Office Excel,则C#MVC核心StartInfo /过程打印.XLSX将继续加载,直到错误502

时间:2019-01-28 04:48:25

标签: c# asp.net excel printing processstartinfo

这是我的代码

            string destinationFileWord = filePath;

            Process print = new Process();
            print.StartInfo.FileName = destinationFileWord;
            print.StartInfo.UseShellExecute = true;

            print.StartInfo.CreateNoWindow = true;
            print.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            print.StartInfo.Verb = "PrintTo";

            print.StartInfo.Arguments = Utility.GetAppSettings("PrinterSettings", "Address1");
            print.StartInfo.WorkingDirectory = Path.GetDirectoryName(destinationFileWord);
            print.Start();

            if (print.HasExited == false)
            {
                print.WaitForExit(5000);

            }

以上代码仅在LibreOffice Calc是我的默认应用程序时有效。如果是Microsoft Excel,它将继续加载。

有人知道为什么吗?

0 个答案:

没有答案