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

Cannot delete sheets #346

Open
horvathAdam285 opened this issue Apr 18, 2024 · 6 comments
Open

Cannot delete sheets #346

horvathAdam285 opened this issue Apr 18, 2024 · 6 comments

Comments

@horvathAdam285
Copy link

Calling excel.delete(sheetName) can throw this error:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Cannot remove from an unmodifiable list
E/flutter (20043): #0 UnmodifiableListMixin.removeWhere (dart:_internal/list.dart:139:5)

The problem seems to be trying to delete from _archive.files, which is an UnmodifiableListView

@bahadirarslan
Copy link

I am facing this issue while using the rename function.
It tries to delete the old named sheet

@Another-Chris
Copy link

Another-Chris commented May 30, 2024

Apparently they are trying to call removeWhere() on _archive.files, which is an UnmodifiableListView
I am not sure why they make _archive.files unmodifiable but also call removeWhere on it. Dart documentation clearly says it is not supported. removeWhere method

  • Dart: 2.19.6
  • excel: 3.0.0

@luizgpa
Copy link
Contributor

luizgpa commented Jul 11, 2024

Could anyone please confirm if that issue continues on 4.0.x?

@mikeloomisgg
Copy link

mikeloomisgg commented Jul 25, 2024

I'm able to rename sheets that I create.
This is on windows 11, lib version v4.0.2

  Excel excel = Excel.createExcel();
  var sheet = excel['OLD_NAME'];
  excel.rename("OLD_NAME", "NEW_NAME");

I cannot delete "Sheet1", however. It gives me this error:

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      main (*)

@mikeloomisgg
Copy link

If I remove the block of code that is throwing an exception then I can delete Sheet1:

      // _archive.files.removeWhere((file) {
      //   return file.name.toLowerCase() == _xmlSheetId[sheet]?.toLowerCase();
      // });

What is the purpose of deleting from the unmodifiable list?

@mikeloomisgg
Copy link

I upgraded to v4.0.3 and this was fixed, even for Sheet1.

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

No branches or pull requests

5 participants