Ik wil een excel werkblad vullen vanuit C#
Ik krijg de data erin, ook makkelijke formules (zoals: A1+(B1*1000)+(C1*60000)+(D1*60*60000) om tijd naar millisec on te rekenen). Tevens kan ik een =SOM(A2:A5 erin krijgen.
Maar zodra ik de formule "AFRONDEN" wil gebruiken krijg ik een exception.
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Dynamic.dll
Additional information: Exception from HRESULT: 0x800A03EC
The error code 0x800A03EC (or -2146827284) means NAME_NOT_FOUND; in other words, you've asked for something, and Excel can't find it.
[Bron: stackoverflow]
worksheet.Cells[3, 3].Formula = "=SOM(A2:A5)"; // werkt wel
worksheet.Cells[3, 3].Formula = "=AFRONDEN(SOM(A2:A5);0)"; // werkt dus niet
Heeft iemand enig idee hoe ik het toch voor elkaar krijg?
Ik krijg de data erin, ook makkelijke formules (zoals: A1+(B1*1000)+(C1*60000)+(D1*60*60000) om tijd naar millisec on te rekenen). Tevens kan ik een =SOM(A2:A5 erin krijgen.
Maar zodra ik de formule "AFRONDEN" wil gebruiken krijg ik een exception.
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Dynamic.dll
Additional information: Exception from HRESULT: 0x800A03EC
The error code 0x800A03EC (or -2146827284) means NAME_NOT_FOUND; in other words, you've asked for something, and Excel can't find it.
[Bron: stackoverflow]
code:
1
2
3
4
5
6
7
8
9
| Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); if (xlApp == null) { MessageBox.Show("Excel is not properly installed!!"); return; } Microsoft.Office.Interop.Excel.Workbook xlWorkBook; Microsoft.Office.Interop.Excel.Worksheet worksheet; object misValue = System.Reflection.Missing.Value; xlWorkBook = xlApp.Workbooks.Add(misValue); worksheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); |
worksheet.Cells[3, 3].Formula = "=SOM(A2:A5)"; // werkt wel
worksheet.Cells[3, 3].Formula = "=AFRONDEN(SOM(A2:A5);0)"; // werkt dus niet
Heeft iemand enig idee hoe ik het toch voor elkaar krijg?
[ Voor 16% gewijzigd door liquid_ice op 12-03-2016 20:33 ]
Klus page: http://klusthuis.blogspot.com