フラッタインポートCSVファイルとリストに変換
6521 ワード
Flutter CSV File ListView内のデータをインポートおよび表示します.
我々がカバーするこのポスト CSVファイルをインポート CSVファイルからデータを読み取り、リストに変換 ビューにCSVデータを表示する
ファイルをインポートするには、FileCounterプラグインを使用します.このファイルピッカーには、speccificなファイルタイプを選ぶようなプロパティがあります.ここではcsvファイルをインポートしていますので、ファイルタイプとして拡張子を追加する必要があります.カスタム
我々がカバーするこのポスト
dependencies:
flutter:
sdk: flutter
csv: ^5.0.0
path_provider: ^2.0.2
permission_handler: ^7.1.0
file_picker: ^3.0.4
CSVファイルをインポートファイルをインポートするには、FileCounterプラグインを使用します.このファイルピッカーには、speccificなファイルタイプを選ぶようなプロパティがあります.ここではcsvファイルをインポートしていますので、ファイルタイプとして拡張子を追加する必要があります.カスタム
void _openFileExplorer() async {
try {
_paths = (await FilePicker.platform.pickFiles(
type: _pickingType,
allowMultiple: false,
allowedExtensions: (_extension?.isNotEmpty ?? false)
? _extension?.replaceAll(' ', '').split(',')
: null,
))
?.files;
} on PlatformException catch (e) {
print("Unsupported operation" + e.toString());
} catch (ex) {
print(ex);
}
if (!mounted) return;
setState(() {
openFile(_paths![0].path);
print(_paths);
print("File path ${_paths![0]}");
print(_paths!.first.extension);
});
}
CSVファイルからデータを読み込むopenFile(filepath) async
{
File f = new File(filepath);
print("CSV to List");
final input = f.openRead();
final fields = await input.transform(utf8.decoder).transform(new CsvToListConverter()).toList();
print(fields);
setState(() {
employeeData=fields;
});
}
ダウンロード完了コードFlutter CSV File 輸入Reference
この問題について(フラッタインポートCSVファイルとリストに変換), 我々は、より多くの情報をここで見つけました https://dev.to/rrtutors/flutter-import-csv-file-and-convert-to-list-377fテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol