Forum Discussion
girishjedar
Oct 26, 2023Copper Contributor
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!
- 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
- JKPieterseSilver ContributorYour 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.
- rachelIron ContributorYes, 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.- girishjedarCopper ContributorYou are the best!!!! Thank you so much Rachel. ❤️
- girishjedarCopper 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