0

The Softartisans' ExcelWriter v8 seems having a bug on merged cell formula. For example:

    ExcelApplication xla = new ExcelApplication();
    Workbook wb = xla.Create(ExcelApplication.FileFormat.Xlsx);

    area = ws.CreateArea(1, 0, 1, 2);
    area.MergeCells();
    cell = ws.Cells[area.FirstRow, area.FirstColumn];
    cell.Formula = "=A1”;

The formula will be disappeared on the worksheet.

BTW, it works on xls format.

Is there an acceptable workaround?

jmoreno
  • 12,752
  • 4
  • 60
  • 91

2 Answers2

1

I work for SoftArtisans.

We have reproduced this behavior, and it does appear to be a bug. We will submit it to Development and will update this thread when we have news.

In the meantime, here is a suggested workaround:

area = ws.CreateArea(1, 0, 1, 2);
area.MergeCells();
cell = ws.Cells[area.FirstRow, area.FirstColumn];
cell.Value = ws.Cells["A1"].Value;

What we have done here is to assign a value to the cell instead of the formula. If the formula is a cell reference as in your example, this is a simple task. However, for more complex formulas, you will have to do the calculations in your code.

The drawbacks of this approach are that there is no longer a live formula within the cell, so it will not be updated automatically by any changes in the output file by the user.

Thank you for bringing this issue to our attention.

Tvae
  • 11
  • 1
1

This issue has been fixed in the recent 8.5.1 release of OfficeWriter. Formulas are now preserved properly in merged cells in .xlsx files (this always worked properly with .xls files). See the OfficeWriter change log.

Aviva M.
  • 381
  • 1
  • 9