Custom activity FOR INSERTING TABLE NAME

Hi Every one,

I tried to create custom activity for Inserting table name in an Excel sheet.
I am attaching the code here. If anyone have done it before please respond and your ideas are appreciated. NOTE (code was little bit scrambled due to confidentiality but it resembles the idea )


public class SetTableName: CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
string FullFilePath = this.FullFilePath.Get(context);
string TableName = this.TableName.Get(context);
string SheetName = this.SheetName.Get(context);
System.Data.DataTable dataTable = this.DataTable.Get(context);
int i = dataTable.Columns.Count;
int j = dataTable.Rows.Count;
String str = { “A”, “B”,“C”,“D”,“E”,“F”,“G”,“H”,“I”,“J”,“K”,“L”,“M”,“N”,“O”,“P”,“Q”,“R”,“S”,“T”,“U”,“V”,“W”,“X”,“Y”,“Z”};

        Microsoft.Office.Interop.Excel.Application ExcelObj = new Microsoft.Office.Interop.Excel.Application();
        ExcelObj.DisplayAlerts = false;
        ExcelObj.Visible = false;
        Microsoft.Office.Interop.Excel.Workbook eBook = ExcelObj.Workbooks.Open(FullFilePath);
        Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)eBook.Worksheets[SheetName];
        Microsoft.Office.Interop.Excel.Range tRange = ws.get_Range("A1",str[i]+j.ToString() );
        ws.ListObjects.Add(Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange, tRange, Type.Missing, Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes, Type.Missing).Name = TableName;
    }
    [Category("Input"), RequiredArgument]
    public InArgument<string> TableName { get; set; }

    [Category("Input"), RequiredArgument]
    public InArgument<string> SheetName { get; set; }

    [Category("Input"), RequiredArgument]
    public InArgument<string>  FullFilePath { get; set; }

    [Category("Input"), RequiredArgument]
    public InArgument<System.Data.DataTable> DataTable { get; set; }

    [Category("Options")]
    public bool AddHeaders { get; set; }
}

}
_______________________________________________________ END