Forum Discussion

girishjedar's avatar
girishjedar
Copper Contributor
Oct 26, 2023
Solved

Implicit intersection operator: @, breaking the excel generated from C# code

I am trying to generate a excel document, with a SUM total cell having a formula:
=SUM(ROUNDUP(A1:A3,2))


But when I write a formula in C# code as shown below:
workSheet.Cells[1, column.Value].FormulaR1C1 = "=SUM(ROUNDUP(AW3:AW14,2))";

I get the result like this:

How to resolve this? Is there a way to remove the @ operator? Please help. 

Thanks!

 

  • rachel's avatar
    rachel
    Oct 28, 2023
    Yes, writing it as an array formula works for me:

    worksheet.Range("A4:A4").FormulaArrayA1 = "=SUM(ROUNDUP(A1:A3,2))";

    I use "using ClosedXML.Excel;" in csharp.

4 Replies

  • JKPieterse's avatar
    JKPieterse
    Silver Contributor
    Your screenshot formula doesn't match the one in your text. That being said, the range object has a (set of) new Formula2 property/properties you should be using when placing Dynamic array-capable formulas into cells.
    • rachel's avatar
      rachel
      Iron Contributor
      Yes, writing it as an array formula works for me:

      worksheet.Range("A4:A4").FormulaArrayA1 = "=SUM(ROUNDUP(A1:A3,2))";

      I use "using ClosedXML.Excel;" in csharp.

    • girishjedar's avatar
      girishjedar
      Copper Contributor

      JKPieterse that's because, the one I have written in text, is the actual code I have written in C#. But when Excel is generated through .Net Framework, somehow "@" is being added automatically, that's how I ended up with that formula in Screenshot. Its Excel framework that is adding it, and I want to avoid it or remove it through code somehow

Resources