【VSTO】Office开发中遇到的兼容性检查问题
来源:互联网 发布:brew install node 6 编辑:程序博客网 时间:2024/06/03 21:21
事情是这样的:
我们的一个应用程序需要通过VSTO代码方式操作本地的Excel,包括打开工作簿,生成新的工作簿,设置数据,并且保存为新文件等等。
该程序在Excel 2003的环境下没有任何问题,但是在Excel 2007或者是Excel 2010中就老是遇到中途被卡住的状况。
究其原因,是因为我们想将文件继续保存为Excel 2003格式,但Excel 2007或者Excel 2010默认会有一个兼容性检查的功能。如下
如果将“Check compatiblity when saving this workbook”的选项关闭,则问题可以解决。
但是,如果你无法确保用户那边关闭了该选项,也可以通过程序的方式临时关闭检查
有两种方式实现这样的需求
第一种:在Application级别关闭警告
If (app Is Nothing) Then app = New Excel.Application app.Interactive = False app.UserControl = False app.DisplayAlerts = False app.Visible = False app.ScreenUpdating = False End If.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }
第二种:在Workbook级别关闭警告
wb.CheckCompatibility=False
还有一个情况就是,如果你关闭了警告(不管是手工地,还是代码关闭),却又想恢复该选项。要按照下面这样做
在上面的对话框中,点击“Check Compatibility”,你将可以继续勾选上这个选项。.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }
- 【VSTO】Office开发中遇到的兼容性检查问题
- VB.NET 开发中遇到的兼容性检查问题
- Office VSTO插件开发问题集
- VSTO开发中应避免有相同的项目名在同一个Office应用中
- win7 下安装oracle10g 遇到的问题 正在检查 Oracle 主目录的不兼容性...
- VSTO中开发Excle 常用的操作
- 整理上个项目中css+div兼容性遇到的问题
- 浏览器兼容性改造过程中遇到的问题
- 关于VSTO中ReleaseComObject的问题
- office档开发遇到的问题的解决方法笔记
- VSTO 向office文档中插入内容
- 制作VSTO 2005 SE开发的Office 2007 AddIn的安装包
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- 开发中遇到的问题
- wget使用技巧
- 如何在SQL Server中使用正则表达式
- SAP 系统参数设置 RZ10 RZ11
- tar
- linux下文件的切割与合并
- 【VSTO】Office开发中遇到的兼容性检查问题
- sed直接替换文件内容
- 常见SQL Server导入导出数据的几个工具
- 谈EXPORT_SYMBOL使用
- linux更改用户名
- 【SSAS】Model-First Cube 设计的最佳实践
- RIA Service中对于递归实体类型处理的问题及解决方案
- Linux的五个查找命令
- Linux操作系统挂载U盘和硬盘光驱的问题