Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Excel Table and Pivot Table Formatting sanmos Excel Discussion (Misc queries) 0 February 9th 10 12:07 AM
Conditional formatting in a table is lost on table refresh Steve Huckett Excel Worksheet Functions 0 November 6th 07 11:39 AM
help me write this table retaining table spacing and formatting deano Excel Programming 6 September 5th 05 10:06 PM
retain table formatting when writing excel table to a txt file deanop Excel Programming 8 September 3rd 05 05:38 AM
Pivot Table border formatting and pivot chart formatting [email protected] Excel Discussion (Misc queries) 0 July 22nd 05 02:22 PM


All times are GMT +1. The time now is 04:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"