如何使用excel 1.1.5包导出excel文件



我目前正在使用这个包Excel1.1.5…它目前有一个名为save的方法,但它只返回一个List integers。。。我不知道从这里到哪里去。。

List<int>? potato = excel.save(fileName: 'namePotato');

希望你们能帮忙!谢谢

找到答案,你可以使用dart:io,我也使用了Permissions_handler

Future exportReport() async {
var excel = Excel.createExcel();
DateTime _now = DateTime.now();
String _name = DateFormat('yyyy-MM-dd').format(_now);
String _fileName = 'surname-' + _name;
List<int>? potato = excel.save(fileName: _name);
PermissionStatus status = await Permission.storage.request();
if (status == PermissionStatus.granted) {
await File('/storage/emulated/0/Download/$_fileName.xlsx').writeAsBytes(potato!, flush: true).then((value) {
log('saved');
});
} else if (status == PermissionStatus.denied) {
log('Denied. Show a dialog with a reason and again ask for the permission.');
} else if (status == PermissionStatus.permanentlyDenied) {
log('Take the user to the settings page.');
}
return null;
}

最新更新