Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Table formatting in C#
I formatted a range and recorded a macro to see how it was done and part of
the VBA code that was generated was: ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$2:$E$34919"), , xlYes).Name = "Table1" So I tried to translate this to C# in an Excel Addin VSTO project and I came up with ws.ListObjects.Add(Excel.XlListObjectSourceType.xl SrcRange, ws.get_Range(string.Format("${0}$2:${1}${2}", (char)('A' + (baseColumn + 0)), (char)('A' + (baseColumn + 4)), orderList.Count + 2), Type.Missing), Type.Missing, Excel.XlYesNoGuess.xlYes, Type.Missing).Name = tableName; The complicated string format has been verified and it generates a string like $A$2:$E$34919. When I run this code the first table created works fine. However the second table throws an exception indicating that the range overlaps with another table. I know the string doesn't overlap. I suspect there is something that I am doing wrong in translating Range("$A$2:$E$34919") to something equivalent in C#. One other thing that adds credence to this theory is that I have other data on this sheet and the columns seem to be merged into this table name. It is almost like the range is not A-E but all columns from A to the end. Any suggestions? Thank you. Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2007 Excel Table and Pivot Table Formatting | Excel Discussion (Misc queries) | |||
Conditional formatting in a table is lost on table refresh | Excel Worksheet Functions | |||
help me write this table retaining table spacing and formatting | Excel Programming | |||
retain table formatting when writing excel table to a txt file | Excel Programming | |||
Pivot Table border formatting and pivot chart formatting | Excel Discussion (Misc queries) |