有很多 CSV 示例可以列出 Flutter 应用程序,我面临着 Flutter Web 和文件转换的问题。
某些 CSV 无法正常工作,我猜这是格式问题 这是用户上传文件时的转换功能
Future _openFileExplorer() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowMultiple: false,
withData: true,
type: FileType.custom,
allowedExtensions: ['csv']);
if (result != null) {
//decode bytes back to utf8
final bytes = utf8.decode((result.files.first.bytes)!.toList());
setState(() {
//from the csv plugin
employeeData = CsvToListConverter().convert(bytes);
});
}
}
工作 CSV 文件转换
不工作csv文件转换,结构不一样,这是一个大块
如果你想尝试,我做了一个完整的项目回购,在自述文件中添加了一些照片,