justkawal / excel

Excel Library for Flutter and Dart - https://pub.dev/packages/excel
MIT License
416 stars 229 forks source link

excel.delete("Sheet1") execute error #309

Closed yeleibo closed 8 months ago

yeleibo commented 9 months ago

error info :Cannot remove from an unmodifiable list image

Javicg10 commented 9 months ago

I have the same error.

`[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Cannot remove from an unmodifiable list

0 UnmodifiableListMixin.removeWhere (dart:_internal/list.dart:139:5)

1 Excel.delete (package:excel/src/excel.dart:279:22)

2 Excel.rename (package:excel/src/excel.dart:213:7)

... `

I'm seeking advice on whether there's a workaround I can implement, or if this is an issue that needs resolution within the package itself. This functionality is crucial to my application, and any guidance or assistance you can provide would be greatly appreciated.

Thank you for your efforts in maintaining this package!

Javicg10 commented 9 months ago

The only solution I came with at the moment is to not rename or delete any sheet, which is a pity because I used this to remove the default Sheet1 and now its there.

MichiHill1991 commented 9 months ago

This is really bad, I need to be able to rename the default sheet or delete it.

17martix commented 9 months ago

I'm having the same issue, can't delete the sheet created by default

eapCJ commented 9 months ago

Hey there! I stumbled upon the same issue. As a workaround you can wrap the function in a try-catch block, it's temporary but might help you too!

ksh-b commented 8 months ago

excel.setDefaultSheet can be used as workaround for avoiding Sheet1

maboumra commented 8 months ago

Great workarounds by @ksh-b and @eapCJ . Thank you!

ericsu0630 commented 8 months ago

This is strange, it wasn't an issue before. I've been using version 2.1.0 and haven't upgraded dart or flutter either, but now I'm suddenly getting this error.

timobaehr commented 8 months ago

Downgrade is not helping me out. I' getting this error as well with version 3.0.0 and even 2.1.0 as well.

timobaehr commented 8 months ago

The error is coming from used package archive. One fix is to use latest main branch and the newly added deleteFile function.

Link to pull request: https://github.com/justkawal/excel/pull/314

mtcahill57 commented 8 months ago

Until this is resolved, I was able to fix this by setting the version of archive in my own project's pubspec to 3.4.9. Hope this helps someone

maboumra commented 8 months ago

@mtcahill57 it didn't work for me

mtcahill57 commented 8 months ago

@maboumra Hmm, I am able to use it properly. My project's pubspec looks like this:

  archive: 3.4.9
  excel: any

then I ran flutter clean; flutter pub get

Kontrano commented 8 months ago

I had the same issue, However, I upgraded to version 4.0.2 from version 2... something I'm not sure about anymore, however, I never had Archive installed, and once I added it manually it fixed the issue. Is there a chance it's a new dependency that's not auto-installed when upgrading?