Skip to content

Multiple non-overlapping Range.merge() calls produce a corrupted XLSX workbook #2551

Description

@VintageHighTech

Bug description

Description
I'm seeing what appears to be a bug in syncfusion_flutter_xlsio when more than one non-overlapping range is merged.

Expected behaviour
Both merged ranges should be written independently to the workbook.
Merged ranges:

Q61:AD61
R65:W65

Excel should open the workbook without reporting any problems.

Actual behaviour

When two merge() calls are made:
Excel reports that the workbook is corrupted and offers to repair it.
After repair, the two separate merged regions have been combined into a single merged area.
Content from the second merged region is lost.
If either merge() call is removed, the workbook opens correctly.

Environment

  • syncfusion_flutter_xlsio: 34.1.32
  • Flutter: 3.44.1
  • Dart: 3.12.1
  • Operating System: Windows 11
  • Microsoft Excel: Microsoft 365 Version 2606 (Build 20131.20154)

Steps to reproduce

  1. Create a new Workbook.
  2. Get the first worksheet.
  3. Merge the range Q61:AD61.
  4. Merge the non-overlapping range R65:W65.
  5. Save the workbook to an .xlsx file.
  6. Open the file in Microsoft Excel.

Code sample

Code sample
import 'package:syncfusion_flutter_xlsio/xlsio.dart';

void main() {
  final Workbook workbook = Workbook();
  final Worksheet sheet = workbook.worksheets[0];

  sheet.getRangeByName('Q61:AD61').merge();
  sheet.getRangeByName('R65:W65').merge();

  final List<int> bytes = workbook.saveAsStream();
  workbook.dispose();

  // Save bytes to an .xlsx file.
}

Screenshots or Video

failed_merge.xlsx

Screenshots / Video demonstration

[Upload media here]

Stack Traces

Stack Traces
[Add the Stack Traces here]

On which target platforms have you observed this bug?

Windows

Flutter Doctor output

Doctor output
[Add your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions