Replies: 4 comments 2 replies
-
The @ symbol is the implicit intersection operator which was introduced in Office 365 sometime ago. It is part of the new "dynamic array" functionality. See also this link. I believe in your case, NPOI has worked, but Excel 365 now renders these formulas differently. Let's say in Excel 2016 you had, in cell A4 a formula =$A$1:$D$1. This formula would be "implicitly intersected" with the referring cell, and so A4 would get the value from $A$1. Excel's object model Range interface has several members for supporting dynamic arrays, e.g. Formula2, Formula2R1C1, HasSpill, SpillParent, SpilingToRange, SavedAsArray. I think NPOI will probably need equivalents sooner or later. |
Beta Was this translation helpful? Give feedback.
-
Excel 365 that supports dynamic arrays will always display the @ for implicit intersections, AFAIK. However, if you want to get the "legacy style" formula out of a cell in Excel, use Range.Formula or Range.FormulaR1C1, otherwise use Range.Formula2 or Range.Formula2R1C1. If your formula has a mixture of implicit intersections and dynamic arrays, you'll still get an @ out of Range.Formula and Range.FormulaR1C1. Regarding the calculation issue, are you able to attach a simple example workbook? |
Beta Was this translation helpful? Give feedback.
-
Thanks, but can you please give me code syntax example for the same. In C#, I am not able to see how to get range and apply formula on range using NPOI. I can see only cell.setFormula. |
Beta Was this translation helpful? Give feedback.
-
Range.Formula and the other Range.* refer to Excel Interop or VBA, not NPOI. Set the formula in NPOI with ICell.SetCellFormula, but simply don't use dynamic array formulas. If you write the formula in Excel, use Alt-F11 to open the VB Editor, then Ctrl-G to go to the immediate window, then, assuming your formula is in C10, for example, ?Range("C10").Formula This gets you the formula without the implicit intersection operator, if the formula actually has no dynamic array components. Assign this in NPOI with ICell.SetCellFormula. You can still get an @ out of Excel's Range.Formula with a mixed formula such as =SQRT(A1:A4)+ SQRT(@A1:A4). |
Beta Was this translation helpful? Give feedback.
-
I am using NPOI latest version in c#. I have used a formula like below, means when there is sheetname soon after the '=' sign then additional symbol '@' comes it self while exporting the excel.
e.g:
string strFormula = "IFERROR(IF(MATCH(1,(D{0}='sheet name'!D:D)*......so on
but in excel file this formula comes like:
"IFERROR(IF(MATCH(1,(D{0}=@'sheet name'!D:D)*......so on
means extra @ comes itself. so cell formula doesn't work.
Can someone please help on it,
Beta Was this translation helpful? Give feedback.
All reactions