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 |
All times are GMT +1. The time now is 12:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com