我写它使用的Microsoft.Office.Interop.Excel组件出口从Excel US preadsheets /导入数据的应用程序。一切都进行得很顺利(除1基于索引和所有可选参数!),直到我试图用条件格式。当我打电话Range.FormatConditions.Add我得到的MissingMethodException告诉我,这样的方法并不存在。这发生在Vista和XP。
下面是的code产生异常的例子:
// 1。添加引用的Microsoft.Office.Interop.Excel(版本11.0.0.0) // 2。编译并运行以下code: 使用的Microsoft.Office.Interop.Excel; 类节目 { 静态无效的主要(字串[] args) { 应用程序=新的应用程序(); 簿簿= app.Workbooks [1]; 工作表工作表=(表)workbook.Worksheets [1]; 范围范围= worksheet.get_Range(A1,A5); FormatCondition条件= range.FormatConditions.Add( XlFormatConditionType.xlCellValue, XlFormatConditionOperator.xlBetween, 100, 200); } }解决方案
这可能是你一个很好的链接:social.msdn.microsoft/Forums/en-US/vsto/thread/8a91d154-f766-427a-963c-16dfa39e154a/
I am writing an application which uses the Microsoft.Office.Interop.Excel assembly to export/import data from Excel spreadsheets. Everything was going fine (except for 1 based indexing and all those optional parameters!), until I tried to use conditional formatting. When I call Range.FormatConditions.Add I get a MissingMethodException telling me that no such method exists. This happens in both Vista and XP.
Here's an example of the code that generates the exception:
//1. Add a reference to Microsoft.Office.Interop.Excel (version 11.0.0.0) //2. Compile and run the following code: using Microsoft.Office.Interop.Excel; class Program { static void Main(string[] args) { Application app = new Application(); Workbook workbook = app.Workbooks[1]; Worksheet worksheet = (Worksheet)workbook.Worksheets[1]; Range range = worksheet.get_Range("A1", "A5"); FormatCondition condition = range.FormatConditions.Add( XlFormatConditionType.xlCellValue, XlFormatConditionOperator.xlBetween, 100, 200); } }解决方案
This may be a good link for you: social.msdn.microsoft/Forums/en-US/vsto/thread/8a91d154-f766-427a-963c-16dfa39e154a/
更多推荐
Excel的互操作:Range.FormatConditions.Add抛出的MissingMethodException
发布评论