Comments (6)
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.
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.
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.
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.
I use flutter_dropzone to get the data and than Excel.decodeBytes to decode it, works perfectly on web!
from excel.
I am closing this issue as @edwinmacalopu solutions seems to work.
from excel.
Related Issues (20)
- Help: Determining the type of a cell HOT 1
- How to use custom Chinese fonts
- Excel - Roadmap Tasks HOT 2
- Default constructors for simplicity
- rename sheet breaks with archive 3.4.10 HOT 1
- Excel.decodeBytes -> Bad State too many elements
- The argument type 'String' can't be assigned to the parameter type 'ExcelColor' HOT 4
- How to parse Excel cell merging information?
- Bug reading SpannedItems as empty HOT 2
- README.md demo doesn't compile since 4.0.3 update
- Couldn't decode ".xls" file HOT 1
- Cannot delete sheets HOT 6
- DateTimeCellValue not working on Windows
- Very inefficient RAM usage HOT 2
- Can't read the XLSX file from http request - Damaged Excel file: Corrupted Excel file HOT 1
- How to save .csv
- Bad state: No element while parsing
- Can I select the sheet I want to open in a file that has multiple sheets?
- update package HOT 5
- Cells with a time below `02:25:00` are recognized as `DateTimeCellValue` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from excel.