none
Styling a Range as Table on Excel RRS feed

  • Question

  • Hi!

    If I have range, how do I apply to it a Table Format like in Home > Styles > Format as Table using .NET?

    I've been trying to format a range all day but I can't seem to find the right properties or methods...

     

    Thanks in advance,

    Óscar

    Friday, April 16, 2010 10:13 PM

Answers

  • Hello,

    As Cindy said in this thread, Questions concerning automation of an Office application are technically off-topic in this forum, which is dedicated to questions concerning the VSTO technology. A list of appropriate newsgroups is provided in the "Please Read First" posting at the top of the forum.

    In general, you could use macro recorder. By recording a macro, you could see VBA code, and convert it to C# one. C# code like this,

                Excel.ListObject listobject=this.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, this.Range["A1", "C9"], missing, Excel.XlYesNoGuess.xlNo, missing);
                //listobject.Name = "Table1";
                //listobject.Range.Select();
                listobject.TableStyle = "TableStyleMedium24";

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bessie Zhao Friday, April 23, 2010 10:34 AM
    Tuesday, April 20, 2010 3:20 AM