Giter Site home page Giter Site logo

Read files in Web about excel HOT 6 CLOSED

justkawal avatar justkawal commented on August 14, 2024
Read files in Web

from excel.

Comments (6)

edwinmacalopu avatar edwinmacalopu commented on August 14, 2024 2

you can use filepicker to import excel file https://pub.dev/packages/file_picker

example code:

RaisedButton(onPressed: () async {
          FilePickerResult result = await FilePicker.platform.pickFiles(
           type: FileType.custom,
            allowedExtensions: ['xls', 'xlsx'],
            allowMultiple: false);
            if (result != null) {
              var bytes = result.files.single.bytes;
              var excel = Excel.decodeBytes(bytes);

              for (var table in excel.tables.keys) {
                print(table); //sheet Name
                print(excel.tables[table].maxCols);
                print(excel.tables[table].maxRows);
                for (var row in excel.tables[table].rows) {
                  print("$row");
                }
              }
            }
          }

from excel.

justkawal avatar justkawal commented on August 14, 2024

For reading in web, I really don't know for now how to achieve that.

It will be best for you to open up the issue in flutter's main repo as they might provide help for this.

from excel.

felixwortmann avatar felixwortmann commented on August 14, 2024

Reading files in text mode works with that code. You can print it etc. it just somehow does not really work with binary files.

from excel.

venkimurthy07 avatar venkimurthy07 commented on August 14, 2024

Getting error:
Cannot read property 'Symbol(dartx.forEach)' of null
at excel.XlsxDecoder.new.[_parseMergedCells] (http://localhost:65001/packages/excel/excel.dart.lib.js:1936:20)

Future<File> selectFile() async {
    InputElement uploadInput = FileUploadInputElement();
    uploadInput.click();

    uploadInput.onChange.listen((e) {
      // read file content as dataURL
      final files = uploadInput.files;
      if (files.length == 1) {
        final file = files[0];
        final reader = new FileReader();

        reader.onLoadEnd.listen((e) {
          // var reade = reader.result as String;
         var excel =  Excel.decodeBytes(reader.result,verify: true);
           print("${excel}");
//          var decoder = SpreadsheetDecoder.decodeBytes(reader.result);
//          var table = decoder.tables['Sheet1'];
//          var values = table.rows[0];
//
//          table.rows.forEach((element) {
//            element.forEach((element1) {
//              print("${element1}");
//              if (element1 == "CateogoryID") {
//                print("first ${element1}");
//              }
//            });
//          });

          return reader.result;
        });

        reader.readAsArrayBuffer(file);
      }
    });
  }

from excel.

arlucio avatar arlucio commented on August 14, 2024

I use flutter_dropzone to get the data and than Excel.decodeBytes to decode it, works perfectly on web!

from excel.

justkawal avatar justkawal commented on August 14, 2024

I am closing this issue as @edwinmacalopu solutions seems to work.

from excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.