Hi All,
I am attempting to import excel files using FilePicker and Excel Pub.Deb dependency.
I have managed to get the filepicker to work and add the excel package to convert to Json.
Unfortunately, when testing it, I return null value when converted.
Basically my goal is to use flutterflow to import data from an excel file to then import it to my supabase table.
If the method I am currently trying to setup is not efficient and have a better solution I would love to know.
I have spent hours and hours with no luck. open to all suggestions.
Thanks in advance.
import 'package:excel/excel.dart';
import 'package:file_picker/file_picker.dart';
Future<dynamic> importExcel() async {
// import excel and return as json extract as json path
// Importing the excel file
// Reading the excel file
var file;
final bytes = await file.readAsBytes();
final excel = Excel.decodeBytes(bytes);
// Extracting the data from the excel file
final sheet = excel['Sheet1'];
final rows = sheet.rows;
final headers = rows.first;
final data = rows.skip(1).map((row) {
final rowData = Map.fromIterables(headers, row);
return rowData;
}).toList();
// Converting the data to JSON format
final jsonData = json.encode(data);
// Returning the JSON data
return jsonData;
}