Excel进程无法在Windows Server Standard Service Pack 1中终止 [英] Excel process not able to kill in Windows Server Standard Service Pack 1

查看:134
本文介绍了Excel进程无法在Windows Server Standard Service Pack 1中终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



下面是我用来打开Excel工作表并将其另存为CSV文件的方法.在Windows 7,Windows Server 2008 R2中,excel进程在处理完excel文件后会自动终止自身.在Windows Server 2008 Standard Service Pack1中,它继续创建大量Excel进程并显示消息"Microsoft Excel错误-没有足够的系统资源无法完全显示."

在任务管理器中几乎有200个Excel进程在那一刻没有被杀死,并且服务器被挂起./

下面是用于处理许多Excel文件的代码.

Hi ,

Below is the method I used to open Excel sheet and save it as CSV file. In Windows 7, Windows Server 2008 R2, the excel process/es is automatically killing itself after processing the excel file/s. In windows Server 2008 Standard Service Pack1, Its going on creating a lot of Excel processes and showing the message ''Microsoft Excel Error - Not enough system resources to display completely.''

Almost near to 200 Excel processes are at Task Manager without killing at that instant and server is hanged./

Below is the code is used to process lot of Excel files.

private static bool SaveExcelCVS(string fileName, string outFile)
        {
            bool success = false;

            try
            {
                Excel.Application xApp = new Excel.Application();
                Excel.Workbook xF1 = xApp.Workbooks.Open(fileName,
                    0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
                    true, false, 0, true, false, false);
                xF1.SaveAs(outFile, Excel.XlFileFormat.xlCSV, "", "", false, false,
                Excel.XlSaveAsAccessMode.xlNoChange, Excel.XlSaveConflictResolution.xlLocalSessionChanges,
                false, false, false, false);
                xF1.Close(false);
                xF1 = null;
                xApp.Quit();
                xApp = null;
                success = true;
            }
            catch
            {
            }
            return success;
        }

推荐答案

为什么不杀死该进程?

http://july-code.blogspot.com/2008/11/kill-excelexe-process-in-c-net.html [ http://social.msdn.microsoft.com /Forums/zh-CN/csharpgeneral/thread/8c89fd55-0571-444f-a3df-ce47839ed5aa/ [
Why don''t you kill the process?

http://july-code.blogspot.com/2008/11/kill-excelexe-process-in-c-net.html[^]

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8c89fd55-0571-444f-a3df-ce47839ed5aa/[^]


尝试以下代码:

Try the following code :

private static bool SaveExcelCVS(string fileName, string outFile)
        {
            bool success = false;
            Excel.Application xApp = new Excel.Application(); 
            try
            {

                Excel.Workbook xF1 = xApp.Workbooks.Open(fileName,
                    0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
                    true, false, 0, true, false, false);
                xF1.SaveAs(outFile, Excel.XlFileFormat.xlCSV, "", "", false, false,
                Excel.XlSaveAsAccessMode.xlNoChange, Excel.XlSaveConflictResolution.xlLocalSessionChanges,
                false, false, false, false);
                xF1.Close(false);
                xF1 = null;

                success = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }
            finally
            {
                xApp.Quit();
                xApp = null;            
            }
            return success;
        }


这篇关于Excel进程无法在Windows Server Standard Service Pack 1中终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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