I have successfully created an Excel file using OLEDB (after first creating a table / sheet). I would like to insert a formula that sums a Cost (Currency) cell but have been unable find any techniques for doing so.
I have tried inserting the formula into the Cost field as follows but receive an invalid data type error, which is understandable:
cmd.Parameters.Add("P0", OleDbType.PropVariant).Value = "=SUM(K2:K5)"
cmd.CommandText = "INSERT INTO [" & ExcelTableName & "] (Cost) VALUES(P0);"
cmd.ExecuteNonQuery()
Is there any way of doing this using OLEDB or will I need to use automation?