我需要打开一个没有新书的 excel 应用程序。可能吗?这是我的代码:
public static Excel.Application InitializeTemplateExcelApp(string logFile)
{
            Excel.Application app = null;
            try
            {
                app = new Excel.Application();
                app.Visible = true;
                // reload all previously loaded addins
                foreach (Excel.AddIn ai in app.AddIns)
                {
                    if (ai.Installed != false)
                    {
                        ai.Installed = false;
                        ai.Installed = true;
                        app.Wait(30);
                    }
                }
                return app;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message.ToString();
                File.AppendAllText(logFile, errMessage);
                return null;
            }
        }
问题是当我初始化 excel 应用程序时,会自动创建新的工作簿。之后我需要打开我自己的工作簿,它已经成为第二个打开的工作簿,我想避免这种情况。
谢谢你的帮助,
伊利亚