creer un fichier Excel c#
Bonjour,
J'ai ce problème ci lorsque je tente de creer un fichier excel.
System.InvalidCastException*: 'Impossible d'effectuer un cast d'un objet COM de type 'Microsoft.Office.Interop.Excel.ApplicationClass' en type d'interface 'Microsoft.Office.Interop.Excel._Application'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{000208D5-0000-0000-C000-000000000046}' a échoué en raison de l'erreur suivante*: Erreur lors du chargement de la bibliothèque/DLL du type. (Exception de HRESULT : 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).'
J'ai beau chercher sur le net je vois que c'est un soucis récurrent.
Ce que j'ai fait :
désinstaller office
Nettoyer la base de registre
Nettoyer le projet
redemarrer
Reinstallation Office.
Ajouter la DLL dans les reference.. et ca replante ou c'est mon code qui est pourri.
Excel version 64 bits compilation idem.
Code:
1 2 3 4 5 6 7 8 9 10 11
|
using Excel=Microsoft.Office.Interop.Excel;
.
.
.
Excel.Application Exl = new Excel.Application();
var Wb =(Excel.Workbook)Exl.Workbooks.Add(); <--- La Ligne de plantage
var ws = (Excel.Worksheet)Exl.Worksheets.Add(); |
Merci