You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varworkbook=newXLWorkbook();varws=workbook.Worksheets.Add("Columns of a Range");// All columns in a rangews.Range("A1:B2").Columns().Style.Fill.BackgroundColor=XLColor.DimGray;varbigRange=ws.Range("A4:V6");// Contiguous columns by numberbigRange.Columns(1,2).Style.Fill.BackgroundColor=XLColor.Red;// Contiguous columns by letterbigRange.Columns("D","E").Style.Fill.BackgroundColor=XLColor.Blue;// Contiguous columns by letterbigRange.Columns("G:H").Style.Fill.BackgroundColor=XLColor.DeepPink;// Spread columns by numberbigRange.Columns("10:11,13:14").Style.Fill.BackgroundColor=XLColor.Orange;// Spread columns by letterbigRange.Columns("P:Q,S:T").Style.Fill.BackgroundColor=XLColor.Turquoise;// Use a single number/letterbigRange.Columns("V").Style.Fill.BackgroundColor=XLColor.Cyan;// Only the used columns in a worksheetws.Columns("A:V").Width=3;
Selecting Columns of a Worksheet
varws2=workbook.Worksheets.Add("Columns of a worksheet");// Contiguous columns by numberws2.Columns(1,2).Style.Fill.BackgroundColor=XLColor.Red;// Contiguous columns by letterws2.Columns("D","E").Style.Fill.BackgroundColor=XLColor.Blue;// Contiguous columns by letterws2.Columns("G:H").Style.Fill.BackgroundColor=XLColor.DeepPink;// Spread columns by numberws2.Columns("10:11,13:14").Style.Fill.BackgroundColor=XLColor.Orange;// Spread columns by letterws2.Columns("P:Q,S:T").Style.Fill.BackgroundColor=XLColor.Turquoise;// Use a single number/letterws2.Columns("V").Style.Fill.BackgroundColor=XLColor.Cyan;ws2.Columns("A:V").Width=3;workbook.SaveAs("SelectingColumns.xlsx");