Excel的互操作:Range.FormatConditions.Add抛出的MissingMethodException

编程入门 行业动态 更新时间:2024-10-24 10:18:15
本文介绍了Excel的互操作:Range.FormatConditions.Add抛出的MissingMethodException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写它使用的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

本文发布于:2023-11-10 15:50:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:抛出   操作   Range   Excel   MissingMethodException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!