Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insertRow(sheet, 20) : RangeError: Invalid value: Not in inclusive range 0..12: 20 #33

Open
Patrick386 opened this issue Dec 24, 2021 · 3 comments

Comments

@Patrick386
Copy link

I put the template Excel file in the asset folder and tested it.

sample codel:

  var _excel = SpreadsheetDecoder.decodeBytes(bytes, update: true);

  String sheet = _excel.tables.keys.first; 
  print('Sheet:>>>>${sheet}');
  _excel
    ..updateCell(sheet, 0, 1, "aaaaaaaaaa")
    ..updateCell(sheet, 1, 1, 'bbbbbbbbbb')
    ..updateCell(sheet, 2, 1, 'cccccccccc')
    ..updateCell(sheet, 1, 2, 8880.3)
    ..insertRow(sheet, 1)
    ..insertRow(sheet, 20)
    ..updateCell(sheet, 0, 09, 'A14=========}')
    ..updateCell(sheet, 0, 15, 'A13---------}')
     ..insertColumn(sheet, 0);


  var b = _excel.encode();

Error:

Error: RangeError: Invalid value: Not in inclusive range 0..12: 20
    at Object.throw_ [as throw] (http://localhost:56557/dart_sdk.js:5063:11)
    at spreadsheet_decoder.XlsxDecoder.new.insertRow (http://localhost:56557/packages/spreadsheet_decoder/spreadsheet_decoder.dart.lib.js:227:19)
    at spreadsheet_decoder.XlsxDecoder.new.insertRow (http://localhost:56557/packages/spreadsheet_decoder/spreadsheet_decoder.dart.lib.js:855:13)
    at http://localhost:56557/packages/pronto/pages/base_product_page/excel_upload/product_excel_repository.dart.lib.js:198:12
    at testexcel (http://localhost:56557/packages/pronto/pages/base_product_page/excel_upload/product_excel_repository.dart.lib.js:203:9)
    at testexcel.next (<anonymous>)
    at http://localhost:56557/dart_sdk.js:40192:33
    at _RootZone.runUnary (http://localhost:56557/dart_sdk.js:40062:59)
    at _FutureListener.thenAwait.handleValue (http://localhost:56557/dart_sdk.js:34983:29)
    at handleValueCallback (http://localhost:56557/dart_sdk.js:35551:49)
    at Function._propagateToListeners (http://localhost:56557/dart_sdk.js:35589:17)
    at _Future.new.[_completeWithValue] (http://localhost:56557/dart_sdk.js:35437:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:56557/dart_sdk.js:35458:35)
    at Object._microtaskLoop (http://localhost:56557/dart_sdk.js:40330:13)
    at _startMicrotaskLoop (http://localhost:56557/dart_sdk.js:40336:13)
    at http://localhost:56557/dart_sdk.js:35811:9
ProductCount:168
@sestegra
Copy link
Owner

Your file seems to contain only 12 rows. So, insertRow(sheet, 20) is out of range as the error message explains.

@Patrick386
Copy link
Author

Your file seems to contain only 12 rows. So, insertRow(sheet, 20) is out of range as the error message explains.

If so, can't we automatically increase the column or row that is insufficient according to the data?

@sestegra sestegra added the usage label Dec 24, 2021
@sestegra
Copy link
Owner

sestegra commented Dec 24, 2021

Unfortunately, this feature isn't implemented yet.
It could be interesting to have such a feature.

In the meantime, you have to call insertRow many times to reach the desired number of rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants