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

Adding a picture to excel sheet doesn't work in the slightest and hasn't across last 2 (major) versions at least. #2190

Open
sidetraxaudio opened this issue Nov 30, 2024 · 0 comments
Labels
open Open xlsIO XlsIO component

Comments

@sidetraxaudio
Copy link

Bug description

final image = File(p.join(Directory.current.path, 'map.png')).readAsBytesSync();
sheet.pictures.addStream(15, 1, image)

^Results in late initialization exception on lastColOffset.

final image = File(p.join(Directory.current.path, 'map.png')).readAsBytesSync();
sheet.pictures.addStream(15, 1, image)..lastColOffset = 0..lastRowOffset = 0;
final fileName = _createFilename(taEntry);
final bytes = newExcel.saveAsStream();
final File saveFile = File(p.join(exportDirectory.path, fileName));
saveFile.writeAsBytesSync(bytes);

^Results in a corrupted excel file with seemingly incorrect or malformed drawing1.xml and excel reporting:
"We found a problem with some content in [file] Do you want us to recover?"
-> Click Yes and reports:
"Repaired Records: Drawing from /xl/drawings/drawing1.xml part (Drawing shape)"
Result:
Image is located in media folder fine but is not present within the sheet and drawing xml seems to be malformed or incorrect.

Steps to reproduce

As above

Code sample

Code sample
AS ABOVE

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]
Screenshot 2024-11-30 215733

Stack Traces

Stack Traces
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: LateInitializationError: Field 'lastColOffset' has not been initialized.
#0      Picture.lastColOffset (package:syncfusion_flutter_xlsio/src/xlsio/images/picture.dart)
#1      SerializeWorkbook._saveDrawings.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:1851:33)
serialize_workbook.dart:1851
#2      XmlBuilder._insert (package:xml/src/xml/builder.dart:326:12)
builder.dart:326
#3      XmlBuilder.element (package:xml/src/xml/builder.dart:178:9)
builder.dart:178
#4      SerializeWorkbook._saveDrawings.<anonymous closure>.<anonymous closure> (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:1848:21)
serialize_workbook.dart:1848
#5      XmlBuilder._insert (package:xml/src/xml/builder.dart:326:12)
builder.dart:326
#6      XmlBuilder.element (package:xml/src/xml/builder.dart:178:9)
builder.dart:178
#7      SerializeWorkbook._saveDrawings.<anonymous closure> (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:1839:19)
serialize_workbook.dart:1839
#8      XmlBuilder._insert (package:xml/src/xml/builder.dart:326:12)
builder.dart:326
#9      XmlBuilder.element (package:xml/src/xml/builder.dart:178:9)
builder.dart:178
#10     SerializeWorkbook._saveDrawings (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:1809:13)
serialize_workbook.dart:1809
#11     SerializeWorkbook._saveWorksheet.<anonymous closure> (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:714:9)
serialize_workbook.dart:714
#12     XmlBuilder._insert (package:xml/src/xml/builder.dart:326:12)
builder.dart:326
#13     XmlBuilder.element (package:xml/src/xml/builder.dart:178:9)
builder.dart:178
#14     SerializeWorkbook._saveWorksheet (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:453:13)
serialize_workbook.dart:453
#15     SerializeWorkbook._saveWorksheets (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:390:7)
serialize_workbook.dart:390
#16     SerializeWorkbook.saveInternal (package:syncfusion_flutter_xlsio/src/xlsio/general/serialize_workbook.dart:110:5)
serialize_workbook.dart:110
#17     Workbook.saveAsStream (package:syncfusion_flutter_xlsio/src/xlsio/general/workbook.dart:6221:16)
</details>


### On which target platforms have you observed this bug?

Windows

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
flutter doctor -v
[√] Flutter (Channel beta, 3.27.0-0.2.pre, on Microsoft Windows [Version 10.0.26100.2454], locale en-AU)
    • Flutter version 3.27.0-0.2.pre on channel beta at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.gitFramework revision fc011960a2 (2 weeks ago), 2024-11-14 12:19:18 -0800Engine revision 397deba30f
    • Dart version 3.6.0 (build 3.6.0-334.4.beta)
    • DevTools version 2.40.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at *Platform android-34, build-tools 34.0.0Java binary at: C:\Program Files\Android\Android Studio2\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.10.8)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\ProfessionalVisual Studio Professional 2022 version 17.10.35326.205Windows 10 SDK version 10.0.22621.0

[!] Android Studio (version 2023.3)
    • Android Studio at C:\Program Files\Android\Android StudioFlutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutterDart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[!] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio1Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutterDart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Program Files\Android\Android Studio2Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutterDart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dartJava version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[√] VS Code (version 1.95.3)
    • VS Code at *Flutter extension version 3.101.20241031

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2454]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 131.0.6778.86Edge (web)        • edge    • web-javascript • Microsoft Edge 131.0.2903.70

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
@VijayakumarMariappan VijayakumarMariappan added xlsIO XlsIO component open Open labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open Open xlsIO XlsIO component
Projects
None yet
Development

No branches or pull requests

2 participants