FormulaR1C1 "RC[+1]/RC[+2]" doesn't work with EPPlus

Viewed 88

The graphics no longer work with the EPPlus version 4.0.5, I upgraded to version 5.8.4 but I find myself with the FormulaR1C1 which no longer works in some cases.

If I assign a FormulaR1C1 that uses the values of cells on the right, the value is always 0. Whereas if I do the same thing using cells on the left, the FormulaR1C1 is well transformed into an address and it rediscover values. Below is an explanatory image of my text. The values of the columns are C and D have the correct value when the calculate is requested.

Explanatory image of my text

foreach (ExcelRangeBase c in ws.Cells.Reverse())
{
   ExcelRangeBase newCells = assignCell(c, params);
   if (newCells != null)
   {
      string valeur = (c.Value ?? "").ToString();
      if (valeur.StartsWith("{=") && valeur.EndsWith("}"))
      {
        newCells.FormulaR1C1 = "RC[+1]/RC[+2]"; //Simplify for the example but comes from the decomposition of 'valeur'
     }
     newRanges.Add(newCells);
  }
}

ws.Workbook.CalcMode = ExcelCalcMode.Automatic;
ws.Calculate(); 

I have no errors during the generation. When opening the generated file, I got a corruption error.

1 Answers

I found the solution, just remove the + sign which was mandatory in version 4.0.5 of EPPlus and not anymore.

Related