如何在颤动的列表中获取所需的数据?
How can I get the desired data in the list in flutter?
我有一个从 excel 中读取的列表。在这里,我想获取列表中索引号为 1 和 3 的数据。例如,我只想获取“广告”和“名称”值。
示例:[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])
行类型是 Iterable
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);
之前需要解析为List:
final row = excel.tables[excel.tables.keys.first]!.rows
.map((e) => e.map((e) => e!.value).toList()).toList();
然后:
row.forEach((e){
int index = row.indexOf(e);
row[index].removeAt(0);
row[index].removeAt(1);
});
输出:
[Kelime1, Kelme2], [ad, name], [öğrenci, student], [teach, öğren]
我有一个从 excel 中读取的列表。在这里,我想获取列表中索引号为 1 和 3 的数据。例如,我只想获取“广告”和“名称”值。
示例:[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])
行类型是 Iterable
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);
之前需要解析为List:
final row = excel.tables[excel.tables.keys.first]!.rows
.map((e) => e.map((e) => e!.value).toList()).toList();
然后:
row.forEach((e){
int index = row.indexOf(e);
row[index].removeAt(0);
row[index].removeAt(1);
});
输出:
[Kelime1, Kelme2], [ad, name], [öğrenci, student], [teach, öğren]