stream method
Extracts text content from a file and returns it as a stream of strings.
Implementing classes must define how to parse their specific file format. @param file The file to extract text from
Implementation
@override
Stream<String> stream(File file) async* {
Excel x = Excel.decodeBytes(await file.readAsBytes());
for (String table in x.tables.keys) {
yield table;
yield "\n";
for (var row in x.tables[table]!.rows) {
StringBuffer buffer = StringBuffer();
for (Data? cell in row) {
buffer.write(",");
CellValue? value = cell?.value;
buffer.write(switch (value) {
TextCellValue() => value.value,
FormulaCellValue() => value.formula,
IntCellValue() => value.value.toString(),
DoubleCellValue() => value.value.toString(),
BoolCellValue() => value.value.toString(),
DateCellValue() => value.asDateTimeUtc().toIso8601String(),
TimeCellValue() =>
'${value.hour}h:${value.minute}m:${value.second}s',
DateTimeCellValue() => value.asDateTimeUtc().toIso8601String(),
null => "",
});
}
buffer.write("\n");
yield buffer.toString().substring(1);
}
yield "\n\n";
}
}