showColumns method

void showColumns(
  1. bool? isVisible
)

Shows or hides columns in the given range. TRUE by default.

Workbook workbook = new Workbook();
Worksheet sheet = workbook.worksheets[0];
Range range = sheet.getRangeByName('A1');
range.showColumns(false);
List<int> bytes = workbook.saveAsStream();
File('Number.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

void showColumns(bool? isVisible) {
  if (isSingleRange) {
    Column? column1 = _worksheet.columns[column];
    if (column1 == null) {
      column1 = Column(_worksheet);
      column1.index = column;
      worksheet.columns[column] = column1;
    }
    column1.isHidden = !isVisible!;
  } else {
    for (int columnIndex = column; columnIndex <= lastColumn; columnIndex++) {
      Column? column1 = _worksheet.columns[columnIndex];
      if (column1 == null) {
        column1 = Column(_worksheet);
        column1.index = column;
        worksheet.columns[columnIndex] = column1;
      }
      column1.isHidden = !isVisible!;
    }
  }
}