0

I want to see information such as:

  • [A1:A20]
  • Data in column A

after receiving the Excel information through the 'file_picker 5.2.5' and 'excel 2.0.1' package in flutter web.

I used this code And I could print "sheetName" in last:

void _giveExcel() async {
    FilePickerResult? excelFile = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['xlsx'],
      allowMultiple: false,
    );
    if (excelFile != null) {
      var bytes = excelFile .files.single.bytes;
      var excel = Excel.decodeBytes(bytes as List<int>);
      for (var table in excel.tables.keys) {
        print(excel.tables[table]?.sheetName); 
      }
    }
  }

Thank you for telling me how to find this information.

MhmdRza
  • 1
  • 1

1 Answers1

0

Reading excel is like reading 2D array,

You can use CellIndex like

final cellIndex  =  CellIndex.indexByColumnRow(rowIndex: 1, columnIndex: 20); //1 and 20 based on your data.play with it

final String data =  excel[excel.tables.keys.first]
        .rows[cellIndex.rowIndex][cellIndex.columnIndex]
        ?.value
        .toString()
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
  • it didn't work. "Error: RangeError (index): Index out of range: index should be less than 2: 20" – MhmdRza Mar 09 '23 at 17:39
  • You need to provide your data-column index instead of `columnIndex: 20`. based on the error you just have range 2. means 0 and 1. try to play with index – Md. Yeasin Sheikh Mar 09 '23 at 17:42