C# Excel change existing table style

  • Thread starter Thread starter Domleg
  • Start date Start date
D

Domleg

Guest
I have an existing table1 in an Excel spreadsheet and I want to simply change if from blue to grey. "TableLight1" but can't figure it out.

var exApp = new Microsoft.Office.Interop.Excel.Application();
var exWbk = exApp.Workbooks.Open("C:\\Indications.xlsx");
var exWks = (Microsoft.Office.Interop.Excel.Worksheet)exWbk.Sheets["Sheet1"];
var exRng1 = exWks.Range["B1"].EntireColumn;
var exRng3 = exWks.Range["A1", "E1"].EntireColumn;

try
{
exRng1.NumberFormat = "YYYY-MM-DD HH:MM:SS.000";
exRng3.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
exRng3.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
exRng3.AutoFit();
//change the style of table1 here from blue to grey "tablelight1"
exWbk.Save();
exWbk.Close();
exApp.Workbooks.Close();
}

From this

1420212.jpg

To this

1420213.jpg

Thanks

Continue reading...
 
Back
Top