J'essaie de manipuler un file excel (xls), en utilisant un plugin personnalisé créé pour moi sur Dynamics CRM 2015. Le file se trouve dans un disque c: / sur mon server Dynamics CRM. Mon problème est quand j'essaie d'ouvrir le file Excel pour insert des données, j'ai la prochaine erreur:
Exception non gérée: System.ServiceModel.FaultException`1 [[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version = 7.0.0.0, Culture = neutre, PublicKeyToken = 31bf3856ad364e35]]: System.Runtime.InteropServices.COMException ( 0x800A03EC):
Mon code est le suivant:
Microsoft.Office.Interop.Excel.Application oXL; Microsoft.Office.Interop.Excel._Workbook oWB; Microsoft.Office.Interop.Excel._Worksheet oSheet; try { selectedPath = @"...\newtest.xls"; Object misValue = System.Reflection.Missing.Value; oXL = new Microsoft.Office.Interop.Excel.Application(); var myExcelApp = new Microsoft.Office.Interop.Excel.Application() { Visible = false }; oWB = myExcelApp.Workbooks.Open(Filename: @"tst.xls", ReadOnly: false); oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet; oSheet.Cells[10, 4] = "DATA"; oWB.SaveCopyAs(selectedPath); oWB.Close(); oXL.Quit(); Marshal.ReleaseComObject(oXL); } catch (Exception e) { Console.WriteLine(e.Message); throw new Exception(e.ToSsortingng()); }
Quelqu'un peut m'aider?