Some of you asked me if it was possible to use Excel in Nova scripting. Yes it is with the following prerequisite: Excel must be installed on the computer! Then, here a small piece of code:
' Bypass for this error: old format or invalid type library excel 2007
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
Dim excelApp As Object
Dim wb As Object
Dim ws As Object
' Create Excel application
excelApp = CreateObject(
"Excel.Application")
If Not excelApp
Is Nothing Then ' Excel file openning
wb = excelApp.WorkBooks.Open(filePath,, False)
If Not wb Is Nothing Then
ws = wb.Worksheets(excelWorksheetName)
If Not ws Is Nothing Then
ws.Range(cellCoord).Value2 = valueToStore
wb.Save()
End If
wb.Close()
End If
' Free COM Object from memory
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp)
End If
Since we use COM Interop, it's very important to explicitly release COM Object with Marshal.ReleaseComObject method's call.
I've tested this code with Excel 2007. Enjoy!