J'écris une application qui utilise l'assembly Microsoft.Office.Interop.Excel pour exporter/importer des données à partir de feuilles de calcul Excel. Tout allait bien (sauf pour 1 indexation et tous ces paramètres optionnels!), Jusqu'à ce que j'ai essayé d'utiliser le formatage conditionnel. Lorsque j'appelle Range.FormatConditions.Add, j'obtiens une exception MissingMethodException m'indiquant qu'aucune telle méthode n'existe. Cela se produit à la fois dans Vista et XP.Excel Interop: Range.FormatConditions.Add throws MissingMethodException
Voici un exemple du code qui génère l'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);
}
}
Merci! Ce lien a résolu le problème. J'ai été capable d'utiliser la réflexion pour invoquer la méthode et maintenant tout fonctionne bien! –