While trying to save the changes I made in an excel file with flutter, this error raised, and the changes are not being saved.

Here is the code

_updateExcel() async{
    ByteData data = await rootBundle.load('assets/mood.xlsx');
    var bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
    var excel = Excel.decodeBytes(bytes);
    Sheet sheetObjectAlger = excel['Alger'];
    Sheet sheetObjectOran = excel['Oran'];
    Sheet sheetObjectConst = excel['Alger'];
    Sheet sheetObjectAll = excel['All'];
    var cell = sheetObjectAlger.cell(CellIndex.indexByString('B2'));
    cell.value = cell.value +1;
    print(cell.value);    //to see if the value is picked up 
    excel.updateCell('Alger', CellIndex.indexByString('B2'),cell.value);
    var excelOutput = excel.encode();
    File('/assets/mood.xlsx').writeAsBytesSync(excelOutput!);
  }

I tried to save the changes of the value of a cell in Excel. I am using this excel package text

This is the antier error :

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: FileSystemException: Cannot open file, path = '/assets/mood.xlsx' (OS Error: No such file or directory, errno = 2)
E/flutter ( 6555): #0      _File.throwIfError (dart:io/file_impl.dart:635:7)
E/flutter ( 6555): #1      _File.openSync (dart:io/file_impl.dart:479:5)
E/flutter ( 6555): #2      _File.writeAsBytesSync (dart:io/file_impl.dart:604:31)
E/flutter ( 6555): #3      _My_MoodState._updateExcel (package:mood_meter/pages/my_Mood.dart:57:31)
E/flutter ( 6555): <asynchronous suspension>
0

There are 0 best solutions below