为什么即使在关闭工作簿之后也会打开多个工作簿 [英] Why multiple work books are opening even after closing the workbook

查看:138
本文介绍了为什么即使在关闭工作簿之后也会打开多个工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我使用以下代码将我的工作保存到工作簿中并在将数据保存到工作簿后将其关闭



Hi,

I am using the following code to save my work into workbook and closing it after saving my data into it

object misValue = System.Reflection.Missing.Value;
            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);

            Excel._Worksheet xlWorksheet1 = xlWorkBook.Sheets[1];
            
            List<DataSet> lstDS1 = new List<DataSet>();

         lstDS1 = GetExcelData(@"\\global.scd.scania.com\home\se\121\valhbc\Desktop\log file data\Output\", "ResponseTime.xls");

       
            string path1 = Properties.Settings.Default.OutputDirPath + "\\" + "GatewayMsgs.xls";


            if (File.Exists(path1))
                File.Delete(path1);




          //do something



            xlWorkBook.SaveAs(path1, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlShared, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);



        }
    }





但是当我尝试的时候要在输出文件夹中打开工作簿,另一个空工作簿也会打开我保存的工作簿,每次工作簿编号都是如此(Book1,Book2,Book3等)



任何人都可以建议我解决这个问题的解决方案





谢谢

John



But when I am trying to open the workbook in output folder,another empty workbook is also opening with my saved workbook and every time the workbook number is incresing like(Book1,Book2,Book3 etc)

Can anyone please suggest me some olution to solve this problem


Thanks
John

推荐答案

我所知道的是它与Interop库有关。





阅读本文



http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects [ ^ ]
All I know is that it is something to do with the Interop library.


Have a read of this one

http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects[^]


这篇关于为什么即使在关闭工作簿之后也会打开多个工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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