Ich schreibe eine Anwendung, die die Microsoft.Office.Interop.Excel-Assembly zum Exportieren/Importieren von Daten aus Excel-Tabellen verwendet. Alles lief gut (außer 1-basierter Indizierung und all diesen optionalen Parametern!), Bis ich versuchte, bedingte Formatierung zu verwenden. Wenn ich Range.FormatConditions.Add aufruft, bekomme ich eine MissingMethodException, die mir sagt, dass keine solche Methode existiert. Dies geschieht sowohl in Vista als auch in XP.Excel Interop: Range.FormatConditions.Add wirft MissingMethodException
Hier ist ein Beispiel für den Code, der die Ausnahme erzeugt:
//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);
}
}
Danke! Diese Verbindung löste das Problem. Ich konnte Reflektion verwenden, um die Methode aufzurufen, und nun funktioniert alles super! –