Worksheet topic

Features that live on a worksheet rather than in a single cell: data validation, conditional formatting, hyperlinks, filters, frozen and split panes, comments, sparklines, protection, images, and print setup. Each is authored through a Sheet method and, where the format stores it, read back from the opened file.

A dropdown list, and a numeric-range rule:

sheet.setDataValidation(
  CellIndex.indexByString('B2'),
  DataValidation.list(['Low', 'Medium', 'High'], prompt: 'Pick a priority'),
);
sheet.setDataValidation(
  CellIndex.indexByString('B3'),
  DataValidation.wholeNumber(min: 1, max: 100),
  end: CellIndex.indexByString('B10'),
);

Conditional formatting, from a simple threshold to a colour scale or icon set:

final from = CellIndex.indexByString('B2');
final to = CellIndex.indexByString('B20');

sheet.addConditionalFormat(from, to, ConditionalFormat.greaterThan(
  100, style: CellStyle(bold: true, fontColorHex: ExcelColor.red)));

sheet.addConditionalFormat(from, to, ConditionalFormat.colorScale(
  min: ExcelColor.red, mid: ExcelColor.yellow, max: ExcelColor.green));

for (final rule in sheet.conditionalFormats) {
  print('${rule.type} on ${rule.range}'); // rules read from the file
}

Hyperlinks, freeze panes, and a comment:

sheet.setHyperlink(CellIndex.indexByString('A1'),
    Hyperlink.url('https://pub.dev', tooltip: 'Open pub.dev'));

sheet.freezePanes(rows: 1, columns: 1); // keep the header row + first column

sheet.setComment(CellIndex.indexByString('A1'),
    Comment('Reviewed and approved', author: 'QA'));

Also here: FilterColumn criteria for Sheet.setAutoFilter, SparklineGroup / Sparkline in-cell charts, ExcelImage via Sheet.insertImage, SheetProtectionOption for Sheet.protect, SheetVisibility, and PageSetup / PageMargins for print layout.

Classes

Comment Worksheet
A classic cell comment (note), the little pop-up box anchored to a cell.
ConditionalFormat Worksheet
A conditional formatting rule applied to a cell range.
DataValidation Worksheet
An input rule applied to a cell range: a dropdown list, a numeric/length bound, a date/time constraint, or a custom formula.
ExcelImage Worksheet
A picture embedded in a worksheet.
FilterColumn Worksheet
A criterion applied to one column of a sheet's autofilter, the filter that actually hides non-matching rows, beyond just showing the dropdown arrow.
A hyperlink attached to a cell (or cell range).
PageMargins Worksheet
Printed page margins, in inches (the unit used by <pageMargins>).
PageSetup Worksheet
How a worksheet is laid out for printing: orientation, scaling, centering, what to print, and page margins.
Sparkline Worksheet
A single sparkline: a tiny chart of dataRange drawn inside the cell at location.
SparklineGroup Worksheet
A group of Sparklines that share one type and colour scheme, the unit Excel stores sparklines in.

Enums

ConditionalFormatType Worksheet
The kind of a ConditionalFormat rule. Covers the common OOXML cfRule types; anything else reads as other (its raw type is on ConditionalFormat.typeName).
IconSetType Worksheet
The icon set drawn by ConditionalFormat.iconSet. The name encodes the icon count (three / four / five icons).
SheetProtectionOption Worksheet
An action a user may be permitted to perform on a protected sheet.
SheetVisibility Worksheet
Visibility of a worksheet's tab within the workbook.
SparklineType Worksheet
The kind of miniature chart drawn by a SparklineGroup.