I am building an excel 2007 add-in on visual studio professional 2008 with SP1. I want my add-in to add and remove data to a certain excel table.
Excel.Range rg = ws.get_Range("myExcelTable", System.Type.Missing); rg.Value2 = string.Empty; rg.Value2 = myArray;
If the table has less rows than the array, the table doesnt reisze and so the last rows of the array are not copied into excel.
If the table has more rows than the array, the rows are repeated in the table.
So, I need to resize the table to fit the array and, after that, copy the array to the table. No missing data and no surplus data.
How can I do this?
You could create a ListObject for the table, and then resize the ListObject to include the correct number of rows. Here is a topic about how to resize a List Object - http://msdn.microsoft.com/en-us/library/afxz16c3.aspx.