ClosedXML Excel trend function

fennelltd

New member
Joined
Jul 17, 2024
Messages
1
Programming Experience
10+
I am trying to use Excel from C#, specifically using the Excel trend function:
ws.Cell("B5").FormulaA1 = "=TREND(G1:G3,H1:H3,23.6)";
when I try and retrieve the calculation of that cell:
var b1 = ws.Cell("B5").Value;
I get an Error 4

I've tried EPPLus and they do not support trend at this time.
Any Thoughts?
 
I'm surprised that it even supports evaluating any formulas at all. To me that feels like they would effectively have to make an Excel emulator. Wow!
 
Looked into this and ClosedXml which is free to use (MIT) and in version 0.1 supports around half of the standard functions. EPPlus is a commercial library and has a large function support list, though not Trend.
If you're just reading the sheets and not changing anything look into reading the cached value previously calculated by Excel, for ClosedXml that is IXLCell.CachedValue instead of IXLCell.Value.

There is another library NPOI that can be used, and if I read this right it support around 200 functions like ClosedXml, but including Trend.
Just some page I found while browsing that could be helpful: c# npoi excel How to get a cell's formula VALUE?

The functions list I found here:
I haven't used any of these libraries except for a quick look into ClosedXml a few years back, so don't know much about them.
 
Back
Top Bottom