<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>excel porting Archives - CenterSpace</title>
	<atom:link href="https://www.centerspace.net/tag/excel-porting/feed" rel="self" type="application/rss+xml" />
	<link>https://www.centerspace.net/tag/excel-porting</link>
	<description>.NET numerical class libraries</description>
	<lastBuildDate>Tue, 07 Feb 2023 21:54:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
<site xmlns="com-wordpress:feed-additions:1">104092929</site>	<item>
		<title>Porting Excel to .NET</title>
		<link>https://www.centerspace.net/porting-excel-to-net</link>
					<comments>https://www.centerspace.net/porting-excel-to-net#respond</comments>
		
		<dc:creator><![CDATA[Trevor Misfeldt]]></dc:creator>
		<pubDate>Tue, 18 Feb 2014 19:11:24 +0000</pubDate>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[csharp excel]]></category>
		<category><![CDATA[excel built-in]]></category>
		<category><![CDATA[excel porting]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[port excel to .net]]></category>
		<category><![CDATA[porting excel to .net]]></category>
		<category><![CDATA[stats]]></category>
		<guid isPermaLink="false">http://www.centerspace.net/blog/?p=5254</guid>

					<description><![CDATA[<p>In previous blog posts, we demonstrated calling NMath from within Excel (C#, Visual Basic). Another common use case is replacing an Excel spreadsheet with an equivalent .NET application. Today, we are releasing .NET code to make this task much easier. We have created a library of Excel extensions for NMath that work just like the built-in [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/porting-excel-to-net">Porting Excel to .NET</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In previous blog posts, we demonstrated calling NMath from within Excel (<a href="/using-c-and-exceldna-to-call-net-libraries/">C#</a>, <a href="/calling-external-net-libraries-from-excel/">Visual Basic</a>). Another common use case is replacing an Excel spreadsheet with an equivalent .NET application. Today, we are releasing .NET code to make this task much easier.</p>
<p>We have created a library of Excel extensions for NMath that work just like the built-in Excel mathematical and statistical functions. They work with arrays in a similar fashion to a range of cells in Excel. Errors have been replaced with exceptions. Return values match as closely as possible.</p>
<p>For example, if you were using the <code>ZTest</code> function in Excel like so:</p>
<p><a href="https://www.centerspace.net/blog/wp-content/uploads/2014/02/ztest.png"><img decoding="async" loading="lazy" class="aligncenter size-full wp-image-5732" src="https://www.centerspace.net/blog/wp-content/uploads/2014/02/ztest.png" alt="Screenshot of Excel spreadsheet with ZTest function." width="461" height="370" srcset="https://www.centerspace.net/wp-content/uploads/2014/02/ztest.png 461w, https://www.centerspace.net/wp-content/uploads/2014/02/ztest-300x240.png 300w" sizes="(max-width: 461px) 100vw, 461px" /></a></p>
<p>This is how you would do the same thing in .NET with NMath:</p>
<pre lang="csharp"> 
      using CenterSpace.NMath.Excel;

      double[] array = { 4, 5, 6, 7, 8, 3, 4 };
      ExcelStats.ZTest( array, 4.5 );</pre>
<p>That&#8217;s possible because we have code like this to make NMath work just like Excel:</p>
<pre lang="csharp">   
    public static double ZTest( double[] array, double mu, double sigma = Double.NaN )
    {
      if ( array.Length == 0 )
      {
        throw new ExcelNumException( "array must not be empty" );
      }
      sigma = Double.IsNaN( sigma ) ? StatsFunctions.StandardDeviation( array, BiasType.Unbiased ) : sigma;
      var zTest = new OneSampleZTest( array, mu, sigma );
      return zTest.P / 2.0;
    }</pre>
<p>We have tested these functions against Excel directly and verified the results.</p>
<p>Here we provide an equivalent function to the MInverse (matrix inverse) function in Excel:</p>
<pre lang="csharp">   
using CenterSpace.NMath.Excel;

    public static double[,] MInverse( double[,] array )
    {
      if ( array.GetLength( 0 ) != array.GetLength( 1 ) )
      {
        throw new ExcelValueException( "array must be square" );
      }
      var matrix = new DoubleMatrix( array );
      var factorization = new DoubleLUFact( matrix );
      return factorization.Inverse().ToArray();
    }</pre>
<p>In the case where you have a user-defined function that calls other built-in functions, you can replace your code easily. For example, a user-defined function as follows:</p>
<pre lang="vb">Function CV(numbers As Range)
  mean = Application.WorksheetFunction.Average(numbers)
  standarddeviation = Application.WorksheetFunction.StDev(numbers)
  CV = (standarddeviation / mean) * 100
End Function
</pre>
<p>would look as follows:</p>
<pre lang="csharp">    private static double CV( double[] a )
    {
      var mean = ExcelStats.Average( a );
      var stddev = ExcelStats.StDev( a );
      return ( stddev / mean ) * 100.0;
    }
</pre>
<p>To use this functionality:</p>
<ol>
<li>Download the <a href="/trial-version/">free trial versions</a> of our NMath library. Trial versions are distributed in distributed in binary form only for a 30-day evaluation period.</li>
<li>Download the Excel extension library <a title="here" href="https://drive.google.com/file/d/1rD1jzQXiSNaIVYJH7kYgmIiPqB7N923a/view?usp=share_link">here</a>. It comes with source code, so you can see exactly how Excel functions are implement in NMath. (In a future release, this functionality will be built into NMath.)</li>
</ol>
<p><strong>Note:</strong> The Excel extensions are designed as static methods, allowing a one-to-one mapping from Excel to NMath. In some cases, such as within loops, greater performance can be achieved by maintaining NMath state between calls.</p>
<p>&#8211; Trevor</p>
<h2>Porting Excel to .NET</h2>
<p>Below is a complete list of supported Excel functions which are now directly supported in NMath.</p>
<pre class="code">ACos
ACosH
ASin
ASinH
ATan
ATan2
ATanH
Abs
AveDev
Average
BetaDist
BetaInv
BinomDist
Ceiling
ChiDist
ChiInv
Combin
Confidence
Correl
Cos
CosH
Count
CountBlank
CountIf
Covar
CritBinom
Degrees
DevSq
Even
Exp
ExponDist
FDist
FInv
FTest
Fact
FactDouble
Floor
Forecast
Frequency
GCD
GammaDist
GammaInv
GammaLn
GeoMean
Growth
HarMean
Int
Intercept
Kurt
Large
LinEst
Ln
Log
Log10
LogEst
LogInv
LogNormDist
MDeterm
MInverse
MMult
Max
Median
Min
Mod
Mode
NegBinomDist
NormDist
NormInv
NormSDist
NormSInv
Odd
Pearson
PercentRank
Percentile
Permut
Pi
Poisson
Power
Prob
Product
Quartile
Quotient
Radians
Rand
RandBetween
Rank
Round
RoundDown
RoundUp
Sign
Sin
SinH
Skew
Slope
Small
SqRt
SqRtPi
StDev
StDevP
StEYX
Standardize
Sum
SumSq
TDist
TInv
TTest
Tan
TanH
Trend
TrimMean
Var
VarP
Weibull
ZTest</pre>
<p>The post <a rel="nofollow" href="https://www.centerspace.net/porting-excel-to-net">Porting Excel to .NET</a> appeared first on <a rel="nofollow" href="https://www.centerspace.net">CenterSpace</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.centerspace.net/porting-excel-to-net/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">5254</post-id>	</item>
	</channel>
</rss>
