List visible = new List();
// Add visible column index
for (int i = 2; i < 9; i++)
visible.Add(i);
int col = sheet.UsedRange.LastColumn;
//Hide other column
for (int i = 1; i < col + 1; i++)
{
if(!visible.Contains(i))
sheet.ShowColumn(i, false);
}
ShowColumn method. If you do not want the data in the sheet and like to delete them permanently, you may make use of sheet.DeleteColumn() method.