I have a list that I read from excel. Here I want to get data with index number 1 and 3 of the lists. For example, I just want to get "ad" and "name" values.
example: [tr, ad, en, name]= [ad, name]
debug=I/flutter (25765): ([Dil1, Kelime1, Dil2, Kelme2], [tr, ad, en, name], [tr, öğrenci, en, student], [en, teach, tr, öğren])
row type is Iterable<List>
Future readExcel() async {
var excelfileDetails = new Word();
var file = excelPath;
var bytes = File(file).readAsBytesSync();
var excel = Excel.decodeBytes(bytes);
print('${excel}');
print(excel.tables.keys); //sheet Name
print(excel.tables[excel.tables.keys.first]!.maxCols);
print(excel.tables[excel.tables.keys.first]!.maxRows);
final row = excel.tables[excel.tables.keys.first]!.rows
.map((e) => e.map((e) => e!.value).toList());
print(row);
CodePudding user response:
You need to parse to List before:
final row = excel.tables[excel.tables.keys.first]!.rows
.map((e) => e.map((e) => e!.value).toList()).toList();
And then:
row.forEach((e){
int index = row.indexOf(e);
row[index].removeAt(0);
row[index].removeAt(1);
});
Output:
[Kelime1, Kelme2], [ad, name], [öğrenci, student], [teach, öğren]