I am currently developing an excel add-in in C# with several methods (table valued functions) that will be available to excel users and programmers (VBA).
How can I write a method which adds a new ListObject (excel table) to the given excel worksheet, and bind the given DataTable as data source? Something like the following:
using Excel = Microsoft.Office.Interop.Excel;
...
[ClassInterface(ClassInterfaceType.AutoDual)]
public class TableFunctions {
...
public Excel.ListObject CreateListObject(Excel.Worksheet ws, string TableName, DataTable dt, string CellStr = "A1")
{
...
}
This approach, sending the Worksheet object as parameter apparently doesn't work. Or could it?
After some research I found an answer to my question, how to add a ListObject (excel table) to a worksheet programmatically in C#:
See my article about this and other related code for excel and .net integration.