-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27703.2042 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReloadingModeFuzzyUDF", "ReloadingModeFuzzyUDF\ReloadingModeFuzzyUDF.csproj", "{D7740BD7-C1F0-4F58-96D9-55D189F18F51}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{D7740BD7-C1F0-4F58-96D9-55D189F18F51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D7740BD7-C1F0-4F58-96D9-55D189F18F51}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D7740BD7-C1F0-4F58-96D9-55D189F18F51}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D7740BD7-C1F0-4F58-96D9-55D189F18F51}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7891DF78-6EEE-4DE4-A061-5344AABB8108} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ExcelDna.Integration; | ||
|
||
namespace ReloadingModeFuzzyUDF | ||
{ | ||
public class Spread | ||
{ | ||
public double min { get; set; } | ||
public double max { get; set; } | ||
public int count { get; set; } | ||
} | ||
|
||
public static class ReloadingFunctions | ||
{ | ||
[ExcelFunction(Name = "MODE.FUZZY", Description = "Calculates the mode of a dataset with a specified \"spread\"", Category = "ReloadingCalculator")] | ||
public static double[] ModeFuzzy(double[] range, double spreadValue, double spreadIncrement) | ||
{ | ||
double[] output = new double[3]; | ||
var foos = new List<double>(range); | ||
foos.RemoveAll(i => i == 0); | ||
range = foos.ToArray(); | ||
for (int i = 0; i < range.Count(); i++) | ||
{ | ||
range[i] = Math.Round(range[i], 2); | ||
} | ||
double smallest = Math.Round(range.Min(), 2); | ||
double largest = Math.Round(range.Max(), 2); | ||
List<Spread> spreadCountList = new List<Spread>(); | ||
Spread spreadSingle = new Spread(); | ||
spreadSingle.min = Math.Round(smallest, 2); | ||
spreadSingle.max = Math.Round((Math.Min((smallest + spreadValue), largest)) - spreadIncrement, 2); | ||
spreadSingle.count = 0; | ||
|
||
while (spreadSingle.max <= largest) | ||
{ | ||
for (int i = 0; i < range.Count(); i++) | ||
{ | ||
if ((range[i] >= spreadSingle.min) && (range[i] <= spreadSingle.max)) | ||
{ | ||
spreadSingle.count++; | ||
} | ||
} | ||
spreadCountList.Add(spreadSingle); | ||
spreadSingle = new Spread(); | ||
spreadSingle.min = Math.Round(spreadCountList[spreadCountList.Count - 1].min + spreadIncrement, 2); | ||
spreadSingle.max = Math.Round(spreadSingle.min + spreadValue - spreadIncrement, 2); | ||
spreadSingle.count = 0; | ||
} | ||
|
||
int indexMax | ||
= !spreadCountList.Any() ? -1 : | ||
spreadCountList | ||
.Select((value, index) => new { Value = value, Index = index }) | ||
.Aggregate((a, b) => (a.Value.count > b.Value.count) ? a : b) | ||
.Index; | ||
|
||
if (indexMax >= 0) | ||
{ | ||
output[0] = spreadCountList[indexMax].count; | ||
output[1] = spreadCountList[indexMax].min; | ||
output[2] = spreadCountList[indexMax].max; | ||
} | ||
else | ||
{ | ||
output[0] = 0; | ||
output[1] = 0; | ||
output[2] = 0; | ||
} | ||
|
||
|
||
return output; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("ReloadingModeFuzzyUDF")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("ReloadingModeFuzzyUDF")] | ||
[assembly: AssemblyCopyright("Copyright © 2018")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("d7740bd7-c1f0-4f58-96d9-55d189f18f51")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="ExcelDnaProps"> | ||
<!-- | ||
If you change properties in this file, they may not come into effect until you: | ||
* Rebuild the solution/project | ||
or | ||
* Close Visual Studio | ||
* Delete .vs folder, if exists | ||
* Delete ProjectName.csproj.user (or equivalent for VB, F#, etc.), if exists | ||
* Delete SolutionName.suo, if exists | ||
* Open your solution/project again in Visual Studio | ||
--> | ||
|
||
<!-- | ||
Configuration properties for building .dna files | ||
--> | ||
<PropertyGroup> | ||
<!-- | ||
Enable/Disable automatic generation of platform-specific versions of .dna files | ||
--> | ||
<ExcelDnaCreate32BitAddIn Condition="'$(ExcelDnaCreate32BitAddIn)' == ''">true</ExcelDnaCreate32BitAddIn> | ||
<ExcelDnaCreate64BitAddIn Condition="'$(ExcelDnaCreate64BitAddIn)' == ''">true</ExcelDnaCreate64BitAddIn> | ||
|
||
<!-- | ||
Define the suffix used for each platform-specific file e.g. MyAddIn64.dna | ||
--> | ||
<ExcelDna32BitAddInSuffix Condition="'$(ExcelDna32BitAddInSuffix)' == ''"></ExcelDna32BitAddInSuffix> | ||
<ExcelDna64BitAddInSuffix Condition="'$(ExcelDna64BitAddInSuffix)' == ''">64</ExcelDna64BitAddInSuffix> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Configuration properties for packing .dna files | ||
--> | ||
<PropertyGroup> | ||
<!-- | ||
Enable/Disable packing of .dna files | ||
--> | ||
<RunExcelDnaPack Condition="'$(RunExcelDnaPack)' == ''">true</RunExcelDnaPack> | ||
|
||
<!-- | ||
Suffix used for packed .xll files e.g. MyAddIn-packed.xll | ||
--> | ||
<ExcelDnaPackXllSuffix Condition="'$(ExcelDnaPackXllSuffix)' == ''">-packed</ExcelDnaPackXllSuffix> | ||
</PropertyGroup> | ||
</Project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<DnaLibrary Name="ReloadingModeFuzzyUDF Add-In" RuntimeVersion="v4.0"> | ||
<ExternalLibrary Path="ReloadingModeFuzzyUDF.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" /> | ||
|
||
<!-- | ||
The RuntimeVersion attribute above allows two settings: | ||
* RuntimeVersion="v2.0" - for .NET 2.0, 3.0 and 3.5 | ||
* RuntimeVersion="v4.0" - for .NET 4 and 4.5 | ||
|
||
Additional referenced assemblies can be specified by adding 'Reference' tags. | ||
These libraries will not be examined and registered with Excel as add-in libraries, | ||
but will be packed into the -packed.xll file and loaded at runtime as needed. | ||
For example: | ||
|
||
<Reference Path="Another.Library.dll" Pack="true" /> | ||
|
||
Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file. | ||
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution. | ||
--> | ||
|
||
</DnaLibrary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{D7740BD7-C1F0-4F58-96D9-55D189F18F51}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>ReloadingModeFuzzyUDF</RootNamespace> | ||
<AssemblyName>ReloadingModeFuzzyUDF</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="ExcelDna.Integration, Version=0.34.6373.42344, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\ExcelDna.Integration.0.34.6\lib\ExcelDna.Integration.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Class1.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="ReloadingModeFuzzyUDF-AddIn.dna" /> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\ExcelDna.Build.props" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets" Condition="Exists('..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets')" /> | ||
<Target Name="EnsureExcelDnaTargetsImported" BeforeTargets="BeforeBuild" Condition="'$(ExcelDnaTargetsImported)' == ''"> | ||
<Error Condition="!Exists('..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets') And ('$(RunExcelDnaBuild)' != '' And $(RunExcelDnaBuild))" Text="You are trying to build with ExcelDna, but the NuGet targets file that ExcelDna depends on is not available on this computer. This is probably because the ExcelDna package has not been committed to source control, or NuGet Package Restore is not enabled. Please enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" /> | ||
<Error Condition="Exists('..\packages\ExcelDna.AddIn.0.34.6\tools\ExcelDna.AddIn.targets') And ('$(RunExcelDnaBuild)' != '' And $(RunExcelDnaBuild))" Text="ExcelDna cannot be run because NuGet packages were restored prior to the build running, and the targets file was unavailable when the build started. Please build the project again to include these packages in the build. You may also need to make sure that your build server does not delete packages prior to each build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="ExcelDna.AddIn" version="0.34.6" targetFramework="net461" /> | ||
<package id="ExcelDna.Integration" version="0.34.6" targetFramework="net461" /> | ||
</packages> |