110,502
社区成员
发帖
与我相关
我的任务
分享
static class Program
{
static Excel.Application _resource;
public static Excel.Application Resource
{
get
{
// 仅在第一次访问这个属性时才创建Excel进程
if (_resource == null)
{
_resource = new Excel.Application();
}
return _resource;
}
}
// 程序主入口
static void Main()
{
// .....
Application.Run(new MainForm());
// 主窗体关闭以后清理资源
if (_resource != null)
{
// 关闭Excel进程
_resource.Quit();
}
}
}