Delete a bunch of unnecesary EPPlus projects.
Change-Id: I3d7595083497be0af5e97dba1029e8b2b8eb5f22
Reviewed-on: https://gnocchi-internal-review.git.corp.google.com/c/third_party/epplus/+/207481
Reviewed-by: Hughes Hilton <hugheshilton@google.com>
Autosubmit: Brian Cairns <bcairns@google.com>
diff --git a/Doc/EPPlusDoc.shfbproj b/Doc/EPPlusDoc.shfbproj
deleted file mode 100644
index 6260364..0000000
--- a/Doc/EPPlusDoc.shfbproj
+++ /dev/null
@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <PropertyGroup>
- <!-- The configuration and platform will be used to determine which
- assemblies to include from solution and project documentation
- sources -->
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{9b3cf930-a2ba-4d8e-ab20-997503b8024b}</ProjectGuid>
- <SHFBSchemaVersion>1.9.9.0</SHFBSchemaVersion>
- <!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
- Studio adds them anyway -->
- <AssemblyName>Documentation</AssemblyName>
- <RootNamespace>Documentation</RootNamespace>
- <Name>Documentation</Name>
- <!-- SHFB properties -->
- <OutputPath>.\Help\</OutputPath>
- <HtmlHelpName>EPPlus 4.0</HtmlHelpName>
- <FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
- <DocumentationSources>
- <DocumentationSource sourceFile="..\EPPlus\bin\Release\EPPlus.dll" />
- <DocumentationSource sourceFile="..\EPPlus\bin\Release\EPPlus.XML" />
- </DocumentationSources>
- <ProjectSummary>EPPlus is a .net library that reads and writes Excel files using the Open Office Xml format.
-EPPlus supports ranges, cell styling, charts, picture, shapes, named ranges, comments,tables and a lot of other stuff.
-EPPlus started with the source from the ExcelPackage project hosted on CodePlex.</ProjectSummary>
- <NamespaceSummaries>
- <NamespaceSummaryItem name="OfficeOpenXml" isDocumented="True">This is the main namespace for EPPlus</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Drawing" isDocumented="True">Contains all classes related to drawings. Drawing objects are Charts, Shapes and Pictures</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Drawing.Chart" isDocumented="True">Contains chart classes</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Style" isDocumented="True">Contains classes for cell styling and named styles</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Style.XmlAccess" isDocumented="True">Contains the classes that write the style xml</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Drawing.Vml" isDocumented="True">Contains classes used for Vml drawings. Vml drawings are used for comments and background images</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Table" isDocumented="True">Contains the classes used for Excel tables</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.DataValidation" isDocumented="True">Contains classes for Datavalidation</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Table.PivotTable" isDocumented="True">Contains classes for Excel Pivottables</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Utils" isDocumented="True">Internal utility classes</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.ConditionalFormatting" isDocumented="True">Contains classes for Conditional Formatting</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Style.Dxf" isDocumented="True">Contains classes for differential styling. EPPlus only support dxf styling in conditional formatting at this point</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.VBA" isDocumented="True">Contains classes for Excel VBA support</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.ConditionalFormatting.Contracts" isDocumented="True">Contains interfaces for Conditional formatting</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.DataValidation.Contracts" isDocumented="True">Contains interfaces for data validation</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.DataValidation.Formulas.Contracts" isDocumented="True">Contains interfaces for data validation formulas</NamespaceSummaryItem>
-<NamespaceSummaryItem name="Ionic.Zip" isDocumented="False">Internal zip handling for packaging. This is code comes from the DotNetZip library... http://dotnetzip.codeplex.com</NamespaceSummaryItem>
-<NamespaceSummaryItem name="Ionic.Zlib" isDocumented="False">Internal zip handling for packaging. This is code comes from the DotNetZip library... http://dotnetzip.codeplex.com</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing" isDocumented="True">Top namesspace for formula parsing</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Packaging" isDocumented="True">Contains classes to handle OOXML packaging. Uses the DotNetZip library to handle compression.</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Packaging.Ionic.Zip" isDocumented="True">Internal zip handling for packaging. This is code comes from the DotNetZip library... http://dotnetzip.codeplex.com</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.Packaging.Ionic.Zlib" isDocumented="True">Internal zip handling for packaging. This is code comes from the DotNetZip library... http://dotnetzip.codeplex.com</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions" isDocumented="True">Formula parsing buildin functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime" isDocumented="True">Formula parsing buildin date and time functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.Information" isDocumented="True">Formula parsing buildin information functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.Logical" isDocumented="True">Formula parsing buildin logical functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.Math" isDocumented="True">Formula parsing buildin math functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.Numeric" isDocumented="True">Formula parsing buildin numeric functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup" isDocumented="True">Formula parsing buildin reference and lookup functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Functions.Text" isDocumented="True">Formula parsing buildin text functions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Excel.Operators" isDocumented="True">Formula parsing operators</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.ExcelUtilities" isDocumented="False">Formula parsing internal utilities</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Exceptions" isDocumented="True">Formula parsing exeptions</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.ExpressionGraph" isDocumented="True">Formula parsing expression graph</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.ExpressionGraph.CompileStrategy" isDocumented="True">Formula parsing expression graph</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.ExpressionGraph.FunctionCompilers" isDocumented="True">Formula parsing expression graph</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.LexicalAnalysis" isDocumented="False">Formula parsing lexial analysis</NamespaceSummaryItem>
-<NamespaceSummaryItem name="OfficeOpenXml.FormulaParsing.Utilities" isDocumented="True">Formula parsing internal utilities</NamespaceSummaryItem></NamespaceSummaries>
- <HelpTitle>EPPlus 4.0</HelpTitle>
- <VisibleItems>InheritedMembers, InheritedFrameworkMembers</VisibleItems>
- <BuildLogFile />
- <HtmlHelp1xCompilerPath />
- <HtmlHelp2xCompilerPath />
- <SandcastlePath />
- <WorkingPath />
- <MaximumGroupParts>2</MaximumGroupParts>
- <NamespaceGrouping>False</NamespaceGrouping>
- <SyntaxFilters>Standard</SyntaxFilters>
- <SdkLinkTarget>Blank</SdkLinkTarget>
- <RootNamespaceContainer>False</RootNamespaceContainer>
- <PresentationStyle>VS2010</PresentationStyle>
- <Preliminary>False</Preliminary>
- <NamingMethod>Guid</NamingMethod>
- <Language>en-US</Language>
- <ContentPlacement>AboveNamespaces</ContentPlacement>
- </PropertyGroup>
- <!-- There are no properties for these groups. AnyCPU needs to appear in
- order for Visual Studio to perform the build. The others are optional
- common platform types that may appear. -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
- </PropertyGroup>
- <!-- Import the SHFB build targets -->
- <Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
-</Project>
\ No newline at end of file
diff --git a/EPPlus.testsettings b/EPPlus.testsettings
deleted file mode 100644
index 61427e0..0000000
--- a/EPPlus.testsettings
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<TestSettings
- id="6583600c-a59c-493b-ad3a-e32b47f76d9c"
- name="EPPlus"
- enableDefaultDataCollectors="false"
- xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
- <Description><!--_locID_text="Description1"-->These are default test settings for a local test run.</Description>
- <Deployment enabled="false" />
-</TestSettings>
diff --git a/EPPlusExcelCalculationSample/App.config b/EPPlusExcelCalculationSample/App.config
deleted file mode 100644
index 8e15646..0000000
--- a/EPPlusExcelCalculationSample/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
- </startup>
-</configuration>
\ No newline at end of file
diff --git a/EPPlusExcelCalculationSample/ConvertUtil.cs b/EPPlusExcelCalculationSample/ConvertUtil.cs
deleted file mode 100644
index 3713dc7..0000000
--- a/EPPlusExcelCalculationSample/ConvertUtil.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace EPPlusExcelFormDemo
-{
- internal static class ConvertUtil
- {
- internal static bool IsNumeric(object candidate)
- {
- if (candidate == null) return false;
- return (candidate.GetType().IsPrimitive || candidate is double || candidate is decimal || candidate is DateTime || candidate is TimeSpan || candidate is long);
- }
-
- internal static bool IsNumericString(object candidate)
- {
- if (candidate != null)
- {
- return Regex.IsMatch(candidate.ToString(), @"^[\d]+(\,[\d])?");
- }
- return false;
- }
-
- /// <summary>
- /// Convert an object value to a double
- /// </summary>
- /// <param name="v"></param>
- /// <param name="ignoreBool"></param>
- /// <returns></returns>
- internal static double GetValueDouble(object v, bool ignoreBool = false)
- {
- double d;
- try
- {
- if (ignoreBool && v is bool)
- {
- return 0;
- }
- if (IsNumeric(v))
- {
- if (v is DateTime)
- {
- d = ((DateTime)v).ToOADate();
- }
- else if (v is TimeSpan)
- {
- d = DateTime.FromOADate(0).Add((TimeSpan)v).ToOADate();
- }
- else
- {
- d = Convert.ToDouble(v, CultureInfo.InvariantCulture);
- }
- }
- else
- {
- d = 0;
- }
- }
-
- catch
- {
- d = 0;
- }
- return d;
- }
- }
-}
diff --git a/EPPlusExcelCalculationSample/EPPlusExcelCalculationDemo.csproj b/EPPlusExcelCalculationSample/EPPlusExcelCalculationDemo.csproj
deleted file mode 100644
index f427a5e..0000000
--- a/EPPlusExcelCalculationSample/EPPlusExcelCalculationDemo.csproj
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{94CBCEFC-DDBF-4F54-8AEA-4C40BBD2881B}</ProjectGuid>
- <OutputType>WinExe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>EPPlusExcelFormDemo</RootNamespace>
- <AssemblyName>EPPlusExcelFormDemo</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <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' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release 4.0|AnyCPU'">
- <OutputPath>bin\Release 4.0\</OutputPath>
- </PropertyGroup>
- <ItemGroup>
- <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.Deployment" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ConvertUtil.cs" />
- <Compile Include="ExcelForm.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="ExcelForm.Designer.cs">
- <DependentUpon>ExcelForm.cs</DependentUpon>
- </Compile>
- <Compile Include="Functions.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="Functions.Designer.cs">
- <DependentUpon>Functions.cs</DependentUpon>
- </Compile>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <EmbeddedResource Include="ExcelForm.resx">
- <DependentUpon>ExcelForm.cs</DependentUpon>
- </EmbeddedResource>
- <EmbeddedResource Include="Functions.resx">
- <DependentUpon>Functions.cs</DependentUpon>
- </EmbeddedResource>
- <EmbeddedResource Include="Properties\Resources.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>Resources.Designer.cs</LastGenOutput>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- <Compile Include="Properties\Resources.Designer.cs">
- <AutoGen>True</AutoGen>
- <DependentUpon>Resources.resx</DependentUpon>
- </Compile>
- <None Include="Properties\Settings.settings">
- <Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>Settings.Designer.cs</LastGenOutput>
- </None>
- <Compile Include="Properties\Settings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DependentUpon>Settings.settings</DependentUpon>
- <DesignTimeSharedInput>True</DesignTimeSharedInput>
- </Compile>
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\EPPlus\EPPlus.csproj">
- <Project>{7b288026-5502-4a39-bf41-77e086f3e4a3}</Project>
- <Name>EPPlus</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
diff --git a/EPPlusExcelCalculationSample/ExcelForm.Designer.cs b/EPPlusExcelCalculationSample/ExcelForm.Designer.cs
deleted file mode 100644
index 3f2a9a3..0000000
--- a/EPPlusExcelCalculationSample/ExcelForm.Designer.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-namespace EPPlusExcelFormDemo
-{
- partial class ExcelForm
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
- this.button_Save = new System.Windows.Forms.Button();
- this.saveFileDialog_SaveExcel = new System.Windows.Forms.SaveFileDialog();
- this.tabPage1 = new System.Windows.Forms.TabPage();
- this.textBox_fx = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.dataGridView_Ws1 = new System.Windows.Forms.DataGridView();
- this.E = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.D = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.C = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.B = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.A = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.button_ApplyFormula = new System.Windows.Forms.Button();
- this.tabControl_Worksheets = new System.Windows.Forms.TabControl();
- this.button1 = new System.Windows.Forms.Button();
- this.tabPage1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Ws1)).BeginInit();
- this.tabControl_Worksheets.SuspendLayout();
- this.SuspendLayout();
- //
- // button_Save
- //
- this.button_Save.Location = new System.Drawing.Point(17, 12);
- this.button_Save.Name = "button_Save";
- this.button_Save.Size = new System.Drawing.Size(95, 23);
- this.button_Save.TabIndex = 1;
- this.button_Save.Text = "Save Excelfile";
- this.button_Save.UseVisualStyleBackColor = true;
- this.button_Save.Click += new System.EventHandler(this.button_Save_Click);
- //
- // tabPage1
- //
- this.tabPage1.Controls.Add(this.button_ApplyFormula);
- this.tabPage1.Controls.Add(this.dataGridView_Ws1);
- this.tabPage1.Controls.Add(this.label1);
- this.tabPage1.Controls.Add(this.textBox_fx);
- this.tabPage1.Location = new System.Drawing.Point(4, 22);
- this.tabPage1.Name = "tabPage1";
- this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
- this.tabPage1.Size = new System.Drawing.Size(575, 360);
- this.tabPage1.TabIndex = 0;
- this.tabPage1.Text = "Sheet1";
- this.tabPage1.UseVisualStyleBackColor = true;
- //
- // textBox_fx
- //
- this.textBox_fx.Location = new System.Drawing.Point(94, 16);
- this.textBox_fx.Name = "textBox_fx";
- this.textBox_fx.Size = new System.Drawing.Size(356, 20);
- this.textBox_fx.TabIndex = 0;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(73, 16);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(15, 13);
- this.label1.TabIndex = 1;
- this.label1.Text = "fx";
- //
- // dataGridView_Ws1
- //
- this.dataGridView_Ws1.AllowUserToAddRows = false;
- this.dataGridView_Ws1.AllowUserToDeleteRows = false;
- dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle3.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView_Ws1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3;
- this.dataGridView_Ws1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView_Ws1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.A,
- this.B,
- this.C,
- this.D,
- this.E});
- this.dataGridView_Ws1.Location = new System.Drawing.Point(6, 43);
- this.dataGridView_Ws1.MultiSelect = false;
- this.dataGridView_Ws1.Name = "dataGridView_Ws1";
- dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle4.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
- this.dataGridView_Ws1.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
- this.dataGridView_Ws1.ScrollBars = System.Windows.Forms.ScrollBars.None;
- this.dataGridView_Ws1.ShowCellErrors = false;
- this.dataGridView_Ws1.ShowCellToolTips = false;
- this.dataGridView_Ws1.ShowEditingIcon = false;
- this.dataGridView_Ws1.ShowRowErrors = false;
- this.dataGridView_Ws1.Size = new System.Drawing.Size(563, 311);
- this.dataGridView_Ws1.TabIndex = 2;
- this.dataGridView_Ws1.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView_Ws1_CellBeginEdit);
- this.dataGridView_Ws1.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_Ws1_CellValidating);
- //
- // E
- //
- this.E.HeaderText = "E";
- this.E.Name = "E";
- //
- // D
- //
- this.D.HeaderText = "D";
- this.D.Name = "D";
- //
- // C
- //
- this.C.HeaderText = "C";
- this.C.Name = "C";
- //
- // B
- //
- this.B.HeaderText = "B";
- this.B.Name = "B";
- //
- // A
- //
- this.A.HeaderText = "A";
- this.A.Name = "A";
- //
- // button_ApplyFormula
- //
- this.button_ApplyFormula.Location = new System.Drawing.Point(456, 14);
- this.button_ApplyFormula.Name = "button_ApplyFormula";
- this.button_ApplyFormula.Size = new System.Drawing.Size(64, 23);
- this.button_ApplyFormula.TabIndex = 3;
- this.button_ApplyFormula.Text = "Apply";
- this.button_ApplyFormula.UseVisualStyleBackColor = true;
- this.button_ApplyFormula.Click += new System.EventHandler(this.button_ApplyFormula_Click);
- //
- // tabControl_Worksheets
- //
- this.tabControl_Worksheets.Controls.Add(this.tabPage1);
- this.tabControl_Worksheets.Location = new System.Drawing.Point(13, 63);
- this.tabControl_Worksheets.Name = "tabControl_Worksheets";
- this.tabControl_Worksheets.SelectedIndex = 0;
- this.tabControl_Worksheets.Size = new System.Drawing.Size(583, 386);
- this.tabControl_Worksheets.TabIndex = 0;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(415, 12);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(171, 23);
- this.button1.TabIndex = 2;
- this.button1.Text = "View Implemented Functions";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // ExcelForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(610, 456);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.button_Save);
- this.Controls.Add(this.tabControl_Worksheets);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "ExcelForm";
- this.Text = "EPPlus Excel demo";
- this.tabPage1.ResumeLayout(false);
- this.tabPage1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Ws1)).EndInit();
- this.tabControl_Worksheets.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.Button button_Save;
- private System.Windows.Forms.SaveFileDialog saveFileDialog_SaveExcel;
- private System.Windows.Forms.TabPage tabPage1;
- private System.Windows.Forms.Button button_ApplyFormula;
- private System.Windows.Forms.DataGridView dataGridView_Ws1;
- private System.Windows.Forms.DataGridViewTextBoxColumn A;
- private System.Windows.Forms.DataGridViewTextBoxColumn B;
- private System.Windows.Forms.DataGridViewTextBoxColumn C;
- private System.Windows.Forms.DataGridViewTextBoxColumn D;
- private System.Windows.Forms.DataGridViewTextBoxColumn E;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox textBox_fx;
- private System.Windows.Forms.TabControl tabControl_Worksheets;
- private System.Windows.Forms.Button button1;
- }
-}
-
diff --git a/EPPlusExcelCalculationSample/ExcelForm.cs b/EPPlusExcelCalculationSample/ExcelForm.cs
deleted file mode 100644
index ba0cdc5..0000000
--- a/EPPlusExcelCalculationSample/ExcelForm.cs
+++ /dev/null
@@ -1,245 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using OfficeOpenXml;
-
-namespace EPPlusExcelFormDemo
-{
- public partial class ExcelForm : Form
- {
- private ExcelPackage _package;
- private DataGridViewCell _currentCell;
- private Font _inactiveCellFont;
- private Font _activeCellFont;
- private const int NumberOfColumns = 5;
-
- public ExcelForm()
- {
- InitializeComponent();
- InitializePackage();
- InitPackageToUI();
- this.Closing += (sender, args) => _package.Dispose();
- dataGridView_Ws1.RowHeadersWidth = 50;
- dataGridView_Ws1.Select();
- }
-
- private void InitializePackage()
- {
- _package = new ExcelPackage(new MemoryStream());
- var ws1 = _package.Workbook.Worksheets.Add("Worksheet1");
- for (var col = 2; col < NumberOfColumns; col++)
- {
- for (var row = 1; row < 9; row++)
- {
- ws1.Cells[row, col].Value = row*col;
- }
- }
- ws1.Cells[7, 1].Value = "SUM";
- ws1.Cells[7, 2].Formula = "SUM(B1:B6)";
- ws1.Cells[7, 3].Formula = "SUM(C1:C6)";
- ws1.Cells[7, 4].Formula = "SUM(D1:D6)";
-
- ws1.Cells[8, 1].Value = "STDEV";
- ws1.Cells[8, 2].Formula = "STDEV(B1:B6)";
- ws1.Cells[8, 3].Formula = "STDEV(C1:C6)";
- ws1.Cells[8, 4].Formula = "STDEV(D1:D6)";
- _package.Workbook.Calculate();
- }
-
- private void InitFonts(DataGridView gridView)
- {
- _activeCellFont = new Font(gridView.Font, FontStyle.Bold);
- _inactiveCellFont = gridView.Font;
- }
-
- private void InitEvents(DataGridView gridView)
- {
- gridView.CellEnter += DataGrid1OnCellEnter;
- gridView.CellLeave += DataGrid1OnCellLeave;
- }
-
- /// <summary>
- /// Binds the EPPlus package (or actually only its first worksheet)
- /// to the DataGridView.
- /// </summary>
- private void InitPackageToUI()
- {
- var ws = _package.Workbook.Worksheets.First();
- var page1 = this.tabControl_Worksheets.Controls[0] as TabPage;
- page1.Text = ws.Name;
- var gridView = GetGrid();
- InitFonts(gridView);
- InitEvents(gridView);
-
- for (var row = 0; row < ws.Dimension.Rows; row++)
- {
- var gridRow = new DataGridViewRow {HeaderCell = {Value = (row + 1).ToString()}};
- for (var col = 0; col < NumberOfColumns; col++)
- {
- var cell = ws.Cells[row + 1, col + 1];
- if (cell.Value!=null)
- {
- using (var uiCell = new DataGridViewTextBoxCell())
- {
- uiCell.Value = cell.Value;
- gridRow.Cells.Add(uiCell);
- }
- }
- }
- gridView.Rows.Add(gridRow);
- }
- gridView.Refresh();
- }
-
- private void BindPackageToUI()
- {
- var dataGrid1 = GetGrid();
- for (var row = 1; row < _package.Workbook.Worksheets.First().Dimension.Rows + 1; row++)
- {
- for (var col = 1; col <= NumberOfColumns; col++)
- {
- var excelCell = _package.Workbook.Worksheets.First().Cells[row, col];
- var gridViewCell = dataGrid1.Rows[row - 1].Cells[col - 1];
- gridViewCell.Value = excelCell.Value;
- }
- }
- dataGrid1.Refresh();
- }
-
- private object CellValueToObject(string cellVal)
- {
- if (ConvertUtil.IsNumericString(cellVal))
- {
- return double.Parse(cellVal, CultureInfo.InvariantCulture);
- }
- return cellVal;
- }
-
- private void DataGrid1OnCellLeave(object sender, DataGridViewCellEventArgs e)
- {
- var dataGrid1 = GetGrid();
- var gridViewCell = dataGrid1.Rows[e.RowIndex].Cells[e.ColumnIndex];
- var excelCell = _package.Workbook.Worksheets.First().Cells[e.RowIndex + 1, e.ColumnIndex + 1];
- gridViewCell.Style.ForeColor = Color.Black;
- gridViewCell.Style.BackColor = Color.White;
- gridViewCell.Style.Font = _inactiveCellFont;
- }
-
-
- private DataGridView GetGrid()
- {
- var page1 = this.tabControl_Worksheets.Controls[0] as TabPage;
- var dataGrid1 = page1.Controls["dataGridView_Ws1"] as DataGridView;
- return dataGrid1;
- }
-
- private void DataGrid1OnCellEnter(object sender, DataGridViewCellEventArgs e)
- {
- var dataGrid1 = GetGrid();
- dataGrid1.Refresh();
- BindPackageToUI();
- var cell = dataGrid1.Rows[e.RowIndex].Cells[e.ColumnIndex];
- var excelCell = _package.Workbook.Worksheets.First().Cells[e.RowIndex + 1, e.ColumnIndex + 1];
- if (!string.IsNullOrEmpty(excelCell.Formula))
- {
- textBox_fx.Text = "=" + excelCell.Formula;
- cell.Value = "=" + excelCell.Formula;
- }
- else if(excelCell.Value != null)
- {
- textBox_fx.Text = excelCell.Value.ToString();
- }
- cell.Style.ForeColor = Color.Blue;
- cell.Style.BackColor = Color.Gainsboro;
- cell.Style.Font = _activeCellFont;
- _currentCell = cell;
- }
-
- private void button_Save_Click(object sender, EventArgs e)
- {
- saveFileDialog_SaveExcel.Filter = "Excel files (*.xlsx)|*.xlsx";
- var dialogResult = saveFileDialog_SaveExcel.ShowDialog();
- if (dialogResult == DialogResult.OK)
- {
- _package.SaveAs(new FileInfo(saveFileDialog_SaveExcel.FileName));
- }
- }
-
- private void button_ApplyFormula_Click(object sender, EventArgs e)
- {
- var row = _currentCell.RowIndex;
- var col = _currentCell.ColumnIndex;
- var txt = textBox_fx.Text;
- if (txt.StartsWith("="))
- {
- _package.Workbook.Worksheets.First().Cells[row + 1, col + 1].Formula = txt.Substring(1);
- }
- else
- {
- _package.Workbook.Worksheets.First().Cells[row + 1, col + 1].Formula = null;
- _package.Workbook.Worksheets.First().Cells[row + 1, col + 1].Value = CellValueToObject(txt);
- }
- try
- {
- _package.Workbook.Calculate();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- BindPackageToUI();
- this.Refresh();
- }
-
- private void dataGridView_Ws1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
- {
- var dataGrid1 = GetGrid();
- var cell = dataGrid1.Rows[e.RowIndex].Cells[e.ColumnIndex];
- var excelCell = _package.Workbook.Worksheets.First().Cells[e.RowIndex + 1, e.ColumnIndex + 1];
- if (!string.IsNullOrEmpty(excelCell.Formula))
- {
- cell.Value = "=" + excelCell.Formula;
- }
- dataGrid1.Refresh();
- }
-
- private void dataGridView_Ws1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
- {
- var f = e.FormattedValue.ToString();
- if (f.StartsWith("="))
- {
- _package.Workbook.Worksheets.First().Cells[e.RowIndex + 1, e.ColumnIndex + 1].Formula = f.Substring(1);
- }
- else
- {
- _package.Workbook.Worksheets.First().Cells[e.RowIndex + 1, e.ColumnIndex + 1].Formula = null;
- _package.Workbook.Worksheets.First().Cells[e.RowIndex + 1, e.ColumnIndex + 1].Value = CellValueToObject(f);
- }
- try
- {
- _package.Workbook.Calculate();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- BindPackageToUI();
- this.Refresh();
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- var frm = new frmFunctions(_package.Workbook.FormulaParserManager.GetImplementedFunctionNames().ToList());
- frm.ShowDialog(this);
-
- }
- }
-}
diff --git a/EPPlusExcelCalculationSample/ExcelForm.resx b/EPPlusExcelCalculationSample/ExcelForm.resx
deleted file mode 100644
index ab64aba..0000000
--- a/EPPlusExcelCalculationSample/ExcelForm.resx
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <metadata name="saveFileDialog_SaveExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>17, 17</value>
- </metadata>
- <metadata name="A.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="B.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="C.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="D.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="E.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
-</root>
\ No newline at end of file
diff --git a/EPPlusExcelCalculationSample/Functions.Designer.cs b/EPPlusExcelCalculationSample/Functions.Designer.cs
deleted file mode 100644
index 5fd48ce..0000000
--- a/EPPlusExcelCalculationSample/Functions.Designer.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-namespace EPPlusExcelFormDemo
-{
- partial class frmFunctions
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // textBox1
- //
- this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.textBox1.Location = new System.Drawing.Point(0, 0);
- this.textBox1.Multiline = true;
- this.textBox1.Name = "textBox1";
- this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.textBox1.Size = new System.Drawing.Size(606, 679);
- this.textBox1.TabIndex = 0;
- //
- // frmFunctions
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(606, 679);
- this.Controls.Add(this.textBox1);
- this.Name = "frmFunctions";
- this.Text = "Functions";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.TextBox textBox1;
-
- }
-}
\ No newline at end of file
diff --git a/EPPlusExcelCalculationSample/Functions.cs b/EPPlusExcelCalculationSample/Functions.cs
deleted file mode 100644
index cca4e57..0000000
--- a/EPPlusExcelCalculationSample/Functions.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace EPPlusExcelFormDemo
-{
- public partial class frmFunctions : Form
- {
- public frmFunctions()
- {
- InitializeComponent();
- }
- public frmFunctions(List<string> functions)
- {
- InitializeComponent();
-
- var sb = new StringBuilder();
- foreach (var f in functions)
- {
- sb.AppendLine(f.ToUpper());
- }
- textBox1.Text = sb.ToString();
- }
- }
-}
diff --git a/EPPlusExcelCalculationSample/Functions.resx b/EPPlusExcelCalculationSample/Functions.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/EPPlusExcelCalculationSample/Functions.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
-</root>
\ No newline at end of file
diff --git a/EPPlusExcelCalculationSample/Program.cs b/EPPlusExcelCalculationSample/Program.cs
deleted file mode 100644
index 0c76d4e..0000000
--- a/EPPlusExcelCalculationSample/Program.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace EPPlusExcelFormDemo
-{
- static class Program
- {
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new ExcelForm());
- }
- }
-}
diff --git a/EPPlusExcelCalculationSample/Properties/AssemblyInfo.cs b/EPPlusExcelCalculationSample/Properties/AssemblyInfo.cs
deleted file mode 100644
index 84594e5..0000000
--- a/EPPlusExcelCalculationSample/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-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("EPPlusExcelFormDemo")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("EPPlusExcelFormDemo")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[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("1de25448-fecb-493d-ad8d-d03e6853cee5")]
-
-// 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")]
diff --git a/EPPlusExcelCalculationSample/Properties/Resources.Designer.cs b/EPPlusExcelCalculationSample/Properties/Resources.Designer.cs
deleted file mode 100644
index 08e3d81..0000000
--- a/EPPlusExcelCalculationSample/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.18408
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace EPPlusExcelFormDemo.Properties
-{
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EPPlusExcelFormDemo.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/EPPlusExcelCalculationSample/Properties/Resources.resx b/EPPlusExcelCalculationSample/Properties/Resources.resx
deleted file mode 100644
index af7dbeb..0000000
--- a/EPPlusExcelCalculationSample/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
-</root>
\ No newline at end of file
diff --git a/EPPlusExcelCalculationSample/Properties/Settings.Designer.cs b/EPPlusExcelCalculationSample/Properties/Settings.Designer.cs
deleted file mode 100644
index fc48fa2..0000000
--- a/EPPlusExcelCalculationSample/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.18408
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace EPPlusExcelFormDemo.Properties
-{
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/EPPlusExcelCalculationSample/Properties/Settings.settings b/EPPlusExcelCalculationSample/Properties/Settings.settings
deleted file mode 100644
index 3964565..0000000
--- a/EPPlusExcelCalculationSample/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
- <Profiles>
- <Profile Name="(Default)" />
- </Profiles>
- <Settings />
-</SettingsFile>
diff --git a/EPPlusTest.runsettings b/EPPlusTest.runsettings
deleted file mode 100644
index 8855ba9..0000000
--- a/EPPlusTest.runsettings
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RunSettings>
- <!-- Configurations that affect the Test Framework -->
- <MSTest>
- <DeleteDeploymentDirectoryAfterTestRunIsComplete>false</DeleteDeploymentDirectoryAfterTestRunIsComplete>
- </MSTest>
-
-
-</RunSettings>
\ No newline at end of file
diff --git a/EPPlusTest/Address.cs b/EPPlusTest/Address.cs
deleted file mode 100644
index 2d08d1a..0000000
--- a/EPPlusTest/Address.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest
-{
- /// <summary>
- /// Summary description for Address
- /// </summary>
- [TestClass]
- public class Address
- {
- public Address()
- {
- //
- // TODO: Add constructor logic here
- //
- }
-
- private TestContext testContextInstance;
-
- /// <summary>
- ///Gets or sets the test context which provides
- ///information about and functionality for the current test run.
- ///</summary>
- public TestContext TestContext
- {
- get
- {
- return testContextInstance;
- }
- set
- {
- testContextInstance = value;
- }
- }
-
- #region Additional test attributes
- //
- // You can use the following additional attributes as you write your tests:
- //
- // Use ClassInitialize to run code before running the first test in the class
- // [ClassInitialize()]
- // public static void MyClassInitialize(TestContext testContext) { }
- //
- // Use ClassCleanup to run code after all tests in a class have run
- // [ClassCleanup()]
- // public static void MyClassCleanup() { }
- //
- // Use TestInitialize to run code before running each test
- // [TestInitialize()]
- // public void MyTestInitialize() { }
- //
- // Use TestCleanup to run code after each test has run
- // [TestCleanup()]
- // public void MyTestCleanup() { }
- //
- #endregion
-
- [TestMethod]
- public void InsertDeleteTest()
- {
- var addr = new ExcelAddressBase("A1:B3");
-
- Assert.AreEqual(addr.AddRow(2, 4).Address, "A1:B7");
- Assert.AreEqual(addr.AddColumn(2, 4).Address, "A1:F3");
- Assert.AreEqual(addr.DeleteColumn(2, 1).Address, "A1:A3");
- Assert.AreEqual(addr.DeleteRow(2, 2).Address, "A1:B1");
-
- Assert.AreEqual(addr.DeleteRow(1, 3), null);
- Assert.AreEqual(addr.DeleteColumn(1, 2), null);
- }
- [TestMethod]
- public void SplitAddress()
- {
- var addr = new ExcelAddressBase("C3:F8");
-
- addr.Insert(new ExcelAddressBase("G9"), ExcelAddressBase.eShiftType.Right);
- addr.Insert(new ExcelAddressBase("G3"), ExcelAddressBase.eShiftType.Right);
- addr.Insert(new ExcelAddressBase("C9"), ExcelAddressBase.eShiftType.Right);
- addr.Insert(new ExcelAddressBase("B2"), ExcelAddressBase.eShiftType.Right);
- addr.Insert(new ExcelAddressBase("B3"), ExcelAddressBase.eShiftType.Right);
- addr.Insert(new ExcelAddressBase("D:D"), ExcelAddressBase.eShiftType.Right);
- addr.Insert(new ExcelAddressBase("5:5"), ExcelAddressBase.eShiftType.Down);
- }
- [TestMethod]
- public void Addresses()
- {
- var a1 = new ExcelAddress("SalesData!$K$445");
- var a2 = new ExcelAddress("SalesData!$K$445:$M$449,SalesData!$N$448:$Q$454,SalesData!$L$458:$O$464");
- var a3 = new ExcelAddress("SalesData!$K$445:$L$448");
- //var a4 = new ExcelAddress("'[1]Risk]TatTWRForm_TWRWEEKLY20130926090'!$N$527");
- var a5 = new ExcelAddress("Table1[[#All],[Title]]");
- var a6 = new ExcelAddress("Table1[#All]");
- var a7 = new ExcelAddress("Table1[[#Headers],[FirstName]:[LastName]]");
- var a8 = new ExcelAddress("Table1[#Headers]");
- var a9 = new ExcelAddress("Table2[[#All],[SubTotal]]");
- var a10 = new ExcelAddress("Table2[#All]");
- var a11 = new ExcelAddress("Table1[[#All],[Freight]]");
- var a12 = new ExcelAddress("[1]!Table1[[LastName]:[Name]]");
- var a13 = new ExcelAddress("Table1[[#All],[Freight]]");
- var a14 = new ExcelAddress("SalesData!$N$5+'test''1'!$J$33");
- }
-
- [TestMethod]
- public void IsValidCellAdress()
- {
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("A1"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("A1048576"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("XFD1"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("XFD1048576"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("Table1!A1"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("Table1!A1048576"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("Table1!XFD1"));
- Assert.IsTrue(ExcelCellBase.IsValidCellAddress("Table1!XFD1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("A"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("A"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("XFD"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("XFD"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("1"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("1"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("A1:A1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("A1:XFD1"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("A1048576:XFD1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("XFD1:XFD1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("Table1!A1:A1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("Table1!A1:XFD1"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("Table1!A1048576:XFD1048576"));
- Assert.IsFalse(ExcelCellBase.IsValidCellAddress("Table1!XFD1:XFD1048576"));
- }
-
- }
-}
diff --git a/EPPlusTest/Calculation.cs b/EPPlusTest/Calculation.cs
deleted file mode 100644
index e409e07..0000000
--- a/EPPlusTest/Calculation.cs
+++ /dev/null
@@ -1,317 +0,0 @@
-using System;
-using System.Globalization;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.IO;
-using System.Diagnostics;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest
-{
- [DeploymentItem("Workbooks", "targetFolder")]
- [TestClass]
- public class Calculation
- {
- //[TestMethod]
- //public void Calulation()
- //{
- // var pck = new ExcelPackage(new FileInfo("c:\\temp\\chain.xlsx"));
- // pck.Workbook.Calculate();
- // Assert.AreEqual(50D, pck.Workbook.Worksheets[1].Cells["C1"].Value);
- //}
- //[TestMethod]
- //public void Calulation2()
- //{
- // var pck = new ExcelPackage(new FileInfo("c:\\temp\\chainTest.xlsx"));
- // pck.Workbook.Calculate();
- // Assert.AreEqual(1124999960382D, pck.Workbook.Worksheets[1].Cells["C1"].Value);
- //}
- //[TestMethod]
- //public void Calulation3()
- //{
- // var pck = new ExcelPackage(new FileInfo("c:\\temp\\names.xlsx"));
- // pck.Workbook.Calculate();
- // //Assert.AreEqual(1124999960382D, pck.Workbook.Worksheets[1].Cells["C1"].Value);
- //}
- [TestMethod]
- public void CalulationTestDatatypes()
- {
- var pck = new ExcelPackage();
- var ws=pck.Workbook.Worksheets.Add("Calc1");
- ws.SetValue("A1", (short)1);
- ws.SetValue("A2", (long)2);
- ws.SetValue("A3", (Single)3);
- ws.SetValue("A4", (double)4);
- ws.SetValue("A5", (Decimal)5);
- ws.SetValue("A6", (byte)6);
- ws.SetValue("A7", null);
- ws.Cells["A10"].Formula = "Sum(A1:A8)";
- ws.Cells["A11"].Formula = "SubTotal(9,A1:A8)";
- ws.Cells["A12"].Formula = "Average(A1:A8)";
-
- ws.Calculate();
- Assert.AreEqual(21D, ws.Cells["a10"].Value);
- Assert.AreEqual(21D, ws.Cells["a11"].Value);
- Assert.AreEqual(21D/6, ws.Cells["a12"].Value);
- }
- [TestMethod]
- public void CalculateTest()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
-
- ws.SetValue("A1",( short)1);
- var v=ws.Calculate("2.5-A1+ABS(-3.0)-SIN(3)");
- Assert.AreEqual(4.3589, Math.Round((double)v, 4));
-
- ws.Row(1).Hidden = true;
- v = ws.Calculate("subtotal(109,a1:a10)");
- Assert.AreEqual(0D, v);
-
- v = ws.Calculate("-subtotal(9,a1:a3)");
- Assert.AreEqual(-1D, v);
- }
- [TestMethod]
- public void CalculateTestIsFunctions()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
-
- ws.SetValue(1, 1, 1.0D);
- ws.SetFormula(1, 2, "isblank(A1:A5)");
- ws.SetFormula(1, 3, "concatenate(a1,a2,a3)");
- ws.SetFormula(1, 4, "Row()");
- ws.SetFormula(1, 5, "Row(a3)");
- ws.Calculate();
- }
- [Ignore]
- [TestMethod]
- public void Calulation4()
- {
- //C:\Development\epplus formulas\EPPlusTest\Workbooks\FormulaTest.xlsx
- var pck = new ExcelPackage(new FileInfo(@"C:\Development\epplus formulas\EPPlusTest\Workbooks\FormulaTest.xlsx"));
- //var pck = new ExcelPackage(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\..\\..\\EPPlusTest\\workbooks\\FormulaTest.xlsx"));
- pck.Workbook.Calculate();
- Assert.AreEqual(490D, pck.Workbook.Worksheets[1].Cells["D5"].Value);
- }
- [Ignore]
- [TestMethod]
- public void CalulationValidationExcel()
- {
- var dir = AppDomain.CurrentDomain.BaseDirectory;
- var pck = new ExcelPackage(new FileInfo(Path.Combine(dir, "Workbooks", "FormulaTest.xlsx")));
-
- var ws = pck.Workbook.Worksheets["ValidateFormulas"];
- var fr = new Dictionary<string, object>();
- foreach (var cell in ws.Cells)
- {
- if (!string.IsNullOrEmpty(cell.Formula))
- {
- fr.Add(cell.Address, cell.Value);
- }
- }
- pck.Workbook.Calculate();
- var nErrors = 0;
- var errors = new List<Tuple<string, object, object>>();
- foreach (var adr in fr.Keys)
- {
- try
- {
- if (fr[adr] is double && ws.Cells[adr].Value is double)
- {
- var d1 = Convert.ToDouble(fr[adr]);
- var d2 = Convert.ToDouble(ws.Cells[adr].Value);
- if (Math.Abs(d1 - d2) < 0.0001)
- {
- continue;
- }
- else
- {
- Assert.AreEqual(fr[adr], ws.Cells[adr].Value);
- }
- }
- else
- {
- Assert.AreEqual(fr[adr], ws.Cells[adr].Value);
- }
- }
- catch
- {
- errors.Add(new Tuple<string, object, object>(adr, fr[adr], ws.Cells[adr].Value));
- nErrors++;
- }
- }
- }
- [Ignore]
- [TestMethod]
- public void TestOneCell()
- {
- var pck = new ExcelPackage(new FileInfo(@"C:\temp\EPPlusTestark\Test4.xlsm"));
- var ws = pck.Workbook.Worksheets.First();
- pck.Workbook.Worksheets["Räntebärande formaterat utland"].Cells["M13"].Calculate();
- Assert.AreEqual(0d, pck.Workbook.Worksheets["Räntebärande formaterat utland"].Cells["M13"].Value);
- }
-
- [Ignore]
- [TestMethod]
- public void TestPrecedence()
- {
- var pck = new ExcelPackage(new FileInfo(@"C:\temp\EPPlusTestark\Precedence.xlsx"));
- var ws = pck.Workbook.Worksheets.Last();
- pck.Workbook.Calculate();
- Assert.AreEqual(150d, ws.Cells["A1"].Value);
- }
- [Ignore]
- [TestMethod]
- public void TestDataType()
- {
- var pck = new ExcelPackage(new FileInfo(@"c:\temp\EPPlusTestark\calc_amount.xlsx"));
- var ws = pck.Workbook.Worksheets[1];
- //ws.Names.Add("Name1",ws.Cells["A1"]);
- //ws.Names.Add("Name2", ws.Cells["A2"]);
- ws.Names["PRICE"].Value = 30;
- ws.Names["QUANTITY"].Value = 10;
-
- ws.Calculate();
-
- ws.Names["PRICE"].Value = 40;
- ws.Names["QUANTITY"].Value = 20;
-
- ws.Calculate();
- }
- [TestMethod]
- public void CalcTwiceError()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("CalcTest");
- ws.Names.AddValue("PRICE", 10);
- ws.Names.AddValue("QUANTITY", 11);
- ws.Cells["A1"].Formula="PRICE*QUANTITY";
- ws.Names.AddFormula("AMOUNT", "PRICE*QUANTITY");
-
- ws.Names["PRICE"].Value = 30;
- ws.Names["QUANTITY"].Value = 10;
-
- ws.Calculate();
- Assert.AreEqual(300D, ws.Cells["A1"].Value);
- Assert.AreEqual(300D, ws.Names["AMOUNT"].Value);
- ws.Names["PRICE"].Value = 40;
- ws.Names["QUANTITY"].Value = 20;
-
- ws.Calculate();
- Assert.AreEqual(800D, ws.Cells["A1"].Value);
- Assert.AreEqual(800D, ws.Names["AMOUNT"].Value);
- }
- [TestMethod]
- public void IfError()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("CalcTest");
- ws.Cells["A1"].Value = "test1";
- ws.Cells["A5"].Value = "test2";
- ws.Cells["A2"].Value = "Sant";
- ws.Cells["A3"].Value = "Falskt";
- ws.Cells["A4"].Formula = "if(A1>=A5,true,A3)";
- ws.Cells["B1"].Formula = "isText(a1)";
- ws.Cells["B2"].Formula = "isText(\"Test\")";
- ws.Cells["B3"].Formula = "isText(1)";
- ws.Cells["B4"].Formula = "isText(true)";
- ws.Cells["c1"].Formula = "mid(a1,4,15)";
-
- ws.Calculate();
- }
- [TestMethod, Ignore]
- public void TestAllWorkbooks()
- {
- StringBuilder sb=new StringBuilder();
- //Add sheets to test in this directory or change it to your testpath.
- string path = @"C:\temp\EPPlusTestark\workbooks";
- if(!Directory.Exists(path)) return;
-
- foreach (var file in Directory.GetFiles(path, "*.xls*"))
- {
- sb.Append(GetOutput(file));
- }
-
- if (sb.Length > 0)
- {
- File.WriteAllText(string.Format("TestAllWorkooks{0}.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortDateString()), sb.ToString());
- throw(new Exception("Test failed with\r\n\r\n" + sb.ToString()));
-
- }
- }
- private string GetOutput(string file)
- {
- using (var pck = new ExcelPackage(new FileInfo(file)))
- {
- var fr = new Dictionary<string, object>();
- foreach (var ws in pck.Workbook.Worksheets)
- {
- if (!(ws is ExcelChartsheet))
- {
- foreach (var cell in ws.Cells)
- {
- if (!string.IsNullOrEmpty(cell.Formula))
- {
- fr.Add(ws.PositionID.ToString() + "," + cell.Address, cell.Value);
- ws._values.SetValue(cell.Start.Row, cell.Start.Column, null);
- }
- }
- }
- }
-
- pck.Workbook.Calculate();
- var nErrors = 0;
- var errors = new List<Tuple<string, object, object>>();
- ExcelWorksheet sheet=null;
- string adr="";
- var fileErr = new System.IO.StreamWriter("c:\\temp\\err.txt");
- foreach (var cell in fr.Keys)
- {
- try
- {
- var spl = cell.Split(',');
- var ix = int.Parse(spl[0]);
- sheet = pck.Workbook.Worksheets[ix];
- adr = spl[1];
- if (fr[cell] is double && (sheet.Cells[adr].Value is double || sheet.Cells[adr].Value is decimal || sheet.Cells[adr].Value.GetType().IsPrimitive))
- {
- var d1 = Convert.ToDouble(fr[cell]);
- var d2 = Convert.ToDouble(sheet.Cells[adr].Value);
- //if (Math.Abs(d1 - d2) < double.Epsilon)
- if(double.Equals(d1,d2))
- {
- continue;
- }
- else
- {
- //errors.Add(new Tuple<string, object, object>(adr, fr[cell], sheet.Cells[adr].Value));
- fileErr.WriteLine("Diff cell " + sheet.Name + "!" + adr +"\t" + d1.ToString("R15") + "\t" + d2.ToString("R15"));
- }
- }
- else
- {
- if ((fr[cell]??"").ToString() != (sheet.Cells[adr].Value??"").ToString())
- {
- fileErr.WriteLine("String? cell " + sheet.Name + "!" + adr + "\t" + (fr[cell] ?? "").ToString() + "\t" + (sheet.Cells[adr].Value??"").ToString());
- }
- //errors.Add(new Tuple<string, object, object>(adr, fr[cell], sheet.Cells[adr].Value));
- }
- }
- catch (Exception e)
- {
- fileErr.WriteLine("Exception cell " + sheet.Name + "!" + adr + "\t" + fr[cell].ToString() + "\t" + sheet.Cells[adr].Value + "\t" + e.Message);
- fileErr.WriteLine("***************************");
- fileErr.WriteLine(e.ToString());
- nErrors++;
- }
- }
- fileErr.Close();
- return nErrors.ToString();
- }
- }
- }
-}
diff --git a/EPPlusTest/CellStoreTest.cs b/EPPlusTest/CellStoreTest.cs
deleted file mode 100644
index 1d839a5..0000000
--- a/EPPlusTest/CellStoreTest.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class CellStoreTest : TestBase
- {
-
- [TestMethod]
- public void Insert1()
- {
- var ws=_pck.Workbook.Worksheets.Add("Insert1");
- LoadData(ws);
-
- ws.InsertRow(2, 1000);
- Assert.AreEqual(ws.GetValue(1002,1),"1,0");
- ws.InsertRow(1003, 1000);
- Assert.AreEqual(ws.GetValue(2003, 1), "2,0");
- ws.InsertRow(2004, 1000);
- Assert.AreEqual(ws.GetValue(3004, 1), "3,0");
- ws.InsertRow(2006, 1000);
- Assert.AreEqual(ws.GetValue(4005, 1), "4,0");
- ws.InsertRow(4500, 500);
- Assert.AreEqual(ws.GetValue(5000, 1), "499,0");
-
- ws.InsertRow(1, 1);
- Assert.AreEqual(ws.GetValue(1003, 1), "1,0");
- Assert.AreEqual(ws.GetValue(5001, 1), "499,0");
-
- ws.InsertRow(1, 15);
- Assert.AreEqual(ws.GetValue(4020, 1), "3,0");
- Assert.AreEqual(ws.GetValue(5016, 1), "499,0");
-
- }
- [TestMethod]
- public void Insert2()
- {
- var ws = _pck.Workbook.Worksheets.Add("Insert2-1");
- LoadData(ws);
-
- for (int i = 0; i < 32; i++)
- {
- ws.InsertRow(1, 1);
- }
- Assert.AreEqual(ws.GetValue(33,1),"0,0");
-
- ws = _pck.Workbook.Worksheets.Add("Insert2-2");
- LoadData(ws);
-
- for (int i = 0; i < 32; i++)
- {
- ws.InsertRow(15, 1);
- }
- Assert.AreEqual(ws.GetValue(1, 1), "0,0");
- Assert.AreEqual(ws.GetValue(47, 1), "14,0");
- }
- [TestMethod]
- public void Insert3()
- {
- var ws = _pck.Workbook.Worksheets.Add("Insert3");
- LoadData(ws);
-
- for (int i = 0; i < 500; i+=4)
- {
- ws.InsertRow(i+1, 2);
- }
- }
-
- [TestMethod]
- public void InsertRandomTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("Insert4-1");
-
- LoadData(ws, 5000);
-
- for (int i = 5000; i > 0; i-=2)
- {
- ws.InsertRow(i, 1);
- }
- }
- [TestMethod]
- public void EnumCellstore()
- {
- var ws = _pck.Workbook.Worksheets.Add("enum");
-
- LoadData(ws, 5000);
-
- var o = new CellsStoreEnumerator<object>(ws._values, 2, 1, 5, 3);
- foreach (var i in o)
- {
- Console.WriteLine(i);
- }
- }
- [TestMethod]
- public void DeleteCells()
- {
- var ws = _pck.Workbook.Worksheets.Add("Delete");
- LoadData(ws, 5000);
-
- ws.DeleteRow(2, 2);
- Assert.AreEqual("3,0",ws.GetValue(2,1));
- ws.DeleteRow(10, 10);
- Assert.AreEqual("21,0", ws.GetValue(10, 1));
- ws.DeleteRow(50, 40);
- Assert.AreEqual("101,0", ws.GetValue(50, 1));
- ws.DeleteRow(100, 100);
- Assert.AreEqual("251,0", ws.GetValue(100, 1));
- ws.DeleteRow(1, 31);
- Assert.AreEqual("43,0", ws.GetValue(1, 1));
- }
- [TestMethod]
- public void DeleteCellsFirst()
- {
- var ws = _pck.Workbook.Worksheets.Add("DeleteFirst");
- LoadData(ws, 5000);
-
- ws.DeleteRow(32, 30);
- for (int i = 1; i < 50; i++)
- {
- ws.DeleteRow(1,1);
- }
- }
- [TestMethod]
- public void DeleteInsert()
- {
- var ws = _pck.Workbook.Worksheets.Add("DeleteInsert");
- LoadData(ws, 5000);
-
- ws.DeleteRow(2, 33);
- ws.InsertRow(2, 38);
-
- for (int i = 0; i < 33; i++)
- {
- ws.SetValue(i + 2,1, i + 2);
- }
- }
- private void LoadData(ExcelWorksheet ws)
- {
- LoadData(ws, 1000);
- }
- private void LoadData(ExcelWorksheet ws, int rows, int cols=1)
- {
- for (int r = 0; r < rows; r++)
- {
- for (int c = 0; c < cols; c++)
- {
- ws.SetValue(r+1, c+1, r.ToString()+","+c.ToString());
- }
- }
- }
- [TestMethod]
- public void FillInsertTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("FillInsert");
-
- LoadData(ws, 500);
-
- var r=1;
- for(int i=1;i<=500;i++)
- {
- ws.InsertRow(r,i);
- Assert.AreEqual((i-1).ToString()+",0", ws.GetValue(r+i,1).ToString());
- r+=i+1;
- }
- }
- }
-}
diff --git a/EPPlusTest/CommentsTest.cs b/EPPlusTest/CommentsTest.cs
deleted file mode 100644
index 372a815..0000000
--- a/EPPlusTest/CommentsTest.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class CommentsTest
- {
- [Ignore]
- [TestMethod]
- public void ReadExcelComments()
- {
- var fi = new FileInfo(@"c:\temp\googleComments\Comments.excel.xlsx");
- using (var excelPackage = new ExcelPackage(fi))
- {
- var sheet1 = excelPackage.Workbook.Worksheets.First();
- Assert.AreEqual(2, sheet1.Comments.Count);
- }
- }
- [Ignore]
- [TestMethod]
- public void ReadGoogleComments()
- {
- var fi = new FileInfo(@"c:\temp\googleComments\Comments.google.xlsx");
- using (var excelPackage = new ExcelPackage(fi))
- {
- var sheet1 = excelPackage.Workbook.Worksheets.First();
- Assert.AreEqual(2, sheet1.Comments.Count);
- Assert.AreEqual("Note for column 'Address'.", sheet1.Comments[0].Text);
- }
- }
- }
-}
diff --git a/EPPlusTest/ConditionalFormatting/ConditionalFormatting.cs b/EPPlusTest/ConditionalFormatting/ConditionalFormatting.cs
deleted file mode 100644
index fdd9383..0000000
--- a/EPPlusTest/ConditionalFormatting/ConditionalFormatting.cs
+++ /dev/null
@@ -1,190 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.ConditionalFormatting;
-using System.IO;
-using OfficeOpenXml.ConditionalFormatting.Contracts;
-using System.Drawing;
-
-namespace EPPlusTest
-{
- /// <summary>
- /// Test the Conditional Formatting feature
- /// </summary>
- [TestClass]
- public class ConditionalFormatting
- {
- private TestContext testContextInstance;
- private static ExcelPackage _pck;
-
- /// <summary>
- ///Gets or sets the test context which provides
- ///information about and functionality for the current test run.
- ///</summary>
- public TestContext TestContext
- {
- get
- {
- return testContextInstance;
- }
- set
- {
- testContextInstance = value;
- }
- }
-
- #region Additional test attributes
- // You can use the following additional attributes as you write your tests:
- // Use ClassInitialize to run code before running the first test in the class
- [ClassInitialize()]
- public static void MyClassInitialize(TestContext testContext)
- {
- if (!Directory.Exists("Test"))
- {
- Directory.CreateDirectory(string.Format("Test"));
- }
-
- _pck = new ExcelPackage(new FileInfo(@"Test\ConditionalFormatting.xlsx"));
- }
-
- // Use ClassCleanup to run code after all tests in a class have run
- [ClassCleanup()]
- public static void MyClassCleanup()
- {
- _pck = null;
- }
-
- // //Use TestInitialize to run code before running each test
- // [TestInitialize()]
- // public void MyTestInitialize()
- // {
- // }
-
- //// Use TestCleanup to run code after each test has run
- // [TestCleanup()]
- // public void MyTestCleanup()
- // {
- // }
- #endregion
-
- /// <summary>
- ///
- /// </summary>
- [TestMethod]
- public void TwoColorScale()
- {
- var ws = _pck.Workbook.Worksheets.Add("ColorScale");
- ws.ConditionalFormatting.AddTwoColorScale(ws.Cells["A1:A5"]);
- ws.SetValue(1, 1, 1);
- ws.SetValue(2, 1, 2);
- ws.SetValue(3, 1, 3);
- ws.SetValue(4, 1, 4);
- ws.SetValue(5, 1, 5);
- }
-
- /// <summary>
- ///
- /// </summary>
- [TestMethod]
- [Ignore]
- public void ReadConditionalFormatting()
- {
- var pck = new ExcelPackage(new FileInfo(@"c:\temp\cf.xlsx"));
-
- var ws = pck.Workbook.Worksheets[1];
- Assert.IsTrue(ws.ConditionalFormatting.Count == 6);
- Assert.IsTrue(ws.ConditionalFormatting[0].Type==eExcelConditionalFormattingRuleType.DataBar);
-
- var cf1 = ws.ConditionalFormatting.AddEqual(ws.Cells["C3"]);
- //cf1.Formula = "TRUE";
- var cf2 = ws.Cells["C8:C12"].ConditionalFormatting.AddExpression();
- var cf3 = ws.Cells["d12:D22,H12:H22"].ConditionalFormatting.AddFourIconSet(eExcelconditionalFormatting4IconsSetType.RedToBlack);
- pck.SaveAs(new FileInfo(@"c:\temp\cf2.xlsx"));
- }
- /// <summary>
- ///
- /// </summary>
- [TestMethod]
- [Ignore]
- public void ReadConditionalFormattingError()
- {
- var pck = new ExcelPackage(new FileInfo(@"c:\temp\CofCTemplate.xlsx"));
-
- var ws = pck.Workbook.Worksheets[1];
- pck.SaveAs(new FileInfo(@"c:\temp\cf2.xlsx"));
- }
- /// <summary>
- ///
- /// </summary>
- [TestMethod]
- public void TwoBackColor()
- {
- var ws = _pck.Workbook.Worksheets.Add("TwoBackColor");
- IExcelConditionalFormattingEqual condition1 = ws.ConditionalFormatting.AddEqual(ws.Cells["A1"]);
- condition1.StopIfTrue = true;
- condition1.Priority = 1;
- condition1.Formula = "TRUE";
- condition1.Style.Fill.BackgroundColor.Color = Color.Green;
- IExcelConditionalFormattingEqual condition2 = ws.ConditionalFormatting.AddEqual(ws.Cells["A2"]);
- condition2.StopIfTrue = true;
- condition2.Priority = 2;
- condition2.Formula = "FALSE";
- condition2.Style.Fill.BackgroundColor.Color = Color.Red;
- }
- [TestMethod]
- public void Databar()
- {
- var ws = _pck.Workbook.Worksheets.Add("Databar");
- var cf = ws.ConditionalFormatting.AddDatabar(ws.Cells["A1:A5"], Color.BlueViolet);
- ws.SetValue(1, 1, 1);
- ws.SetValue(2, 1, 2);
- ws.SetValue(3, 1, 3);
- ws.SetValue(4, 1, 4);
- ws.SetValue(5, 1, 5);
- }
- [TestMethod]
- public void IconSet()
- {
- var ws = _pck.Workbook.Worksheets.Add("IconSet");
- var cf = ws.ConditionalFormatting.AddThreeIconSet(ws.Cells["A1:A3"], eExcelconditionalFormatting3IconsSetType.Symbols);
- ws.SetValue(1, 1, 1);
- ws.SetValue(2, 1, 2);
- ws.SetValue(3, 1, 3);
-
- var cf4 = ws.ConditionalFormatting.AddFourIconSet(ws.Cells["B1:B4"], eExcelconditionalFormatting4IconsSetType.Rating);
- cf4.Icon1.Type = eExcelConditionalFormattingValueObjectType.Formula;
- cf4.Icon1.Formula = "0";
- cf4.Icon2.Type = eExcelConditionalFormattingValueObjectType.Formula;
- cf4.Icon2.Formula = "1/3";
- cf4.Icon3.Type = eExcelConditionalFormattingValueObjectType.Formula;
- cf4.Icon3.Formula = "2/3";
- ws.SetValue(1, 2, 1);
- ws.SetValue(2, 2, 2);
- ws.SetValue(3, 2, 3);
- ws.SetValue(4, 2, 4);
-
- var cf5 = ws.ConditionalFormatting.AddFiveIconSet(ws.Cells["C1:C5"],eExcelconditionalFormatting5IconsSetType.Quarters);
- cf5.Icon1.Type = eExcelConditionalFormattingValueObjectType.Num;
- cf5.Icon1.Value = 1;
- cf5.Icon2.Type = eExcelConditionalFormattingValueObjectType.Num;
- cf5.Icon2.Value = 2;
- cf5.Icon3.Type = eExcelConditionalFormattingValueObjectType.Num;
- cf5.Icon3.Value = 3;
- cf5.Icon4.Type = eExcelConditionalFormattingValueObjectType.Num;
- cf5.Icon4.Value = 4;
- cf5.Icon5.Type = eExcelConditionalFormattingValueObjectType.Num;
- cf5.Icon5.Value = 5;
- cf5.ShowValue = false;
- cf5.Reverse = true;
-
- ws.SetValue(1, 3, 1);
- ws.SetValue(2, 3, 2);
- ws.SetValue(3, 3, 3);
- ws.SetValue(4, 3, 4);
- ws.SetValue(5, 3, 5);
- }
- }
-}
\ No newline at end of file
diff --git a/EPPlusTest/DTS_FailingTests.cs b/EPPlusTest/DTS_FailingTests.cs
deleted file mode 100644
index 499b27b..0000000
--- a/EPPlusTest/DTS_FailingTests.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class DTS_FailingTests
- {
-
- [TestMethod]
- public void DeleteWorksheetWithReferencedImage()
- {
- var ms = new MemoryStream();
- using (var pck = new ExcelPackage())
- {
- var ws = pck.Workbook.Worksheets.Add("original");
- ws.Drawings.AddPicture("Pic1", Properties.Resources.Test1);
- pck.Workbook.Worksheets.Copy("original", "copy");
- pck.SaveAs(ms);
- }
- ms.Position = 0;
-
- using (var pck = new ExcelPackage(ms))
- {
- var ws = pck.Workbook.Worksheets["original"];
- pck.Workbook.Worksheets.Delete(ws);
- pck.Save();
- }
- }
-
- [TestMethod]
- public void CopyAndDeleteWorksheetWithImage()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var ws = pck.Workbook.Worksheets.Add("original");
- ws.Drawings.AddPicture("Pic1", Properties.Resources.Test1);
- pck.Workbook.Worksheets.Copy("original", "copy");
- pck.Workbook.Worksheets.Delete(ws);
- pck.Save();
- }
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/CustomValidationTests.cs b/EPPlusTest/DataValidation/CustomValidationTests.cs
deleted file mode 100644
index d7521e8..0000000
--- a/EPPlusTest/DataValidation/CustomValidationTests.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class CustomValidationTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod]
- public void CustomValidation_FormulaIsSet()
- {
- // Act
- var validation = _sheet.DataValidations.AddCustomValidation("A1");
-
- // Assert
- Assert.IsNotNull(validation.Formula);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void CustomValidation_ShouldThrowExceptionIfFormulaIsTooLong()
- {
- // Arrange
- var sb = new StringBuilder();
- for (var x = 0; x < 257; x++) sb.Append("x");
-
- // Act
- var validation = _sheet.DataValidations.AddCustomValidation("A1");
- validation.Formula.ExcelFormula = sb.ToString();
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/DataValidationTests.cs b/EPPlusTest/DataValidation/DataValidationTests.cs
deleted file mode 100644
index ffd1c9a..0000000
--- a/EPPlusTest/DataValidation/DataValidationTests.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.DataValidation;
-using System.IO;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class DataValidationTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetOperatorFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "greaterThanOrEqual", "1");
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual(ExcelDataValidationOperator.greaterThanOrEqual, validation.Operator);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void DataValidations_ShouldThrowIfOperatorIsEqualAndFormula1IsEmpty()
- {
- var validations = _sheet.DataValidations.AddIntegerValidation("A1");
- validations.Operator = ExcelDataValidationOperator.equal;
- validations.Validate();
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetShowErrorMessageFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "1", true, false);
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.IsTrue(validation.ShowErrorMessage ?? false);
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetShowInputMessageFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "1", false, true);
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.IsTrue(validation.ShowInputMessage ?? false);
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetPromptFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "1", "Prompt", "PromptTitle", "Error", "ErrorTitle");
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual("Prompt", validation.Prompt);
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetPromptTitleFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "1", "Prompt", "PromptTitle", "Error", "ErrorTitle");
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual("PromptTitle", validation.PromptTitle);
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetErrorFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "1", "Prompt", "PromptTitle", "Error", "ErrorTitle");
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual("Error", validation.Error);
- }
-
- [TestMethod]
- public void DataValidations_ShouldSetErrorTitleFromExistingXml()
- {
- // Arrange
- LoadXmlTestData("A1", "whole", "1", "Prompt", "PromptTitle", "Error", "ErrorTitle");
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual("ErrorTitle", validation.ErrorTitle);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void DataValidations_ShouldThrowIfOperatorIsBetweenAndFormula2IsEmpty()
- {
- var validation = _sheet.DataValidations.AddIntegerValidation("A1");
- validation.Formula.Value = 1;
- validation.Operator = ExcelDataValidationOperator.between;
- validation.Validate();
- }
-
- [TestMethod]
- public void DataValidations_ShouldAcceptOneItemOnly()
- {
- var validation = _sheet.DataValidations.AddListValidation("A1");
- validation.Formula.Values.Add("1");
- validation.Validate();
- }
-
- [TestMethod]
- public void ExcelDataValidation_ShouldReplaceLastPartInWholeColumnRangeWithMaxNumberOfRowsOneColumn()
- {
- // Act
- var validation = _sheet.DataValidations.AddIntegerValidation("A:A");
-
- // Assert
- Assert.AreEqual("A1:A" + ExcelPackage.MaxRows.ToString(), validation.Address.Address);
- }
-
- [TestMethod]
- public void ExcelDataValidation_ShouldReplaceLastPartInWholeColumnRangeWithMaxNumberOfRowsDifferentColumns()
- {
- // Act
- var validation = _sheet.DataValidations.AddIntegerValidation("A:B");
-
- // Assert
- Assert.AreEqual(string.Format("A1:B{0}", ExcelPackage.MaxRows), validation.Address.Address);
- }
-
- }
-}
diff --git a/EPPlusTest/DataValidation/DecimaDataValidationTests.cs b/EPPlusTest/DataValidation/DecimaDataValidationTests.cs
deleted file mode 100644
index 372bc6f..0000000
--- a/EPPlusTest/DataValidation/DecimaDataValidationTests.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-using OfficeOpenXml.DataValidation.Contracts;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class DecimaDataValidationTests : ValidationTestBase
- {
- private IExcelDataValidationDecimal _validation;
-
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- _validation = _package.Workbook.Worksheets[1].DataValidations.AddDecimalValidation("A1");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- _validation = null;
- }
-
- [TestMethod]
- public void DecimalDataValidation_Formula1IsSet()
- {
- Assert.IsNotNull(_validation.Formula);
- }
-
- [TestMethod]
- public void DecimalDataValidation_Formula2IsSet()
- {
- Assert.IsNotNull(_validation.Formula2);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/ExcelTimeTests.cs b/EPPlusTest/DataValidation/ExcelTimeTests.cs
deleted file mode 100644
index 3bec65c..0000000
--- a/EPPlusTest/DataValidation/ExcelTimeTests.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class ExcelTimeTests
- {
- private ExcelTime _time;
- private readonly decimal SecondsPerHour = 3600;
- // private readonly decimal HoursPerDay = 24;
- private readonly decimal SecondsPerDay = 3600 * 24;
-
- private decimal Round(decimal value)
- {
- return Math.Round(value, ExcelTime.NumberOfDecimals);
- }
-
- [TestInitialize]
- public void Setup()
- {
- _time = new ExcelTime();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _time = null;
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void ExcelTimeTests_ConstructorWithValue_ShouldThrowIfValueIsLessThan0()
- {
- new ExcelTime(-1);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void ExcelTimeTests_ConstructorWithValue_ShouldThrowIfValueIsEqualToOrGreaterThan1()
- {
- new ExcelTime(1);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelTimeTests_Hour_ShouldThrowIfNegativeValue()
- {
- _time.Hour = -1;
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelTimeTests_Minute_ShouldThrowIfNegativeValue()
- {
- _time.Minute = -1;
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelTimeTests_Minute_ShouldThrowIValueIsGreaterThan59()
- {
- _time.Minute = 60;
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelTimeTests_Second_ShouldThrowIfNegativeValue()
- {
- _time.Second = -1;
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelTimeTests_Second_ShouldThrowIValueIsGreaterThan59()
- {
- _time.Second = 60;
- }
-
- [TestMethod]
- public void ExcelTimeTests_ToExcelTime_HourIsSet()
- {
- // Act
- _time.Hour = 1;
-
- // Assert
- Assert.AreEqual(Round(SecondsPerHour/SecondsPerDay), _time.ToExcelTime());
- }
-
- [TestMethod]
- public void ExcelTimeTests_ToExcelTime_MinuteIsSet()
- {
- // Arrange
- decimal expected = SecondsPerHour + (20M * 60M);
- // Act
- _time.Hour = 1;
- _time.Minute = 20;
-
- // Assert
- Assert.AreEqual(Round(expected/SecondsPerDay), _time.ToExcelTime());
- }
-
- [TestMethod]
- public void ExcelTimeTests_ToExcelTime_SecondIsSet()
- {
- // Arrange
- decimal expected = SecondsPerHour + (20M * 60M) + 10M;
- // Act
- _time.Hour = 1;
- _time.Minute = 20;
- _time.Second = 10;
-
- // Assert
- Assert.AreEqual(Round(expected / SecondsPerDay), _time.ToExcelTime());
- }
-
- [TestMethod]
- public void ExcelTimeTests_ConstructorWithValue_ShouldSetHour()
- {
- // Arrange
- decimal value = 3660M/(decimal)SecondsPerDay;
-
- // Act
- var time = new ExcelTime(value);
-
- // Assert
- Assert.AreEqual(1, time.Hour);
- }
-
- [TestMethod]
- public void ExcelTimeTests_ConstructorWithValue_ShouldSetMinute()
- {
- // Arrange
- decimal value = 3660M / (decimal)SecondsPerDay;
-
- // Act
- var time = new ExcelTime(value);
-
- // Assert
- Assert.AreEqual(1, time.Minute);
- }
-
- [TestMethod]
- public void ExcelTimeTests_ConstructorWithValue_ShouldSetSecond()
- {
- // Arrange
- decimal value = 3662M / (decimal)SecondsPerDay;
-
- // Act
- var time = new ExcelTime(value);
-
- // Assert
- Assert.AreEqual(2, time.Second);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/Formulas/CustomFormulaTests.cs b/EPPlusTest/DataValidation/Formulas/CustomFormulaTests.cs
deleted file mode 100644
index 4fb4742..0000000
--- a/EPPlusTest/DataValidation/Formulas/CustomFormulaTests.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-
-namespace EPPlusTest.DataValidation.Formulas
-{
- [TestClass]
- public class CustomFormulaTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- _dataValidationNode = null;
- }
-
- [TestMethod]
- public void CustomFormula_FormulasFormulaIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "decimal", "A1");
-
- // Act
- var validation = new ExcelDataValidationCustom(_sheet, "A1", ExcelDataValidationType.Custom, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual("A1", validation.Formula.ExcelFormula);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/Formulas/DateTimeFormulaTests.cs b/EPPlusTest/DataValidation/Formulas/DateTimeFormulaTests.cs
deleted file mode 100644
index 357d897..0000000
--- a/EPPlusTest/DataValidation/Formulas/DateTimeFormulaTests.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-using OfficeOpenXml;
-
-namespace EPPlusTest.DataValidation.Formulas
-{
- [TestClass]
- public class DateTimeFormulaTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- _dataValidationNode = null;
- }
-
- [TestMethod]
- public void DateTimeFormula_FormulaValueIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- var date = DateTime.Parse("2011-01-08");
- var dateAsString = date.ToOADate().ToString(_cultureInfo);
- LoadXmlTestData("A1", "decimal", dateAsString);
- // Act
- var validation = new ExcelDataValidationDateTime(_sheet, "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual(date, validation.Formula.Value);
- }
-
- [TestMethod]
- public void DateTimeFormula_FormulasFormulaIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- var date = DateTime.Parse("2011-01-08");
- LoadXmlTestData("A1", "decimal", "A1");
-
- // Act
- var validation = new ExcelDataValidationDateTime(_sheet, "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual("A1", validation.Formula.ExcelFormula);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/Formulas/DecimalFormulaTests.cs b/EPPlusTest/DataValidation/Formulas/DecimalFormulaTests.cs
deleted file mode 100644
index 217291b..0000000
--- a/EPPlusTest/DataValidation/Formulas/DecimalFormulaTests.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation.Formulas;
-using System.Xml;
-using OfficeOpenXml.DataValidation;
-
-namespace EPPlusTest.DataValidation.Formulas
-{
- [TestClass]
- public class DecimalFormulaTests : ValidationTestBase
- {
-
-
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- _dataValidationNode = null;
- }
-
- [TestMethod]
- public void DecimalFormula_FormulaValueIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "decimal", "1.3");
- // Act
- var validation = new ExcelDataValidationDecimal(_sheet, "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);
- Assert.AreEqual(1.3D, validation.Formula.Value);
- }
-
- [TestMethod]
- public void DecimalFormula_FormulasFormulaIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "decimal", "A1");
-
- // Act
- var validation = new ExcelDataValidationDecimal(_sheet, "A1", ExcelDataValidationType.Decimal, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual("A1", validation.Formula.ExcelFormula);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/Formulas/IntegerFormulaTests.cs b/EPPlusTest/DataValidation/Formulas/IntegerFormulaTests.cs
deleted file mode 100644
index 649ff10..0000000
--- a/EPPlusTest/DataValidation/Formulas/IntegerFormulaTests.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-
-namespace EPPlusTest.DataValidation.Formulas
-{
- [TestClass]
- public class IntegerFormulaTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- _dataValidationNode = null;
- }
-
- [TestMethod]
- public void IntegerFormula_FormulaValueIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "decimal", "1");
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
- Assert.AreEqual(1, validation.Formula.Value);
- }
-
- [TestMethod]
- public void IntegerFormula_FormulasFormulaIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "decimal", "A1");
-
- // Act
- var validation = new ExcelDataValidationInt(_sheet, "A1", ExcelDataValidationType.Whole, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual("A1", validation.Formula.ExcelFormula);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/Formulas/ListFormulaTests.cs b/EPPlusTest/DataValidation/Formulas/ListFormulaTests.cs
deleted file mode 100644
index 3c6f6af..0000000
--- a/EPPlusTest/DataValidation/Formulas/ListFormulaTests.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-using System.Collections;
-
-namespace EPPlusTest.DataValidation.Formulas
-{
- [TestClass]
- public class ListFormulaTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- _dataValidationNode = null;
- }
-
- [TestMethod]
- public void ListFormula_FormulaValueIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "list", "\"1,2\"");
- // Act
- var validation = new ExcelDataValidationList(_sheet, "A1", ExcelDataValidationType.List, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual(2, validation.Formula.Values.Count);
- }
-
- [TestMethod]
- public void ListFormula_FormulaValueIsSetFromXmlNodeInConstructorOrderIsCorrect()
- {
- // Arrange
- LoadXmlTestData("A1", "list", "\"1,2\"");
- // Act
- var validation = new ExcelDataValidationList(_sheet, "A1", ExcelDataValidationType.List, _dataValidationNode, _namespaceManager);
- // Assert
- CollectionAssert.AreEquivalent(new List<string>{ "1", "2"}, (ICollection)validation.Formula.Values);
- }
-
- [TestMethod]
- public void ListFormula_FormulasExcelFormulaIsSetFromXmlNodeInConstructor()
- {
- // Arrange
- LoadXmlTestData("A1", "list", "A1");
- // Act
- var validation = new ExcelDataValidationList(_sheet, "A1", ExcelDataValidationType.List, _dataValidationNode, _namespaceManager);
- // Assert
- Assert.AreEqual("A1", validation.Formula.ExcelFormula);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/Formulas/TimeFormulaTests.cs b/EPPlusTest/DataValidation/Formulas/TimeFormulaTests.cs
deleted file mode 100644
index 14a3232..0000000
--- a/EPPlusTest/DataValidation/Formulas/TimeFormulaTests.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-
-namespace EPPlusTest.DataValidation.Formulas
-{
- [TestClass]
- public class TimeFormulaTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod]
- public void TimeFormula_ValueIsSetFromConstructorValidateHour()
- {
- // Arrange
- var time = new ExcelTime(0.675M);
- LoadXmlTestData("A1", "time", "0.675");
-
- // Act
- var formula = new ExcelDataValidationTime(_sheet, "A1", ExcelDataValidationType.Time, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual(time.Hour, formula.Formula.Value.Hour);
- }
-
- [TestMethod]
- public void TimeFormula_ValueIsSetFromConstructorValidateMinute()
- {
- // Arrange
- var time = new ExcelTime(0.395M);
- LoadXmlTestData("A1", "time", "0.395");
-
- // Act
- var formula = new ExcelDataValidationTime(_sheet, "A1", ExcelDataValidationType.Time, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual(time.Minute, formula.Formula.Value.Minute);
- }
-
- [TestMethod]
- public void TimeFormula_ValueIsSetFromConstructorValidateSecond()
- {
- // Arrange
- var time = new ExcelTime(0.812M);
- LoadXmlTestData("A1", "time", "0.812");
-
- // Act
- var formula = new ExcelDataValidationTime(_sheet, "A1", ExcelDataValidationType.Time, _dataValidationNode, _namespaceManager);
-
- // Assert
- Assert.AreEqual(time.Second.Value, formula.Formula.Value.Second.Value);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/IntegrationTests/IntegrationTests.cs b/EPPlusTest/DataValidation/IntegrationTests/IntegrationTests.cs
deleted file mode 100644
index fa0acb7..0000000
--- a/EPPlusTest/DataValidation/IntegrationTests/IntegrationTests.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-using System.IO;
-using OfficeOpenXml;
-
-namespace EPPlusTest.DataValidation.IntegrationTests
-{
- /// <summary>
- /// Remove the Ignore attributes from the testmethods if you want to run any of these tests
- /// </summary>
- [TestClass]
- public class IntegrationTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod, Ignore]
- public void DataValidations_AddOneValidationOfTypeWhole()
- {
- _sheet.Cells["B1"].Value = 2;
- var validation = _sheet.DataValidations.AddIntegerValidation("A1");
- validation.ShowErrorMessage = true;
- validation.ErrorStyle = ExcelDataValidationWarningStyle.stop;
- validation.ErrorTitle = "Invalid value was entered";
- validation.PromptTitle = "Enter value here";
- validation.Operator = ExcelDataValidationOperator.greaterThan;
- //validation.Value.Value = 3;
- validation.Formula.ExcelFormula = "B1";
-
- _package.SaveAs(new FileInfo(GetTestOutputPath("AddOneValidationOfTypeWhole.xlsx")));
- }
- [TestMethod, Ignore]
- public void DataValidations_AddOneValidationOfTypeDecimal()
- {
- var validation = _sheet.DataValidations.AddDecimalValidation("A1");
- validation.ShowErrorMessage = true;
- validation.ErrorStyle = ExcelDataValidationWarningStyle.stop;
- validation.ErrorTitle = "Invalid value was entered";
- validation.Error = "Value must be greater than 1.4";
- validation.PromptTitle = "Enter value here";
- validation.Prompt = "Enter a value that is greater than 1.4";
- validation.ShowInputMessage = true;
- validation.Operator = ExcelDataValidationOperator.greaterThan;
- validation.Formula.Value = 1.4;
-
- _package.SaveAs(new FileInfo(GetTestOutputPath("AddOneValidationOfTypeDecimal.xlsx")));
- }
-
- [TestMethod]
- public void DataValidations_AddOneValidationOfTypeListOfTypeList()
- {
- var validation = _sheet.DataValidations.AddListValidation("A:A");
- validation.ShowErrorMessage = true;
- validation.ShowInputMessage = true;
- validation.Formula.Values.Add("1");
- validation.Formula.Values.Add("2");
- validation.Formula.Values.Add("3");
- validation.Validate();
-
- _package.SaveAs(new FileInfo(GetTestOutputPath("AddOneValidationOfTypeList.xlsx")));
- }
-
- [TestMethod]
- public void DataValidations_AddOneValidationOfTypeListOfTypeTime()
- {
- var validation = _sheet.DataValidations.AddTimeValidation("A1");
- validation.ShowErrorMessage = true;
- validation.ShowInputMessage = true;
- validation.Formula.Value.Hour = 14;
- validation.Formula.Value.Minute = 30;
- validation.Operator = ExcelDataValidationOperator.greaterThan;
- validation.Prompt = "Enter a time greater than 14:30";
- validation.Error = "Invalid time was entered";
- validation.Validate();
-
- _package.SaveAs(new FileInfo(GetTestOutputPath("AddOneValidationOfTypeTime.xlsx")));
- }
-
- [TestMethod, Ignore]
- public void DataValidations_ReadExistingWorkbookWithDataValidations()
- {
- using (var package = new ExcelPackage(new FileInfo(GetTestOutputPath("DVTest.xlsx"))))
- {
- Assert.AreEqual(3, package.Workbook.Worksheets[1].DataValidations.Count);
- }
- }
-
- //[TestMethod]
- //public void Bug_OpenOffice()
- //{
- // var xlsPath = GetTestOutputPath("OpenOffice.xlsx");
- // var newFile = new FileInfo(xlsPath);
- // if( newFile.Exists)
- // {
- // newFile.Delete();
- // //ensures we create a new workbook
- // newFile = new FileInfo(xlsPath);
-
- // }
- // using(var package = new ExcelPackage(newFile))
- // {
- // // add a new worksheet to the empty workbook
- // var worksheet = package.Workbook.Worksheets.Add("Inventory");
- // // Add the headers
- // worksheet.Cells[1, 1].Value = "ID";
- // worksheet.Cells[1, 2].Value = "Product";
- //// worksheet.Cells[1, 3].Value = "Quantity";
- // worksheet.Cells[1, 4].Value = "Price";
-
- // worksheet.Cells[1, 5].Value = "Value";
-
- // worksheet.Column(1).Width = 15;
- // worksheet.Column(2).Width = 12;
- // worksheet.Column(3).Width = 12;
-
- // worksheet.View.PageLayoutView = true;
-
- // package.Workbook.Properties.Title = "Invertory";
- // package.Workbook.Properties.Author = "Jan Källman";
- // package.Save();
- // }
-
- }
-}
diff --git a/EPPlusTest/DataValidation/ListDataValidationTests.cs b/EPPlusTest/DataValidation/ListDataValidationTests.cs
deleted file mode 100644
index 0a87245..0000000
--- a/EPPlusTest/DataValidation/ListDataValidationTests.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation.Formulas.Contracts;
-using OfficeOpenXml.DataValidation;
-using OfficeOpenXml.DataValidation.Contracts;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class ListDataValidationTests : ValidationTestBase
- {
- private IExcelDataValidationList _validation;
-
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- _validation = _sheet.Workbook.Worksheets[1].DataValidations.AddListValidation("A1");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod]
- public void ListDataValidation_FormulaIsSet()
- {
- Assert.IsNotNull(_validation.Formula);
- }
-
- [TestMethod]
- public void ListDataValidation_WhenOneItemIsAddedCountIs1()
- {
- // Act
- _validation.Formula.Values.Add("test");
-
- // Assert
- Assert.AreEqual(1, _validation.Formula.Values.Count);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ListDataValidation_ShouldThrowWhenNoFormulaOrValueIsSet()
- {
- _validation.Validate();
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/RangeBaseTests.cs b/EPPlusTest/DataValidation/RangeBaseTests.cs
deleted file mode 100644
index a736c23..0000000
--- a/EPPlusTest/DataValidation/RangeBaseTests.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class RangeBaseTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod]
- public void RangeBase_AddIntegerValidation_ValidationIsAdded()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddIntegerDataValidation();
-
- // Assert
- Assert.AreEqual(1, _sheet.DataValidations.Count);
- }
-
- [TestMethod]
- public void RangeBase_AddIntegerValidation_AddressIsCorrect()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddIntegerDataValidation();
-
- // Assert
- Assert.AreEqual("A1:A2", _sheet.DataValidations[0].Address.Address);
- }
-
- [TestMethod]
- public void RangeBase_AddDecimalValidation_ValidationIsAdded()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddDecimalDataValidation();
-
- // Assert
- Assert.AreEqual(1, _sheet.DataValidations.Count);
- }
-
- [TestMethod]
- public void RangeBase_AddDecimalValidation_AddressIsCorrect()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddDecimalDataValidation();
-
- // Assert
- Assert.AreEqual("A1:A2", _sheet.DataValidations[0].Address.Address);
- }
-
- [TestMethod]
- public void RangeBase_AddTextLengthValidation_ValidationIsAdded()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddTextLengthDataValidation();
-
- // Assert
- Assert.AreEqual(1, _sheet.DataValidations.Count);
- }
-
- [TestMethod]
- public void RangeBase_AddTextLengthValidation_AddressIsCorrect()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddTextLengthDataValidation();
-
- // Assert
- Assert.AreEqual("A1:A2", _sheet.DataValidations[0].Address.Address);
- }
-
- [TestMethod]
- public void RangeBase_AddDateTimeValidation_ValidationIsAdded()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddDateTimeDataValidation();
-
- // Assert
- Assert.AreEqual(1, _sheet.DataValidations.Count);
- }
-
- [TestMethod]
- public void RangeBase_AddDateTimeValidation_AddressIsCorrect()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddDateTimeDataValidation();
-
- // Assert
- Assert.AreEqual("A1:A2", _sheet.DataValidations[0].Address.Address);
- }
-
- [TestMethod]
- public void RangeBase_AddListValidation_ValidationIsAdded()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddListDataValidation();
-
- // Assert
- Assert.AreEqual(1, _sheet.DataValidations.Count);
- }
-
- [TestMethod]
- public void RangeBase_AddListValidation_AddressIsCorrect()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddListDataValidation();
-
- // Assert
- Assert.AreEqual("A1:A2", _sheet.DataValidations[0].Address.Address);
- }
-
- [TestMethod]
- public void RangeBase_AdTimeValidation_ValidationIsAdded()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddTimeDataValidation();
-
- // Assert
- Assert.AreEqual(1, _sheet.DataValidations.Count);
- }
-
- [TestMethod]
- public void RangeBase_AddTimeValidation_AddressIsCorrect()
- {
- // Act
- _sheet.Cells["A1:A2"].DataValidation.AddTimeDataValidation();
-
- // Assert
- Assert.AreEqual("A1:A2", _sheet.DataValidations[0].Address.Address);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/ValidationCollectionTests.cs b/EPPlusTest/DataValidation/ValidationCollectionTests.cs
deleted file mode 100644
index 616585a..0000000
--- a/EPPlusTest/DataValidation/ValidationCollectionTests.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.DataValidation;
-
-namespace EPPlusTest.DataValidation
-{
- [TestClass]
- public class ValidationCollectionTests : ValidationTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- SetupTestData();
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- CleanupTestData();
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void ExcelDataValidationCollection_AddDecimal_ShouldThrowWhenAddressIsNullOrEmpty()
- {
- // Act
- _sheet.DataValidations.AddDecimalValidation(string.Empty);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelDataValidationCollection_AddDecimal_ShouldThrowWhenNewValidationCollidesWithExisting()
- {
- // Act
- _sheet.DataValidations.AddDecimalValidation("A1");
- _sheet.DataValidations.AddDecimalValidation("A1");
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelDataValidationCollection_AddInteger_ShouldThrowWhenNewValidationCollidesWithExisting()
- {
- // Act
- _sheet.DataValidations.AddIntegerValidation("A1");
- _sheet.DataValidations.AddIntegerValidation("A1");
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelDataValidationCollection_AddTextLength_ShouldThrowWhenNewValidationCollidesWithExisting()
- {
- // Act
- _sheet.DataValidations.AddTextLengthValidation("A1");
- _sheet.DataValidations.AddTextLengthValidation("A1");
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ExcelDataValidationCollection_AddDateTime_ShouldThrowWhenNewValidationCollidesWithExisting()
- {
- // Act
- _sheet.DataValidations.AddDateTimeValidation("A1");
- _sheet.DataValidations.AddDateTimeValidation("A1");
- }
-
- [TestMethod]
- public void ExcelDataValidationCollection_Index_ShouldReturnItemAtIndex()
- {
- // Arrange
- _sheet.DataValidations.AddDateTimeValidation("A1");
- _sheet.DataValidations.AddDateTimeValidation("A2");
- _sheet.DataValidations.AddDateTimeValidation("B1");
-
- // Act
- var result = _sheet.DataValidations[1];
-
- // Assert
- Assert.AreEqual("A2", result.Address.Address);
- }
-
- [TestMethod]
- public void ExcelDataValidationCollection_FindAll_ShouldReturnValidationInColumnAonly()
- {
- // Arrange
- _sheet.DataValidations.AddDateTimeValidation("A1");
- _sheet.DataValidations.AddDateTimeValidation("A2");
- _sheet.DataValidations.AddDateTimeValidation("B1");
-
- // Act
- var result = _sheet.DataValidations.FindAll(x => x.Address.Address.StartsWith("A"));
-
- // Assert
- Assert.AreEqual(2, result.Count());
-
- }
-
- [TestMethod]
- public void ExcelDataValidationCollection_Find_ShouldReturnFirstMatchOnly()
- {
- // Arrange
- _sheet.DataValidations.AddDateTimeValidation("A1");
- _sheet.DataValidations.AddDateTimeValidation("A2");
-
- // Act
- var result = _sheet.DataValidations.Find(x => x.Address.Address.StartsWith("A"));
-
- // Assert
- Assert.AreEqual("A1", result.Address.Address);
-
- }
-
- [TestMethod]
- public void ExcelDataValidationCollection_Clear_ShouldBeEmpty()
- {
- // Arrange
- _sheet.DataValidations.AddDateTimeValidation("A1");
-
- // Act
- _sheet.DataValidations.Clear();
-
- // Assert
- Assert.AreEqual(0, _sheet.DataValidations.Count);
-
- }
-
- [TestMethod]
- public void ExcelDataValidationCollection_RemoveAll_ShouldRemoveMatchingEntries()
- {
- // Arrange
- _sheet.DataValidations.AddIntegerValidation("A1");
- _sheet.DataValidations.AddIntegerValidation("A2");
- _sheet.DataValidations.AddIntegerValidation("B1");
-
- // Act
- _sheet.DataValidations.RemoveAll(x => x.Address.Address.StartsWith("B"));
-
- // Assert
- Assert.AreEqual(2, _sheet.DataValidations.Count);
- }
- }
-}
diff --git a/EPPlusTest/DataValidation/ValidationTestBase.cs b/EPPlusTest/DataValidation/ValidationTestBase.cs
deleted file mode 100644
index 8b35f1c..0000000
--- a/EPPlusTest/DataValidation/ValidationTestBase.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.IO;
-using OfficeOpenXml.DataValidation;
-using System.Xml;
-using System.Globalization;
-
-namespace EPPlusTest.DataValidation
-{
- public abstract class ValidationTestBase
- {
- protected ExcelPackage _package;
- protected ExcelWorksheet _sheet;
- protected XmlNode _dataValidationNode;
- protected XmlNamespaceManager _namespaceManager;
- protected CultureInfo _cultureInfo;
-
- public void SetupTestData()
- {
- _package = new ExcelPackage();
- _sheet = _package.Workbook.Worksheets.Add("test");
- _cultureInfo = new CultureInfo("en-US");
- }
-
- public void CleanupTestData()
- {
- _package = null;
- _sheet = null;
- _namespaceManager = null;
- }
-
- protected string GetTestOutputPath(string fileName)
- {
- return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName);
- }
-
- protected void SaveTestOutput(string fileName)
- {
- var path = GetTestOutputPath(fileName);
- if (File.Exists(path))
- {
- File.Delete(path);
- }
- _package.SaveAs(new FileInfo(path));
- }
-
- protected void LoadXmlTestData(string address, string validationType, string formula1Value)
- {
- var xmlDoc = new XmlDocument();
- _namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
- _namespaceManager.AddNamespace("d", "urn:a");
- var sb = new StringBuilder();
- sb.AppendFormat("<dataValidation xmlns:d=\"urn:a\" type=\"{0}\" sqref=\"{1}\">", validationType, address);
- sb.AppendFormat("<d:formula1>{0}</d:formula1>", formula1Value);
- sb.Append("</dataValidation>");
- xmlDoc.LoadXml(sb.ToString());
- _dataValidationNode = xmlDoc.DocumentElement;
- }
-
- protected void LoadXmlTestData(string address, string validationType, string operatorName, string formula1Value)
- {
- var xmlDoc = new XmlDocument();
- _namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
- _namespaceManager.AddNamespace("d", "urn:a");
- var sb = new StringBuilder();
- sb.AppendFormat("<dataValidation xmlns:d=\"urn:a\" type=\"{0}\" sqref=\"{1}\" operator=\"{2}\">", validationType, address, operatorName);
- sb.AppendFormat("<d:formula1>{0}</d:formula1>", formula1Value);
- sb.Append("</dataValidation>");
- xmlDoc.LoadXml(sb.ToString());
- _dataValidationNode = xmlDoc.DocumentElement;
- }
-
- protected void LoadXmlTestData(string address, string validationType, string formula1Value, bool showErrorMsg, bool showInputMsg)
- {
- var xmlDoc = new XmlDocument();
- _namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
- _namespaceManager.AddNamespace("d", "urn:a");
- var sb = new StringBuilder();
- sb.AppendFormat("<dataValidation xmlns:d=\"urn:a\" type=\"{0}\" sqref=\"{1}\" ", validationType, address);
- sb.AppendFormat(" showErrorMessage=\"{0}\" showInputMessage=\"{1}\">", showErrorMsg ? 1 : 0, showInputMsg ? 1 : 0);
- sb.AppendFormat("<d:formula1>{0}</d:formula1>", formula1Value);
- sb.Append("</dataValidation>");
- xmlDoc.LoadXml(sb.ToString());
- _dataValidationNode = xmlDoc.DocumentElement;
- }
-
- protected void LoadXmlTestData(string address, string validationType, string formula1Value, string prompt, string promptTitle, string error, string errorTitle)
- {
- var xmlDoc = new XmlDocument();
- _namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
- _namespaceManager.AddNamespace("d", "urn:a");
- var sb = new StringBuilder();
- sb.AppendFormat("<dataValidation xmlns:d=\"urn:a\" type=\"{0}\" sqref=\"{1}\"", validationType, address);
- sb.AppendFormat(" prompt=\"{0}\" promptTitle=\"{1}\"", prompt, promptTitle);
- sb.AppendFormat(" error=\"{0}\" errorTitle=\"{1}\">", error, errorTitle);
- sb.AppendFormat("<d:formula1>{0}</d:formula1>", formula1Value);
- sb.Append("</dataValidation>");
- xmlDoc.LoadXml(sb.ToString());
- _dataValidationNode = xmlDoc.DocumentElement;
- }
-
- }
-}
diff --git a/EPPlusTest/Drawing/Chart/ExcelChartAxisTest.cs b/EPPlusTest/Drawing/Chart/ExcelChartAxisTest.cs
deleted file mode 100644
index 42ade02..0000000
--- a/EPPlusTest/Drawing/Chart/ExcelChartAxisTest.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.Drawing.Chart;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml;
-
-namespace EPPlusTest.Drawing.Chart
-{
- [TestClass]
- public class ExcelChartAxisTest
- {
- private ExcelChartAxis axis;
-
- [TestInitialize]
- public void Initialize()
- {
- var xmlDoc = new XmlDocument();
- var xmlNsm = new XmlNamespaceManager(new NameTable());
- xmlNsm.AddNamespace("c", ExcelPackage.schemaChart);
- axis = new ExcelChartAxis(xmlNsm, xmlDoc.CreateElement("axis"));
- }
-
- [TestMethod]
- public void CrossesAt_SetTo2_Is2()
- {
- axis.CrossesAt = 2;
- Assert.AreEqual(axis.CrossesAt, 2);
- }
-
- [TestMethod]
- public void CrossesAt_SetTo1EMinus6_Is1EMinus6()
- {
- axis.CrossesAt = 1.2e-6;
- Assert.AreEqual(axis.CrossesAt, 1.2e-6);
- }
-
- [TestMethod]
- public void MinValue_SetTo2_Is2()
- {
- axis.MinValue = 2;
- Assert.AreEqual(axis.MinValue, 2);
- }
-
- [TestMethod]
- public void MinValue_SetTo1EMinus6_Is1EMinus6()
- {
- axis.MinValue = 1.2e-6;
- Assert.AreEqual(axis.MinValue, 1.2e-6);
- }
-
- [TestMethod]
- public void MaxValue_SetTo2_Is2()
- {
- axis.MaxValue = 2;
- Assert.AreEqual(axis.MaxValue, 2);
- }
-
- [TestMethod]
- public void MaxValue_SetTo1EMinus6_Is1EMinus6()
- {
- axis.MaxValue = 1.2e-6;
- Assert.AreEqual(axis.MaxValue, 1.2e-6);
- }
- }
-}
diff --git a/EPPlusTest/DrawingTest.cs b/EPPlusTest/DrawingTest.cs
deleted file mode 100644
index 3d82e5d..0000000
--- a/EPPlusTest/DrawingTest.cs
+++ /dev/null
@@ -1,905 +0,0 @@
-using System;
-using System.Drawing;
-using System.IO;
-using System.Xml;
-using EPPlusTest.Properties;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.Drawing;
-using OfficeOpenXml.Drawing.Chart;
-using OfficeOpenXml.Style;
-
-namespace EPPlusTest
-{
- /// <summary>
- /// Summary description for UnitTest1
- /// </summary>
- [TestClass]
- public class DrawingTest : TestBase
- {
- [TestMethod]
- public void RunDrawingTests()
- {
- BarChart();
- Column();
- Cone();
- Dougnut();
- Drawings();
- Line();
- LineMarker();
- PieChart();
- PieChart3D();
- Pyramid();
- Scatter();
- Bubble();
- Radar();
- Surface();
- Line2Test();
- MultiChartSeries();
- DrawingSizingAndPositioning();
- DeleteDrawing();
-
- SaveWorksheet("Drawing.xlsx");
-
- ReadDocument();
- ReadDrawing();
- }
- //[TestMethod]
- //[Ignore]
- public void ReadDrawing()
- {
- using (ExcelPackage pck = new ExcelPackage(new FileInfo(_worksheetPath + @"Drawing.xlsx")))
- {
- var ws = pck.Workbook.Worksheets["Pyramid"];
- Assert.AreEqual(ws.Cells["V24"].Value, 104D);
- ws = pck.Workbook.Worksheets["Scatter"];
- var cht = ws.Drawings["ScatterChart1"] as ExcelScatterChart;
- Assert.AreEqual(cht.Title.Text, "Header Text");
- cht.Title.Text = "Test";
- Assert.AreEqual(cht.Title.Text, "Test");
- }
- }
-
- [TestMethod]
- public void Picture()
- {
- var ws = _pck.Workbook.Worksheets.Add("Picture");
- var pic = ws.Drawings.AddPicture("Pic1", Resources.Test1);
-
- pic = ws.Drawings.AddPicture("Pic2", Resources.Test1);
- pic.SetPosition(150, 200);
- pic.Border.LineStyle = eLineStyle.Solid;
- pic.Border.Fill.Color = Color.DarkCyan;
- pic.Fill.Style = eFillStyle.SolidFill;
- pic.Fill.Color = Color.White;
- pic.Fill.Transparancy = 50;
-
- pic = ws.Drawings.AddPicture("Pic3", Resources.Test1);
- pic.SetPosition(400, 200);
- pic.SetSize(150);
-
- pic = ws.Drawings.AddPicture("Pic4", new FileInfo(Path.Combine(_clipartPath, "Vector Drawing.wmf")));
- pic = ws.Drawings.AddPicture("Pic5", new FileInfo(Path.Combine(_clipartPath,"BitmapImage.gif")));
- pic.SetPosition(400, 200);
- pic.SetSize(150);
-
- ws.Column(1).Width = 53;
- ws.Column(4).Width = 58;
-
- pic = ws.Drawings.AddPicture("Pic6öäå", new FileInfo(Path.Combine(_clipartPath, "BitmapImage.gif")));
- pic.SetPosition(400, 400);
- pic.SetSize(100);
-
- var ws2 = _pck.Workbook.Worksheets.Add("Picture2");
- var fi = new FileInfo(@"C:\Program Files (x86)\Microsoft Office\CLIPART\PUB60COR\AG00021_.GIF");
- if (fi.Exists)
- {
- pic = ws2.Drawings.AddPicture("Pic7", fi);
- }
- else
- {
- TestContext.WriteLine("AG00021_.GIF does not exists. Skiping Pic7.");
- }
-
- var wsCopy = _pck.Workbook.Worksheets.Add("Picture3", ws2);
- _pck.Workbook.Worksheets.Delete(ws2);
- }
- //[TestMethod]
- //[Ignore]
- public void DrawingSizingAndPositioning()
- {
- var ws = _pck.Workbook.Worksheets.Add("DrawingPosSize");
-
- var pic = ws.Drawings.AddPicture("Pic1", Resources.Test1);
- pic.SetPosition(1, 0, 1, 0);
-
- pic = ws.Drawings.AddPicture("Pic2", Resources.Test1);
- pic.EditAs = eEditAs.Absolute;
- pic.SetPosition(10, 5, 1, 4);
-
- pic = ws.Drawings.AddPicture("Pic3", Resources.Test1);
- pic.EditAs = eEditAs.TwoCell;
- pic.SetPosition(20, 5, 2, 4);
-
-
- ws.Column(1).Width = 100;
- ws.Column(3).Width = 100;
- }
-
- //[TestMethod]
- // [Ignore]
- public void BarChart()
- {
- var ws = _pck.Workbook.Worksheets.Add("BarChart");
- var chrt = ws.Drawings.AddChart("barChart", eChartType.BarClustered) as ExcelBarChart;
- chrt.SetPosition(50, 50);
- chrt.SetSize(800, 300);
- AddTestSerie(ws, chrt);
- chrt.VaryColors = true;
- chrt.XAxis.Orientation = eAxisOrientation.MaxMin;
- chrt.XAxis.MajorTickMark = eAxisTickMark.In;
- chrt.YAxis.Orientation = eAxisOrientation.MaxMin;
- chrt.YAxis.MinorTickMark = eAxisTickMark.Out;
- chrt.ShowHiddenData = true;
- chrt.DisplayBlanksAs = eDisplayBlanksAs.Zero;
- chrt.Title.RichText.Text = "Barchart Test";
- Assert.IsTrue(chrt.ChartType == eChartType.BarClustered, "Invalid Charttype");
- Assert.IsTrue(chrt.Direction == eDirection.Bar, "Invalid Bardirection");
- Assert.IsTrue(chrt.Grouping == eGrouping.Clustered, "Invalid Grouping");
- Assert.IsTrue(chrt.Shape == eShape.Box, "Invalid Shape");
- }
-
- private static void AddTestSerie(ExcelWorksheet ws, ExcelChart chrt)
- {
- AddTestData(ws);
- chrt.Series.Add("'" + ws.Name + "'!V19:V24", "'" + ws.Name + "'!U19:U24");
- }
-
- private static void AddTestData(ExcelWorksheet ws)
- {
- ws.Cells["U19"].Value = new DateTime(2009, 12, 31);
- ws.Cells["U20"].Value = new DateTime(2010, 1, 1);
- ws.Cells["U21"].Value = new DateTime(2010, 1, 2);
- ws.Cells["U22"].Value = new DateTime(2010, 1, 3);
- ws.Cells["U23"].Value = new DateTime(2010, 1, 4);
- ws.Cells["U24"].Value = new DateTime(2010, 1, 5);
- ws.Cells["U19:U24"].Style.Numberformat.Format = "yyyy-mm-dd";
-
- ws.Cells["V19"].Value = 100;
- ws.Cells["V20"].Value = 102;
- ws.Cells["V21"].Value = 101;
- ws.Cells["V22"].Value = 103;
- ws.Cells["V23"].Value = 105;
- ws.Cells["V24"].Value = 104;
-
- ws.Cells["X19"].Value = "öäå";
- ws.Cells["X20"].Value = "ÖÄÅ";
- ws.Cells["X21"].Value = "üÛ";
- ws.Cells["X22"].Value = "&%#¤";
- ws.Cells["X23"].Value = "ÿ";
- ws.Cells["X24"].Value = "û";
- }
- //[TestMethod]
- //[Ignore]
- public void PieChart()
- {
- var ws = _pck.Workbook.Worksheets.Add("PieChart");
- var chrt = ws.Drawings.AddChart("pieChart", eChartType.Pie) as ExcelPieChart;
-
- AddTestSerie(ws, chrt);
-
- chrt.To.Row = 25;
- chrt.To.Column = 12;
-
- chrt.DataLabel.ShowPercent = true;
- chrt.Legend.Font.Color = Color.SteelBlue;
- chrt.Title.Border.Fill.Style = eFillStyle.SolidFill;
- chrt.Legend.Position = eLegendPosition.TopRight;
- Assert.IsTrue(chrt.ChartType == eChartType.Pie, "Invalid Charttype");
- Assert.IsTrue(chrt.VaryColors);
- chrt.Title.Text = "Piechart";
- }
- //[TestMethod]
- //[Ignore]
- public void PieChart3D()
- {
- var ws = _pck.Workbook.Worksheets.Add("PieChart3d");
- var chrt = ws.Drawings.AddChart("pieChart3d", eChartType.Pie3D) as ExcelPieChart;
- AddTestSerie(ws, chrt);
-
- chrt.To.Row = 25;
- chrt.To.Column = 12;
-
- chrt.DataLabel.ShowValue = true;
- chrt.Legend.Position = eLegendPosition.Left;
- chrt.ShowHiddenData = false;
- chrt.DisplayBlanksAs = eDisplayBlanksAs.Gap;
- chrt.Title.RichText.Add("Pie RT Title add");
- Assert.IsTrue(chrt.ChartType == eChartType.Pie3D, "Invalid Charttype");
- Assert.IsTrue(chrt.VaryColors);
-
- }
- //[TestMethod]
- //[Ignore]
- public void Scatter()
- {
- var ws = _pck.Workbook.Worksheets.Add("Scatter");
- var chrt = ws.Drawings.AddChart("ScatterChart1", eChartType.XYScatterSmoothNoMarkers) as ExcelScatterChart;
- AddTestSerie(ws, chrt);
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.To.Row = 23;
- chrt.To.Column = 12;
- //chrt.Title.Text = "Header Text";
- var r1=chrt.Title.RichText.Add("Header");
- r1.Bold = true;
- var r2=chrt.Title.RichText.Add(" Text");
- r2.UnderLine = eUnderLineType.WavyHeavy;
-
- chrt.Title.Fill.Style = eFillStyle.SolidFill;
- chrt.Title.Fill.Color = Color.LightBlue;
- chrt.Title.Fill.Transparancy = 50;
- chrt.VaryColors = true;
- ExcelScatterChartSerie ser = chrt.Series[0] as ExcelScatterChartSerie;
- ser.DataLabel.Position = eLabelPosition.Center;
- ser.DataLabel.ShowValue = true;
- ser.DataLabel.ShowCategory = true;
- ser.DataLabel.Fill.Color = Color.BlueViolet;
- ser.DataLabel.Font.Color = Color.White;
- ser.DataLabel.Font.Italic = true;
- ser.DataLabel.Font.SetFromFont(new Font("bookman old style", 8));
- Assert.IsTrue(chrt.ChartType == eChartType.XYScatterSmoothNoMarkers, "Invalid Charttype");
- chrt.Series[0].Header = "Test serie";
- chrt = ws.Drawings.AddChart("ScatterChart2", eChartType.XYScatterSmooth) as ExcelScatterChart;
- chrt.Series.Add("U19:U24", "V19:V24");
-
- chrt.From.Column = 0;
- chrt.From.Row=25;
- chrt.To.Row = 53;
- chrt.To.Column = 12;
- chrt.Legend.Position = eLegendPosition.Bottom;
-
- ////chrt.Series[0].DataLabel.Position = eLabelPosition.Center;
- //Assert.IsTrue(chrt.ChartType == eChartType.XYScatter, "Invalid Charttype");
-
- }
- //[TestMethod]
- //[Ignore]
- public void Bubble()
- {
- var ws = _pck.Workbook.Worksheets.Add("Bubble");
- var chrt = ws.Drawings.AddChart("Bubble", eChartType.Bubble) as ExcelBubbleChart;
- AddTestData(ws);
-
- chrt.Series.Add("V19:V24", "U19:U24");
-
- chrt = ws.Drawings.AddChart("Bubble3d", eChartType.Bubble3DEffect) as ExcelBubbleChart;
- ws.Cells["W19"].Value = 1;
- ws.Cells["W20"].Value = 1;
- ws.Cells["W21"].Value = 2;
- ws.Cells["W22"].Value = 2;
- ws.Cells["W23"].Value = 3;
- ws.Cells["W24"].Value = 4;
-
- chrt.Series.Add("V19:V24", "U19:U24", "W19:W24");
- chrt.Style = eChartStyle.Style25;
-
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.From.Row = 23;
- chrt.From.Column = 12;
- chrt.To.Row = 33;
- chrt.To.Column = 22;
- chrt.Title.Text = "Header Text";
-
-
- }
- //[TestMethod]
- //[Ignore]
- public void Radar()
- {
- var ws = _pck.Workbook.Worksheets.Add("Radar");
- AddTestData(ws);
-
- var chrt = ws.Drawings.AddChart("Radar1", eChartType.Radar) as ExcelRadarChart;
- var s=chrt.Series.Add("V19:V24", "U19:U24");
- s.Header = "serie1";
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.From.Row = 23;
- chrt.From.Column = 12;
- chrt.To.Row = 38;
- chrt.To.Column = 22;
- chrt.Title.Text = "Radar Chart 1";
-
- chrt = ws.Drawings.AddChart("Radar2", eChartType.RadarFilled) as ExcelRadarChart;
- s = chrt.Series.Add("V19:V24", "U19:U24");
- s.Header = "serie1";
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.From.Row = 43;
- chrt.From.Column = 12;
- chrt.To.Row = 58;
- chrt.To.Column = 22;
- chrt.Title.Text = "Radar Chart 2";
-
- chrt = ws.Drawings.AddChart("Radar3", eChartType.RadarMarkers) as ExcelRadarChart;
- var rs = (ExcelRadarChartSerie)chrt.Series.Add("V19:V24", "U19:U24");
- rs.Header = "serie1";
- rs.Marker = eMarkerStyle.Star;
- rs.MarkerSize = 14;
-
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.From.Row = 63;
- chrt.From.Column = 12;
- chrt.To.Row = 78;
- chrt.To.Column = 22;
- chrt.Title.Text = "Radar Chart 3";
- }
- //[TestMethod]
- //[Ignore]
- public void Surface()
- {
- var ws = _pck.Workbook.Worksheets.Add("Surface");
- AddTestData(ws);
-
- var chrt = ws.Drawings.AddChart("Surface1", eChartType.Surface) as ExcelSurfaceChart;
- var s = chrt.Series.Add("V19:V24", "U19:U24");
- s.Header = "serie1";
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.From.Row = 23;
- chrt.From.Column = 12;
- chrt.To.Row = 38;
- chrt.To.Column = 22;
- chrt.Title.Text = "Surface Chart 1";
-
- //chrt = ws.Drawings.AddChart("Surface", eChartType.RadarFilled) as ExcelRadarChart;
- //s = chrt.Series.Add("V19:V24", "U19:U24");
- //s.Header = "serie1";
- //// chrt.Series[0].Marker = eMarkerStyle.Diamond;
- //chrt.From.Row = 43;
- //chrt.From.Column = 12;
- //chrt.To.Row = 58;
- //chrt.To.Column = 22;
- //chrt.Title.Text = "Radar Chart 2";
-
- //chrt = ws.Drawings.AddChart("Radar3", eChartType.RadarMarkers) as ExcelRadarChart;
- //var rs = (ExcelRadarChartSerie)chrt.Series.Add("V19:V24", "U19:U24");
- //rs.Header = "serie1";
- //rs.Marker = eMarkerStyle.Star;
- //rs.MarkerSize = 14;
-
- //// chrt.Series[0].Marker = eMarkerStyle.Diamond;
- //chrt.From.Row = 63;
- //chrt.From.Column = 12;
- //chrt.To.Row = 78;
- //chrt.To.Column = 22;
- //chrt.Title.Text = "Radar Chart 3";
- }
- //[TestMethod]
- //[Ignore]
- public void Pyramid()
- {
- var ws = _pck.Workbook.Worksheets.Add("Pyramid");
- var chrt = ws.Drawings.AddChart("Pyramid1", eChartType.PyramidCol) as ExcelBarChart;
- AddTestSerie(ws, chrt);
- // chrt.Series[0].Marker = eMarkerStyle.Diamond;
- chrt.VaryColors = true;
- chrt.To.Row = 23;
- chrt.To.Column = 12;
- chrt.Title.Text = "Header Text";
- chrt.Title.Fill.Style= eFillStyle.SolidFill;
- chrt.Title.Fill.Color = Color.DarkBlue;
- chrt.DataLabel.ShowValue = true;
- //chrt.DataLabel.ShowSeriesName = true;
- //chrt.DataLabel.Separator = ",";
- chrt.Border.LineCap = eLineCap.Round;
- chrt.Border.LineStyle = eLineStyle.LongDashDotDot;
- chrt.Border.Fill.Style = eFillStyle.SolidFill;
- chrt.Border.Fill.Color = Color.Blue;
-
- chrt.Fill.Color = Color.LightCyan;
- chrt.PlotArea.Fill.Color = Color.White;
- chrt.PlotArea.Border.Fill.Style = eFillStyle.SolidFill;
- chrt.PlotArea.Border.Fill.Color = Color.Beige;
- chrt.PlotArea.Border.LineStyle = eLineStyle.LongDash;
-
- chrt.Legend.Fill.Color = Color.Aquamarine;
- chrt.Legend.Position = eLegendPosition.Top;
- chrt.Axis[0].Fill.Style = eFillStyle.SolidFill;
- chrt.Axis[0].Fill.Color = Color.Black;
- chrt.Axis[0].Font.Color = Color.White;
-
- chrt.Axis[1].Fill.Style = eFillStyle.SolidFill;
- chrt.Axis[1].Fill.Color = Color.LightSlateGray;
- chrt.Axis[1].Font.Color = Color.DarkRed;
-
- chrt.DataLabel.Font.Bold = true;
- chrt.DataLabel.Fill.Color = Color.LightBlue;
- chrt.DataLabel.Border.Fill.Style=eFillStyle.SolidFill;
- chrt.DataLabel.Border.Fill.Color=Color.Black;
- chrt.DataLabel.Border.LineStyle = eLineStyle.Solid;
- }
- //[TestMethod]
- //[Ignore]
- public void Cone()
- {
- var ws = _pck.Workbook.Worksheets.Add("Cone");
- var chrt = ws.Drawings.AddChart("Cone1", eChartType.ConeBarClustered) as ExcelBarChart;
- AddTestSerie(ws, chrt);
- chrt.VaryColors = true;
- chrt.SetSize(200);
- chrt.Title.Text = "Cone bar";
- chrt.Series[0].Header = "Serie 1";
- chrt.Legend.Position = eLegendPosition.Right;
- chrt.Axis[1].DisplayUnit = 100000;
- Assert.AreEqual(chrt.Axis[1].DisplayUnit, 100000);
- }
- //[TestMethod]
- //[Ignore]
- public void Column()
- {
- var ws = _pck.Workbook.Worksheets.Add("Column");
- var chrt = ws.Drawings.AddChart("Column1", eChartType.ColumnClustered3D) as ExcelBarChart;
- AddTestSerie(ws, chrt);
- chrt.VaryColors = true;
- chrt.View3D.RightAngleAxes = true;
- chrt.View3D.DepthPercent = 99;
- //chrt.View3D.HeightPercent = 99;
- chrt.View3D.RightAngleAxes = true;
- chrt.SetSize(200);
- chrt.Title.Text = "Column";
- chrt.Series[0].Header = "Serie 1";
- chrt.Locked = false;
- chrt.Print = false;
- chrt.EditAs = eEditAs.TwoCell;
- chrt.Axis[1].DisplayUnit = 10020;
- Assert.AreEqual(chrt.Axis[1].DisplayUnit, 10020);
- }
- //[TestMethod]
- //[Ignore]
- public void Dougnut()
- {
- var ws = _pck.Workbook.Worksheets.Add("Dougnut");
- var chrt = ws.Drawings.AddChart("Dougnut1", eChartType.DoughnutExploded) as ExcelDoughnutChart;
- AddTestSerie(ws, chrt);
- chrt.SetSize(200);
- chrt.Title.Text = "Doughnut Exploded";
- chrt.Series[0].Header = "Serie 1";
- chrt.EditAs = eEditAs.Absolute;
- }
- //[TestMethod]
- //[Ignore]
- public void Line()
- {
- var ws = _pck.Workbook.Worksheets.Add("Line");
- var chrt = ws.Drawings.AddChart("Line1", eChartType.Line) as ExcelLineChart;
- AddTestSerie(ws, chrt);
- chrt.SetSize(150);
- chrt.VaryColors = true;
- chrt.Smooth = false;
- chrt.Title.Text = "Line 3D";
- chrt.Series[0].Header = "Line serie 1";
- var tl = chrt.Series[0].TrendLines.Add(eTrendLine.Polynomial);
- tl.Name = "Test";
- tl.DisplayRSquaredValue = true;
- tl.DisplayEquation = true;
- tl.Forward = 15;
- tl.Backward = 1;
- tl.Intercept = 6;
- //tl.Period = 12;
- tl.Order = 5;
-
- tl = chrt.Series[0].TrendLines.Add(eTrendLine.MovingAvgerage);
- chrt.Fill.Color = Color.LightSteelBlue;
- chrt.Border.LineStyle = eLineStyle.Dot;
- chrt.Border.Fill.Color=Color.Black;
-
- chrt.Legend.Font.Color = Color.Red;
- chrt.Legend.Font.Strike = eStrikeType.Double;
- chrt.Title.Font.Color = Color.DarkGoldenrod;
- chrt.Title.Font.LatinFont = "Arial";
- chrt.Title.Font.Bold = true;
- chrt.Title.Fill.Color = Color.White;
- chrt.Title.Border.Fill.Style = eFillStyle.SolidFill;
- chrt.Title.Border.LineStyle = eLineStyle.LongDashDotDot;
- chrt.Title.Border.Fill.Color = Color.Tomato;
- chrt.DataLabel.ShowSeriesName = true;
- chrt.DataLabel.ShowLeaderLines=true;
- chrt.EditAs = eEditAs.OneCell;
- chrt.DisplayBlanksAs = eDisplayBlanksAs.Span;
- chrt.Axis[0].Title.Text = "Axis 0";
- chrt.Axis[0].Title.Rotation = 90;
- chrt.Axis[0].Title.Overlay = true;
- chrt.Axis[1].Title.Text = "Axis 1";
- chrt.Axis[1].Title.AnchorCtr = true;
- chrt.Axis[1].Title.TextVertical = eTextVerticalType.Vertical270;
- chrt.Axis[1].Title.Border.LineStyle=eLineStyle.LongDashDotDot;
-
- }
- //[TestMethod]
- //[Ignore]
- public void LineMarker()
- {
- var ws = _pck.Workbook.Worksheets.Add("LineMarker1");
- var chrt = ws.Drawings.AddChart("Line1", eChartType.LineMarkers) as ExcelLineChart;
- AddTestSerie(ws, chrt);
- chrt.SetSize(150);
- chrt.Title.Text = "Line Markers";
- chrt.Series[0].Header = "Line serie 1";
- ((ExcelLineChartSerie)chrt.Series[0]).Marker = eMarkerStyle.Plus;
-
- var chrt2 = ws.Drawings.AddChart("Line2", eChartType.LineMarkers) as ExcelLineChart;
- AddTestSerie(ws, chrt2);
- chrt2.SetPosition(500,0);
- chrt2.SetSize(150);
- chrt2.Title.Text = "Line Markers";
- var serie = (ExcelLineChartSerie)chrt2.Series[0];
- serie.Marker = eMarkerStyle.X;
-
- }
- //[TestMethod]
- //[Ignore]
- public void Drawings()
- {
- var ws = _pck.Workbook.Worksheets.Add("Shapes");
- int y=100, i=1;
- foreach(eShapeStyle style in Enum.GetValues(typeof(eShapeStyle)))
- {
- var shape = ws.Drawings.AddShape("shape"+i.ToString(), style);
- shape.SetPosition(y, 100);
- shape.SetSize(300, 300);
- y += 400;
- shape.Text = style.ToString();
- i++;
- }
-
- (ws.Drawings["shape1"] as ExcelShape).TextAnchoring = eTextAnchoringType.Top;
- var rt = (ws.Drawings["shape1"] as ExcelShape).RichText.Add("Added formated richtext");
- (ws.Drawings["shape1"] as ExcelShape).LockText = false;
- rt.Bold = true;
- rt.Color = Color.Aquamarine;
- rt.Italic = true;
- rt.Size = 17;
- (ws.Drawings["shape2"] as ExcelShape).TextVertical = eTextVerticalType.Vertical;
- rt = (ws.Drawings["shape2"] as ExcelShape).RichText.Add("\r\nAdded formated richtext");
- rt.Bold = true;
- rt.Color = Color.DarkGoldenrod ;
- rt.SetFromFont(new Font("Times new roman", 18, FontStyle.Underline));
- rt.UnderLineColor = Color.Green;
-
-
- (ws.Drawings["shape3"] as ExcelShape).TextAnchoring=eTextAnchoringType.Bottom;
- (ws.Drawings["shape3"] as ExcelShape).TextAnchoringControl=true ;
-
- (ws.Drawings["shape4"] as ExcelShape).TextVertical = eTextVerticalType.Vertical270;
- (ws.Drawings["shape4"] as ExcelShape).TextAnchoring = eTextAnchoringType.Top;
-
- (ws.Drawings["shape5"] as ExcelShape).Fill.Style=eFillStyle.SolidFill;
- (ws.Drawings["shape5"] as ExcelShape).Fill.Color=Color.Red;
- (ws.Drawings["shape5"] as ExcelShape).Fill.Transparancy = 50;
-
- (ws.Drawings["shape6"] as ExcelShape).Fill.Style = eFillStyle.NoFill;
- (ws.Drawings["shape6"] as ExcelShape).Font.Color = Color.Black;
- (ws.Drawings["shape6"] as ExcelShape).Border.Fill.Color = Color.Black;
-
- (ws.Drawings["shape7"] as ExcelShape).Fill.Style = eFillStyle.SolidFill;
- (ws.Drawings["shape7"] as ExcelShape).Fill.Color=Color.Gray;
- (ws.Drawings["shape7"] as ExcelShape).Border.Fill.Style=eFillStyle.SolidFill;
- (ws.Drawings["shape7"] as ExcelShape).Border.Fill.Color = Color.Black;
- (ws.Drawings["shape7"] as ExcelShape).Border.Fill.Transparancy=43;
- (ws.Drawings["shape7"] as ExcelShape).Border.LineCap=eLineCap.Round;
- (ws.Drawings["shape7"] as ExcelShape).Border.LineStyle = eLineStyle.LongDash;
- (ws.Drawings["shape7"] as ExcelShape).Font.UnderLineColor = Color.Blue;
- (ws.Drawings["shape7"] as ExcelShape).Font.Color = Color.Black;
- (ws.Drawings["shape7"] as ExcelShape).Font.Bold = true;
- (ws.Drawings["shape7"] as ExcelShape).Font.LatinFont = "Arial";
- (ws.Drawings["shape7"] as ExcelShape).Font.ComplexFont = "Arial";
- (ws.Drawings["shape7"] as ExcelShape).Font.Italic = true;
- (ws.Drawings["shape7"] as ExcelShape).Font.UnderLine = eUnderLineType.Dotted;
-
- (ws.Drawings["shape8"] as ExcelShape).Fill.Style = eFillStyle.SolidFill;
- (ws.Drawings["shape8"] as ExcelShape).Font.LatinFont = "Miriam";
- (ws.Drawings["shape8"] as ExcelShape).Font.UnderLineColor = Color.CadetBlue;
- (ws.Drawings["shape8"] as ExcelShape).Font.UnderLine = eUnderLineType.Single;
-
- (ws.Drawings["shape9"] as ExcelShape).TextAlignment = eTextAlignment.Right;
-
- }
- [TestMethod]
- [Ignore]
- public void DrawingWorksheetCopy()
- {
- var wsShapes = _pck.Workbook.Worksheets.Add("Copy Shapes", _pck.Workbook.Worksheets["Shapes"]);
- var wsScatterChart = _pck.Workbook.Worksheets.Add("Copy Scatter", _pck.Workbook.Worksheets["Scatter"]);
- var wsPicture = _pck.Workbook.Worksheets.Add("Copy Picture", _pck.Workbook.Worksheets["Picture"]);
- }
- //[TestMethod]
- //[Ignore]
- public void Line2Test()
- {
- ExcelWorksheet worksheet = _pck.Workbook.Worksheets.Add("LineIssue");
-
- ExcelChart chart = worksheet.Drawings.AddChart("LineChart", eChartType.Line);
-
- worksheet.Cells["A1"].Value=1;
- worksheet.Cells["A2"].Value=2;
- worksheet.Cells["A3"].Value=3;
- worksheet.Cells["A4"].Value=4;
- worksheet.Cells["A5"].Value=5;
- worksheet.Cells["A6"].Value=6;
-
- worksheet.Cells["B1"].Value=10000;
- worksheet.Cells["B2"].Value=10100;
- worksheet.Cells["B3"].Value=10200;
- worksheet.Cells["B4"].Value=10150;
- worksheet.Cells["B5"].Value=10250;
- worksheet.Cells["B6"].Value=10200;
-
- chart.Series.Add(ExcelRange.GetAddress(1, 2, worksheet.Dimension.End.Row, 2),
- ExcelRange.GetAddress(1, 1, worksheet.Dimension.End.Row, 1));
-
- var Series = chart.Series[0];
-
- chart.Series[0].Header = "Blah";
- }
- //[TestMethod]
- //[Ignore]
- public void MultiChartSeries()
- {
- ExcelWorksheet worksheet = _pck.Workbook.Worksheets.Add("MultiChartTypes");
-
- ExcelChart chart = worksheet.Drawings.AddChart("chtPie", eChartType.LineMarkers);
- chart.SetPosition(100, 100);
- chart.SetSize(800,600);
- AddTestSerie(worksheet, chart);
- chart.Series[0].Header = "Serie5";
- chart.Style = eChartStyle.Style27;
- worksheet.Cells["W19"].Value = 120;
- worksheet.Cells["W20"].Value = 122;
- worksheet.Cells["W21"].Value = 121;
- worksheet.Cells["W22"].Value = 123;
- worksheet.Cells["W23"].Value = 125;
- worksheet.Cells["W24"].Value = 124;
-
- worksheet.Cells["X19"].Value = 90;
- worksheet.Cells["X20"].Value = 52;
- worksheet.Cells["X21"].Value = 88;
- worksheet.Cells["X22"].Value = 75;
- worksheet.Cells["X23"].Value = 77;
- worksheet.Cells["X24"].Value = 99;
-
- var cs2 = chart.PlotArea.ChartTypes.Add(eChartType.ColumnClustered);
- var s = cs2.Series.Add(worksheet.Cells["W19:W24"], worksheet.Cells["U19:U24"]);
- s.Header = "Serie4";
- cs2.YAxis.MaxValue = 300;
- cs2.YAxis.MinValue = -5.5;
- var cs3 = chart.PlotArea.ChartTypes.Add(eChartType.Line);
- s=cs3.Series.Add(worksheet.Cells["X19:X24"], worksheet.Cells["U19:U24"]);
- s.Header = "Serie1";
- cs3.UseSecondaryAxis = true;
-
- cs3.XAxis.Deleted = false;
- cs3.XAxis.MajorUnit = 20;
- cs3.XAxis.MinorUnit = 3;
-
- cs3.XAxis.TickLabelPosition = eTickLabelPosition.High;
- cs3.YAxis.LogBase = 10.2;
-
- var chart2 = worksheet.Drawings.AddChart("scatter1", eChartType.XYScatterSmooth);
- s=chart2.Series.Add(worksheet.Cells["W19:W24"], worksheet.Cells["U19:U24"]);
- s.Header = "Serie2";
-
- var c2ct2 = chart2.PlotArea.ChartTypes.Add(eChartType.XYScatterSmooth);
- s=c2ct2.Series.Add(worksheet.Cells["X19:X24"], worksheet.Cells["V19:V24"]);
- s.Header="Serie3";
- s=c2ct2.Series.Add(worksheet.Cells["W19:W24"], worksheet.Cells["V19:V24"]);
- s.Header = "Serie4";
-
- c2ct2.UseSecondaryAxis = true;
- c2ct2.XAxis.Deleted = false;
- c2ct2.XAxis.TickLabelPosition = eTickLabelPosition.High;
-
- ExcelChart chart3 = worksheet.Drawings.AddChart("chart", eChartType.LineMarkers);
- chart3.SetPosition(300, 1000);
- var s31=chart3.Series.Add(worksheet.Cells["W19:W24"], worksheet.Cells["U19:U24"]);
- s31.Header = "Serie1";
-
- var c3ct2 = chart3.PlotArea.ChartTypes.Add(eChartType.LineMarkers);
- var c32 = c3ct2.Series.Add(worksheet.Cells["X19:X24"], worksheet.Cells["V19:V24"]);
- c3ct2.UseSecondaryAxis = true;
- c32.Header = "Serie2";
-
- XmlNamespaceManager ns=new XmlNamespaceManager(new NameTable());
- ns.AddNamespace("c","http://schemas.openxmlformats.org/drawingml/2006/chart");
- var element = chart.ChartXml.SelectSingleNode("//c:plotVisOnly", ns);
- if (element!=null) element.ParentNode.RemoveChild(element);
- }
- //[TestMethod]
- //[Ignore]
- public void DeleteDrawing()
- {
- var ws=_pck.Workbook.Worksheets.Add("DeleteDrawing1");
- var chart1 = ws.Drawings.AddChart("Chart1", eChartType.Line);
- var chart2 = ws.Drawings.AddChart("Chart2", eChartType.Line);
- var shape1 = ws.Drawings.AddShape("Shape1", eShapeStyle.ActionButtonBackPrevious);
- var pic1 = ws.Drawings.AddPicture("Pic1", Resources.Test1);
- ws.Drawings.Remove(2);
- ws.Drawings.Remove(chart2);
- ws.Drawings.Remove("Pic1");
-
- ws = _pck.Workbook.Worksheets.Add("DeleteDrawing2");
- chart1 = ws.Drawings.AddChart("Chart1", eChartType.Line);
- chart2 = ws.Drawings.AddChart("Chart2", eChartType.Line);
- shape1 = ws.Drawings.AddShape("Shape1", eShapeStyle.ActionButtonBackPrevious);
- pic1 = ws.Drawings.AddPicture("Pic1", Resources.Test1);
-
- ws.Drawings.Remove("chart1");
-
- ws = _pck.Workbook.Worksheets.Add("ClearDrawing2");
- chart1 = ws.Drawings.AddChart("Chart1", eChartType.Line);
- chart2 = ws.Drawings.AddChart("Chart2", eChartType.Line);
- shape1 = ws.Drawings.AddShape("Shape1", eShapeStyle.ActionButtonBackPrevious);
- pic1 = ws.Drawings.AddPicture("Pic1", Resources.Test1);
- ws.Drawings.Clear();
- }
- //[TestMethod]
- //[Ignore]
- public void ReadDocument()
- {
- var fi=new FileInfo(_worksheetPath + "drawing.xlsx");
- if (!fi.Exists)
- {
- Assert.Inconclusive("Drawing.xlsx is not created. Skippng");
- }
- var pck = new ExcelPackage(fi, true);
-
- foreach(var ws in pck.Workbook.Worksheets)
- {
- foreach(ExcelDrawing d in pck.Workbook.Worksheets[1].Drawings)
- {
- if (d is ExcelChart)
- {
- TestContext.WriteLine(((ExcelChart)d).ChartType.ToString());
- }
- }
- }
- pck.Dispose();
- }
- [TestMethod]
- [Ignore]
- public void ReadMultiChartSeries()
- {
- ExcelPackage pck = new ExcelPackage(new FileInfo("c:\\temp\\chartseries.xlsx"), true);
-
- var ws = pck.Workbook.Worksheets[1];
- ExcelChart c = ws.Drawings[0] as ExcelChart;
-
-
- var p = c.PlotArea;
- p.ChartTypes[1].Series[0].Series = "S7:S15";
-
- var c2=ws.Drawings.AddChart("NewChart", eChartType.ColumnClustered);
- var serie1 = c2.Series.Add("R7:R15", "Q7:Q15");
- c2.SetSize(800, 800);
- serie1.Header = "Column Clustered";
-
- var subChart = c2.PlotArea.ChartTypes.Add(eChartType.LineMarkers);
- var serie2 = subChart.Series.Add("S7:S15", "Q7:Q15");
- serie2.Header = "Line";
-
- //var subChart2 = c2.PlotArea.ChartTypes.Add(eChartType.DoughnutExploded);
- //var serie3 = subChart2.Series.Add("S7:S15", "Q7:Q15");
- //serie3.Header = "Doughnut";
-
- var subChart3 = c2.PlotArea.ChartTypes.Add(eChartType.Area);
- var serie4 = subChart3.Series.Add("R7:R15", "Q7:Q15");
- serie4.Header = "Area";
- subChart3.UseSecondaryAxis = true;
-
- var serie5 = subChart.Series.Add("R7:R15","Q7:Q15");
- serie5.Header = "Line 2";
-
- pck.SaveAs(new FileInfo("c:\\temp\\chartseriesnew.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ChartWorksheet()
- {
- _pck = new ExcelPackage();
- var wsChart = _pck.Workbook.Worksheets.AddChart("chart", eChartType.Bubble3DEffect);
- var ws = _pck.Workbook.Worksheets.Add("data");
- AddTestSerie(ws, wsChart.Chart);
- wsChart.Chart.Style = eChartStyle.Style23;
- wsChart.Chart.Title.Text = "Chart worksheet";
- wsChart.Chart.Series[0].Header = "Serie";
- _pck.SaveAs(new FileInfo(@"c:\temp\chart.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadChartWorksheet()
- {
- _pck = new ExcelPackage(new FileInfo(@"c:\temp\chart.xlsx"));
- var chart = ((ExcelChartsheet)_pck.Workbook.Worksheets[1]).Chart;
-
- _pck.SaveAs(new FileInfo(@"c:\temp\chart.xlsx"));
-
- }
- [Ignore]
- [TestMethod]
- public void ReadWriteSmoothChart()
- {
- _pck = new ExcelPackage(new FileInfo(@"c:\temp\bug\Xds_2014_TEST.xlsx"));
- var chart = _pck.Workbook.Worksheets[1].Drawings[0] as ExcelChart;
- _pck.Workbook.Worksheets[1].Cells["B2"].Value = 33;
- _pck.SaveAs(new FileInfo(@"c:\temp\chart.xlsx"));
-
- }
- [TestMethod]
- public void TestHeaderaddress()
- {
- _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("Draw");
- var chart = ws.Drawings.AddChart("NewChart1",eChartType.Area) as ExcelChart;
- var ser1 = chart.Series.Add("A1:A2", "B1:B2");
- ser1.HeaderAddress = new ExcelAddress("A1:A2");
- ser1.HeaderAddress = new ExcelAddress("A1:B1");
- ser1.HeaderAddress = new ExcelAddress("A1");
- _pck.Dispose();
- _pck = null;
- }
- [Ignore]
- [TestMethod]
- public void AllDrawingsInsideMarkupCompatibility()
- {
- string workbooksDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\workbooks");
- // This is codeplex issue 15028: Making an unrelated change to an Excel file that contains drawings that ALL exist
- // inside MarkupCompatibility/Choice nodes causes the drawings.xml file to be incorrectly garbage collected
- // when an unrelated change is made.
- string path = Path.Combine(workbooksDir, "AllDrawingsInsideMarkupCompatibility.xlsm");
-
- // Load example document.
- _pck = new ExcelPackage(new FileInfo(path));
- // Verify the drawing part exists:
- Uri partUri = new Uri("/xl/drawings/drawing1.xml", UriKind.Relative);
- Assert.IsTrue(_pck.Package.PartExists(partUri));
-
- // The Excel Drawings NamespaceManager from ExcelDrawing.CreateNSM:
- NameTable nt = new NameTable();
- var xmlNsm = new XmlNamespaceManager(nt);
- xmlNsm.AddNamespace("a", ExcelPackage.schemaDrawings);
- xmlNsm.AddNamespace("xdr", ExcelPackage.schemaSheetDrawings);
- xmlNsm.AddNamespace("c", ExcelPackage.schemaChart);
- xmlNsm.AddNamespace("r", ExcelPackage.schemaRelationships);
- xmlNsm.AddNamespace("mc", ExcelPackage.schemaMarkupCompatibility);
-
- XmlDocument drawingsXml = new XmlDocument();
- drawingsXml.PreserveWhitespace = false;
- XmlHelper.LoadXmlSafe(drawingsXml, _pck.Package.GetPart(partUri).GetStream());
-
- // Verify that there are the correct # of drawings:
- Assert.AreEqual(drawingsXml.SelectNodes("//*[self::xdr:twoCellAnchor or self::xdr:oneCellAnchor or self::xdr:absoluteAnchor]", xmlNsm).Count, 5);
-
- // Make unrelated change. (in this case a useless additional worksheet)
- _pck.Workbook.Worksheets.Add("NewWorksheet");
-
- // Save it out.
- string savedPath = Path.Combine(workbooksDir, "AllDrawingsInsideMarkupCompatibility2.xlsm");
- _pck.SaveAs(new FileInfo(savedPath));
- _pck.Dispose();
-
- // Reload the new saved file.
- _pck = new ExcelPackage(new FileInfo(savedPath));
-
- // Verify the drawing part still exists.
- Assert.IsTrue(_pck.Package.PartExists(new Uri("/xl/drawings/drawing1.xml", UriKind.Relative)));
-
- drawingsXml = new XmlDocument();
- drawingsXml.PreserveWhitespace = false;
- XmlHelper.LoadXmlSafe(drawingsXml, _pck.Package.GetPart(partUri).GetStream());
-
- // Verify that there are the correct # of drawings:
- Assert.AreEqual(drawingsXml.SelectNodes("//*[self::xdr:twoCellAnchor or self::xdr:oneCellAnchor or self::xdr:absoluteAnchor]", xmlNsm).Count, 5);
- // Verify that the new worksheet exists:
- Assert.IsNotNull(_pck.Workbook.Worksheets["NewWorksheet"]);
- // Cleanup:
- File.Delete(savedPath);
- }
- }
-}
diff --git a/EPPlusTest/EPPlusTest.csproj b/EPPlusTest/EPPlusTest.csproj
deleted file mode 100644
index 4cc7ac5..0000000
--- a/EPPlusTest/EPPlusTest.csproj
+++ /dev/null
@@ -1,268 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{E7BCEDE0-EADD-437B-86D5-49D192216948}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>EPPlusTest</RootNamespace>
- <AssemblyName>EPPlusTest</AssemblyName>
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <OldToolsVersion>3.5</OldToolsVersion>
- <UpgradeBackupLocation />
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
- <RestorePackages>true</RestorePackages>
- <TargetFrameworkProfile />
- </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>
- <PlatformTarget>AnyCPU</PlatformTarget>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>false</Prefer32Bit>
- </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>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <PlatformTarget>x86</PlatformTarget>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup>
- <SignAssembly>true</SignAssembly>
- </PropertyGroup>
- <PropertyGroup>
- <AssemblyOriginatorKeyFile>EPPlusTest.snk</AssemblyOriginatorKeyFile>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release 4.0|AnyCPU'">
- <OutputPath>bin\Release 4.0\</OutputPath>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
- <Reference Include="Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.configuration" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Design" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Security" />
- <Reference Include="System.Xml" />
- <Reference Include="WindowsBase">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Address.cs" />
- <Compile Include="Calculation.cs" />
- <Compile Include="ConditionalFormatting\ConditionalFormatting.cs" />
- <Compile Include="DataValidation\CustomValidationTests.cs" />
- <Compile Include="DataValidation\DataValidationTests.cs" />
- <Compile Include="DataValidation\DecimaDataValidationTests.cs" />
- <Compile Include="DataValidation\ExcelTimeTests.cs" />
- <Compile Include="DataValidation\Formulas\CustomFormulaTests.cs" />
- <Compile Include="DataValidation\Formulas\DateTimeFormulaTests.cs" />
- <Compile Include="DataValidation\Formulas\DecimalFormulaTests.cs" />
- <Compile Include="DataValidation\Formulas\IntegerFormulaTests.cs" />
- <Compile Include="DataValidation\Formulas\ListFormulaTests.cs" />
- <Compile Include="DataValidation\Formulas\TimeFormulaTests.cs" />
- <Compile Include="DataValidation\IntegrationTests\IntegrationTests.cs" />
- <Compile Include="DataValidation\ListDataValidationTests.cs" />
- <Compile Include="DataValidation\RangeBaseTests.cs" />
- <Compile Include="DataValidation\ValidationCollectionTests.cs" />
- <Compile Include="DataValidation\ValidationTestBase.cs" />
- <Compile Include="DTS_FailingTests.cs" />
- <Compile Include="Encrypt.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\AddressTranslatorTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\CellReferenceProviderTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\ExcelAddressInfoTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\IndexToAddressTranslatorTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\NumericExpressionEvaluatorTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\RangeAddressFactoryTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\RangeAddressTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\RangesTest.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\ValueMatcherTests.cs" />
- <Compile Include="FormulaParsing\ExcelUtilities\WildCardValueMatcherTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\ArgumentParserFactoryTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\ArgumentParsersImplementationsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\ArgumentParsersTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\CountIfsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\Database\ExcelDatabaseTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\Database\CriteriaTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\Database\RowMatcherTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\DateTimeFunctionsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\ExcelFunctionTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\FunctionArgumentTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\InformationFunctionsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\LogicalFunctionsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\MathFunctionsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\NumberFunctionsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\RefAndLookup\LookupNavigatorTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\RefAndLookup\RefAndLookupTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\RefAndLookup\IndexTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\RefAndLookup\LookupNavigatorFactoryTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\SubtotalTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\SumIfsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\TextFunctionsTests.cs" />
- <Compile Include="FormulaParsing\Excel\Functions\TimeStringParserTests.cs" />
- <Compile Include="FormulaParsing\Excel\OperatorsTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\EnumerableExpressionTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\ExcelAddressExpressionTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\ExpressionCompilerTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\ExpressionConverterTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\ExpressionFactoryTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\ExpressionGraphBuilderTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\IntegerExpressionTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\DecimalExpressionTests.cs" />
- <Compile Include="FormulaParsing\ExpressionGraph\BooleanExpressionTests.cs" />
- <Compile Include="FormulaParsing\FormulaParserTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BasicCalcTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\DateAndTimeFunctionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\ExcelRanges\MathExcelRangeTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\ExcelRanges\TextExcelRangeTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\InformationFunctionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\LogicalFunctionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\MathFunctionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\RefAndLookupTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\StringFunctionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\SubtotalTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\TextFunctionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\BuiltInFunctions\DatabaseTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\ErrorHandling\SumTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\ExcelDataProviderTests\ExcelDataProviderIntegrationTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\FormulaParserTestBase.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\PrecedenceTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\CalcExtensionsTests.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\ErrorHandling\FormulaErrorHandlingTestBase.cs" />
- <Compile Include="FormulaParsing\IntegrationTests\OperatorsTests.cs" />
- <Compile Include="FormulaParsing\LexicalAnalysis\NegationTests.cs" />
- <Compile Include="FormulaParsing\LexicalAnalysis\SourceCodeTokenizerTests.cs" />
- <Compile Include="FormulaParsing\LexicalAnalysis\SyntacticAnalyzerTests.cs" />
- <Compile Include="FormulaParsing\LexicalAnalysis\TokenFactoryTests.cs" />
- <Compile Include="FormulaParsing\NameValueProviderTests.cs" />
- <Compile Include="FormulaParsing\ParsingContextTests.cs" />
- <Compile Include="FormulaParsing\ParsingScopesTest.cs" />
- <Compile Include="FormulaParsing\ParsingScopeTests.cs" />
- <Compile Include="FormulaParsing\TestHelpers\FunctionsHelper.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="DrawingTest.cs" />
- <Compile Include="Properties\Resources.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>Resources.resx</DependentUpon>
- </Compile>
- <Compile Include="ReadTemplate.cs" />
- <Compile Include="TestBase.cs" />
- <Compile Include="TestDTO.cs" />
- <Compile Include="CellStoreTest.cs" />
- <Compile Include="Issues.cs" />
- <Compile Include="LoadFromCollectionTests.cs" />
- <Compile Include="CommentsTest.cs" />
- <Compile Include="Utils\AddressUtilityTests.cs" />
- <Compile Include="Utils\GuardingTests.cs" />
- <Compile Include="Utils\SqRefUtilityTests.cs" />
- <Compile Include="VBA.cs" />
- <Compile Include="WorkSheet.cs" />
- <Compile Include="WorksheetsTests.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="EPPlusTest.snk" />
- <None Include="packages.config" />
- <None Include="TestStart.orderedtest">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- <SubType>Designer</SubType>
- </None>
- <EmbeddedResource Include="Resources\Vector Drawing.wmf" />
- <EmbeddedResource Include="Resources\Vector Drawing2.wmf" />
- <None Include="Workbooks\FormulaTest.xlsx">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="Properties\Resources.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>Resources.Designer.cs</LastGenOutput>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include=".NETFramework,Version=v4.0">
- <Visible>False</Visible>
- <ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\EPPlus\EPPlus.csproj">
- <Project>{7b288026-5502-4a39-bf41-77e086f3e4a3}</Project>
- <Name>EPPlus</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="Resources\BitmapImage.gif" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="Resources\Test1.jpg" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
diff --git a/EPPlusTest/EPPlusTest.snk b/EPPlusTest/EPPlusTest.snk
deleted file mode 100644
index 885f115..0000000
--- a/EPPlusTest/EPPlusTest.snk
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/Encrypt.cs b/EPPlusTest/Encrypt.cs
deleted file mode 100644
index 025220c..0000000
--- a/EPPlusTest/Encrypt.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.IO;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class Encrypt : TestBase
- {
- [TestMethod]
- [Ignore]
- public void ReadWriteEncrypt()
- {
- using (ExcelPackage pck = new ExcelPackage(new FileInfo(@"Test\Drawing.xlsx"), true))
- {
- pck.Encryption.Password = "EPPlus";
- pck.Encryption.Algorithm = EncryptionAlgorithm.AES192;
- pck.Workbook.Protection.SetPassword("test");
- pck.Workbook.Protection.LockStructure = true;
- pck.Workbook.Protection.LockWindows = true;
-
- pck.SaveAs(new FileInfo(@"Test\DrawingEncr.xlsx"));
- }
-
- using (ExcelPackage pck = new ExcelPackage(new FileInfo(_worksheetPath + @"\DrawingEncr.xlsx"), true, "EPPlus"))
- {
- pck.Encryption.IsEncrypted = false;
- pck.SaveAs(new FileInfo(_worksheetPath + @"\DrawingNotEncr.xlsx"));
- }
-
- FileStream fs = new FileStream(_worksheetPath + @"\DrawingEncr.xlsx", FileMode.Open, FileAccess.ReadWrite);
- using (ExcelPackage pck = new ExcelPackage(fs, "EPPlus"))
- {
- pck.Encryption.IsEncrypted = false;
- pck.SaveAs(new FileInfo(_worksheetPath + @"DrawingNotEncr.xlsx"));
- }
-
- }
- [TestMethod]
- [Ignore]
- public void WriteEncrypt()
- {
- ExcelPackage package = new ExcelPackage();
- //Load the sheet with one string column, one date column and a few random numbers.
- var ws = package.Workbook.Worksheets.Add("First line test");
-
- ws.Cells[1, 1].Value = "1; 1";
- ws.Cells[2, 1].Value = "2; 1";
- ws.Cells[1, 2].Value = "1; 2";
- ws.Cells[2, 2].Value = "2; 2";
-
- ws.Row(1).Style.Font.Bold = true;
- ws.Column(1).Style.Font.Bold = true;
-
- //package.Encryption.Algorithm = EncryptionAlgorithm.AES256;
- //package.SaveAs(new FileInfo(@"c:\temp\encrTest.xlsx"), "ABxsw23edc");
- package.Encryption.Password = "test";
- package.Encryption.IsEncrypted = true;
- package.SaveAs(new FileInfo(@"c:\temp\encrTest.xlsx"));
- }
- [TestMethod]
- [Ignore]
- public void WriteProtect()
- {
- ExcelPackage package = new ExcelPackage(new FileInfo(@"c:\temp\workbookprot2.xlsx"), "");
- //Load the sheet with one string column, one date column and a few random numbers.
- //package.Workbook.Protection.LockWindows = true;
- //package.Encryption.IsEncrypted = true;
- package.Workbook.Protection.SetPassword("t");
- package.Workbook.Protection.LockStructure = true;
- package.Workbook.View.Left = 585;
- package.Workbook.View.Top = 150;
-
- package.Workbook.View.Width = 17310;
- package.Workbook.View.Height = 38055;
- var ws = package.Workbook.Worksheets.Add("First line test");
-
- ws.Cells[1, 1].Value = "1; 1";
- ws.Cells[2, 1].Value = "2; 1";
- ws.Cells[1, 2].Value = "1; 2";
- ws.Cells[2, 2].Value = "2; 2";
-
- package.SaveAs(new FileInfo(@"c:\temp\workbookprot2.xlsx"));
-
- }
- [TestMethod]
- [Ignore]
- public void DecrypTest()
- {
- var p = new ExcelPackage(new FileInfo(@"c:\temp\encr.xlsx"), "test");
-
- var n = p.Workbook.Worksheets[1].Name;
- p.Encryption.Password = null;
- p.SaveAs(new FileInfo(@"c:\temp\encrNew.xlsx"));
-
- }
- [TestMethod]
- [Ignore]
- public void EncrypTest()
- {
- var f = new FileInfo(@"c:\temp\encrwrite.xlsx");
- if (f.Exists)
- {
- f.Delete();
- }
- var p = new ExcelPackage(f);
-
- p.Workbook.Protection.SetPassword("");
- p.Workbook.Protection.LockStructure = true;
- p.Encryption.Version = EncryptionVersion.Agile;
-
- var ws = p.Workbook.Worksheets.Add("Sheet1");
- for (int r = 1; r < 1000; r++)
- {
- ws.Cells[r, 1].Value = r;
- }
- p.Save();
- }
- }
-}
diff --git a/EPPlusTest/ExcelCellBaseTest.cs b/EPPlusTest/ExcelCellBaseTest.cs
deleted file mode 100644
index 130e242..0000000
--- a/EPPlusTest/ExcelCellBaseTest.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class ExcelCellBaseTest
- {
- #region UpdateFormulaReferences Tests
- [TestMethod]
- public void UpdateFormulaReferencesOnTheSameSheet()
- {
- var result = ExcelCellBase.UpdateFormulaReferences("C3", 3, 3, 2, 2, "sheet", "sheet");
- Assert.AreEqual("F6", result);
- }
-
- [TestMethod]
- public void UpdateFormulaReferencesIgnoresIncorrectSheet()
- {
- var result = ExcelCellBase.UpdateFormulaReferences("C3", 3, 3, 2, 2, "sheet", "other sheet");
- Assert.AreEqual("C3", result);
- }
-
- [TestMethod]
- public void UpdateFormulaReferencesFullyQualifiedReferenceOnTheSameSheet()
- {
- var result = ExcelCellBase.UpdateFormulaReferences("'sheet name here'!C3", 3, 3, 2, 2, "sheet name here", "sheet name here");
- Assert.AreEqual("'sheet name here'!F6", result);
- }
-
- [TestMethod]
- public void UpdateFormulaReferencesFullyQualifiedCrossSheetReferenceArray()
- {
- var result = ExcelCellBase.UpdateFormulaReferences("SUM('sheet name here'!B2:D4)", 3, 3, 3, 3, "cross sheet", "sheet name here");
- Assert.AreEqual("SUM('sheet name here'!B2:G7)", result);
- }
-
- [TestMethod]
- public void UpdateFormulaReferencesFullyQualifiedReferenceOnADifferentSheet()
- {
- var result = ExcelCellBase.UpdateFormulaReferences("'updated sheet'!C3", 3, 3, 2, 2, "boring sheet", "updated sheet");
- Assert.AreEqual("'updated sheet'!F6", result);
- }
-
- [TestMethod]
- public void UpdateFormulaReferencesReferencingADifferentSheetIsNotUpdated()
- {
- var result = ExcelCellBase.UpdateFormulaReferences("'boring sheet'!C3", 3, 3, 2, 2, "boring sheet", "updated sheet");
- Assert.AreEqual("'boring sheet'!C3", result);
- }
- #endregion
-
- #region UpdateCrossSheetReferenceNames Tests
- [TestMethod]
- public void UpdateFormulaSheetReferences()
- {
- var result = ExcelCellBase.UpdateFormulaSheetReferences("5+'OldSheet'!$G3+'Some Other Sheet'!C3+SUM(1,2,3)", "OldSheet", "NewSheet");
- Assert.AreEqual("5+'NewSheet'!$G3+'Some Other Sheet'!C3+SUM(1,2,3)", result);
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
- public void UpdateFormulaSheetReferencesNullOldSheetThrowsException()
- {
- ExcelCellBase.UpdateFormulaSheetReferences("formula", null, "sheet2");
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
- public void UpdateFormulaSheetReferencesEmptyOldSheetThrowsException()
- {
- ExcelCellBase.UpdateFormulaSheetReferences("formula", string.Empty, "sheet2");
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
- public void UpdateFormulaSheetReferencesNullNewSheetThrowsException()
- {
- ExcelCellBase.UpdateFormulaSheetReferences("formula", "sheet1", null);
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
- public void UpdateFormulaSheetReferencesEmptyNewSheetThrowsException()
- {
- ExcelCellBase.UpdateFormulaSheetReferences("formula", "sheet1", string.Empty);
- }
- #endregion
- }
-}
diff --git a/EPPlusTest/ExcelRangeBaseTest.cs b/EPPlusTest/ExcelRangeBaseTest.cs
deleted file mode 100644
index 9c52a6f..0000000
--- a/EPPlusTest/ExcelRangeBaseTest.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class ExcelRangeBaseTest : TestBase
- {
- [TestMethod]
- public void CopyCopiesCommentsFromSingleCellRanges()
- {
- InitBase();
- var pck = new ExcelPackage();
- var ws1 = pck.Workbook.Worksheets.Add("CommentCopying");
- var sourceExcelRange = ws1.Cells[3, 3];
- Assert.IsNull(sourceExcelRange.Comment);
- sourceExcelRange.AddComment("Testing comment 1", "test1");
- Assert.AreEqual("test1", sourceExcelRange.Comment.Author);
- Assert.AreEqual("Testing comment 1", sourceExcelRange.Comment.Text);
- var destinationExcelRange = ws1.Cells[5, 5];
- Assert.IsNull(destinationExcelRange.Comment);
- sourceExcelRange.Copy(destinationExcelRange);
- // Assert the original comment is intact.
- Assert.AreEqual("test1", sourceExcelRange.Comment.Author);
- Assert.AreEqual("Testing comment 1", sourceExcelRange.Comment.Text);
- // Assert the comment was copied.
- Assert.AreEqual("test1", destinationExcelRange.Comment.Author);
- Assert.AreEqual("Testing comment 1", destinationExcelRange.Comment.Text);
- }
-
- [TestMethod]
- public void CopyCopiesCommentsFromMultiCellRanges()
- {
- InitBase();
- var pck = new ExcelPackage();
- var ws1 = pck.Workbook.Worksheets.Add("CommentCopying");
- var sourceExcelRangeC3 = ws1.Cells[3, 3];
- var sourceExcelRangeD3 = ws1.Cells[3, 4];
- var sourceExcelRangeE3 = ws1.Cells[3, 5];
- Assert.IsNull(sourceExcelRangeC3.Comment);
- Assert.IsNull(sourceExcelRangeD3.Comment);
- Assert.IsNull(sourceExcelRangeE3.Comment);
- sourceExcelRangeC3.AddComment("Testing comment 1", "test1");
- sourceExcelRangeD3.AddComment("Testing comment 2", "test1");
- sourceExcelRangeE3.AddComment("Testing comment 3", "test1");
- Assert.AreEqual("test1", sourceExcelRangeC3.Comment.Author);
- Assert.AreEqual("Testing comment 1", sourceExcelRangeC3.Comment.Text);
- Assert.AreEqual("test1", sourceExcelRangeD3.Comment.Author);
- Assert.AreEqual("Testing comment 2", sourceExcelRangeD3.Comment.Text);
- Assert.AreEqual("test1", sourceExcelRangeE3.Comment.Author);
- Assert.AreEqual("Testing comment 3", sourceExcelRangeE3.Comment.Text);
- // Copy the full row to capture each cell at once.
- Assert.IsNull(ws1.Cells[5, 3].Comment);
- Assert.IsNull(ws1.Cells[5, 4].Comment);
- Assert.IsNull(ws1.Cells[5, 5].Comment);
- ws1.Cells["3:3"].Copy(ws1.Cells["5:5"]);
- // Assert the original comments are intact.
- Assert.AreEqual("test1", sourceExcelRangeC3.Comment.Author);
- Assert.AreEqual("Testing comment 1", sourceExcelRangeC3.Comment.Text);
- Assert.AreEqual("test1", sourceExcelRangeD3.Comment.Author);
- Assert.AreEqual("Testing comment 2", sourceExcelRangeD3.Comment.Text);
- Assert.AreEqual("test1", sourceExcelRangeE3.Comment.Author);
- Assert.AreEqual("Testing comment 3", sourceExcelRangeE3.Comment.Text);
- // Assert the comments were copied.
- var destinationExcelRangeC5 = ws1.Cells[5, 3];
- var destinationExcelRangeD5 = ws1.Cells[5, 4];
- var destinationExcelRangeE5 = ws1.Cells[5, 5];
- Assert.AreEqual("test1", destinationExcelRangeC5.Comment.Author);
- Assert.AreEqual("Testing comment 1", destinationExcelRangeC5.Comment.Text);
- Assert.AreEqual("test1", destinationExcelRangeD5.Comment.Author);
- Assert.AreEqual("Testing comment 2", destinationExcelRangeD5.Comment.Text);
- Assert.AreEqual("test1", destinationExcelRangeE5.Comment.Author);
- Assert.AreEqual("Testing comment 3", destinationExcelRangeE5.Comment.Text);
- }
-
- [TestMethod]
- public void SettingAddressHandlesMultiAddresses()
- {
- using (ExcelPackage package = new ExcelPackage())
- {
- var worksheet = package.Workbook.Worksheets.Add("Sheet1");
- var name = package.Workbook.Names.Add("Test", worksheet.Cells[3, 3]);
- name.Address = "Sheet1!C3";
- name.Address = "Sheet1!D3";
- Assert.IsNull(name.Addresses);
- name.Address = "C3:D3,E3:F3";
- Assert.IsNotNull(name.Addresses);
- name.Address = "Sheet1!C3";
- Assert.IsNull(name.Addresses);
- }
- }
- }
-}
diff --git a/EPPlusTest/ExcelStyleTest.cs b/EPPlusTest/ExcelStyleTest.cs
deleted file mode 100644
index bc0e15f..0000000
--- a/EPPlusTest/ExcelStyleTest.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class ExcelStyleTest
- {
- [TestMethod]
- public void QuotePrefixStyle()
- {
- using (var p = new ExcelPackage())
- {
- var ws = p.Workbook.Worksheets.Add("QuotePrefixTest");
- var cell = ws.Cells["B2"];
- cell.Style.QuotePrefix = true;
- Assert.IsTrue(cell.Style.QuotePrefix);
-
- p.Workbook.Styles.UpdateXml();
- var nodes = p.Workbook.StylesXml.SelectNodes("//d:cellXfs/d:xf", p.Workbook.NameSpaceManager);
- // Since the quotePrefix attribute is not part of the default style,
- // a new one should be created and referenced.
- Assert.AreNotEqual(0, cell.StyleID);
- Assert.IsNull(nodes[0].Attributes["quotePrefix"]);
- Assert.AreEqual("1", nodes[cell.StyleID].Attributes["quotePrefix"].Value);
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParserFactoryTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParserFactoryTests.cs
deleted file mode 100644
index 5f66a85..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParserFactoryTests.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class ArgumentParserFactoryTests
- {
- private ArgumentParserFactory _parserFactory;
-
- [TestInitialize]
- public void Setup()
- {
- _parserFactory = new ArgumentParserFactory();
- }
-
- [TestMethod]
- public void ShouldReturnIntArgumentParserWhenDataTypeIsInteger()
- {
- var parser = _parserFactory.CreateArgumentParser(DataType.Integer);
- Assert.IsInstanceOfType(parser, typeof(IntArgumentParser));
- }
-
- [TestMethod]
- public void ShouldReturnBoolArgumentParserWhenDataTypeIsBoolean()
- {
- var parser = _parserFactory.CreateArgumentParser(DataType.Boolean);
- Assert.IsInstanceOfType(parser, typeof(BoolArgumentParser));
- }
-
- [TestMethod]
- public void ShouldReturnDoubleArgumentParserWhenDataTypeIsDecial()
- {
- var parser = _parserFactory.CreateArgumentParser(DataType.Decimal);
- Assert.IsInstanceOfType(parser, typeof(DoubleArgumentParser));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParsersImplementationsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParsersImplementationsTests.cs
deleted file mode 100644
index 77a4237..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParsersImplementationsTests.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class ArgumentParsersImplementationsTests
- {
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IntParserShouldThrowIfArgumentIsNull()
- {
- var parser = new IntArgumentParser();
- parser.Parse(null);
- }
-
- [TestMethod]
- public void IntParserShouldConvertToAnInteger()
- {
- var parser = new IntArgumentParser();
- var result = parser.Parse(3);
- Assert.AreEqual(3, result);
- }
-
- [TestMethod]
- public void IntParserShouldConvertADoubleToAnInteger()
- {
- var parser = new IntArgumentParser();
- var result = parser.Parse(3d);
- Assert.AreEqual(3, result);
- }
-
- [TestMethod]
- public void IntParserShouldConvertAStringValueToAnInteger()
- {
- var parser = new IntArgumentParser();
- var result = parser.Parse("3");
- Assert.AreEqual(3, result);
- }
-
- [TestMethod]
- public void BoolParserShouldConvertNullToFalse()
- {
- var parser = new BoolArgumentParser();
- var result = (bool)parser.Parse(null);
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void BoolParserShouldConvertStringValueTrueToBoolValueTrue()
- {
- var parser = new BoolArgumentParser();
- var result = (bool)parser.Parse("true");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void BoolParserShouldConvert0ToFalse()
- {
- var parser = new BoolArgumentParser();
- var result = (bool)parser.Parse(0);
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void BoolParserShouldConvert1ToTrue()
- {
- var parser = new BoolArgumentParser();
- var result = (bool)parser.Parse(0);
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void DoubleParserShouldConvertDoubleToDouble()
- {
- var parser = new DoubleArgumentParser();
- var result = parser.Parse(3d);
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void DoubleParserShouldConvertIntToDouble()
- {
- var parser = new DoubleArgumentParser();
- var result = parser.Parse(3);
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void DoubleParserShouldThrowIfArgumentIsNull()
- {
- var parser = new DoubleArgumentParser();
- parser.Parse(null);
- }
-
- [TestMethod]
- public void DoubleParserConvertStringToDoubleWithDotSeparator()
- {
- var parser = new DoubleArgumentParser();
- var result = parser.Parse("3.3");
- Assert.AreEqual(3.3d, result);
- }
-
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParsersTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParsersTests.cs
deleted file mode 100644
index e97cb28..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/ArgumentParsersTests.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class ArgumentParsersTests
- {
- [TestMethod]
- public void ShouldReturnSameInstanceOfIntParserWhenCalledTwice()
- {
- var parsers = new ArgumentParsers();
- var parser1 = parsers.GetParser(DataType.Integer);
- var parser2 = parsers.GetParser(DataType.Integer);
- Assert.AreEqual(parser1, parser2);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/CountIfsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/CountIfsTests.cs
deleted file mode 100644
index 27a6f2a..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/CountIfsTests.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions
-{
- [TestClass]
- public class CountIfsTests
- {
- private ExcelPackage _package;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _worksheet = _package.Workbook.Worksheets.Add("testsheet");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void ShouldHandleSingleNumericCriteria()
- {
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 1;
- _worksheet.Cells["A3"].Value = 2;
- _worksheet.Cells["A4"].Formula = "COUNTIFS(A1:A3, 1)";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A4"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleSingleRangeCriteria()
- {
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 1;
- _worksheet.Cells["A3"].Value = 2;
- _worksheet.Cells["B1"].Value = 1;
- _worksheet.Cells["A4"].Formula = "COUNTIFS(A1:A3, B1)";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A4"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleSingleNumericWildcardCriteria()
- {
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 2;
- _worksheet.Cells["A3"].Value = 3;
- _worksheet.Cells["A4"].Formula = "COUNTIFS(A1:A3, \"<3\")";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A4"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleSingleStringCriteria()
- {
- _worksheet.Cells["A1"].Value = "abc";
- _worksheet.Cells["A2"].Value = "def";
- _worksheet.Cells["A3"].Value = "def";
- _worksheet.Cells["A4"].Formula = "COUNTIFS(A1:A3, \"def\")";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A4"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleSingleStringWildcardCriteria()
- {
- _worksheet.Cells["A1"].Value = "abc";
- _worksheet.Cells["A2"].Value = "def";
- _worksheet.Cells["A3"].Value = "def";
- _worksheet.Cells["A4"].Formula = "COUNTIFS(A1:A3, \"d*f\")";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A4"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleNullRangeCriteria()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = 1;
- _worksheet.Cells["A3"].Value = null;
- _worksheet.Cells["A4"].Formula = "COUNTIFS(A1:A3, B1)";
- _worksheet.Calculate();
- Assert.AreEqual(0d, _worksheet.Cells["A4"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleMultipleRangesAndCriterias()
- {
- _worksheet.Cells["A1"].Value = "abc";
- _worksheet.Cells["A2"].Value = "def";
- _worksheet.Cells["A3"].Value = "def";
- _worksheet.Cells["A4"].Value = "def";
- _worksheet.Cells["B1"].Value = 1;
- _worksheet.Cells["B2"].Value = 2;
- _worksheet.Cells["B3"].Value = 3;
- _worksheet.Cells["B4"].Value = 2;
- _worksheet.Cells["C1"].Value = null;
- _worksheet.Cells["C2"].Value = 200;
- _worksheet.Cells["C3"].Value = 3;
- _worksheet.Cells["C4"].Value = 2;
- _worksheet.Cells["A5"].Formula = "COUNTIFS(A1:A4, \"d*f\", B1:B4; 2; C1:C4; 200)";
- _worksheet.Calculate();
- Assert.AreEqual(1d, _worksheet.Cells["A5"].Value);
- }
-
- [TestMethod]
- public void ShouldSetErrorValueIfNumberOfCellsInRangesDiffer()
- {
- _worksheet.Cells["A1"].Value = "abc";
- _worksheet.Cells["A2"].Value = "def";
- _worksheet.Cells["A3"].Value = "def";
- _worksheet.Cells["A4"].Value = "def";
- _worksheet.Cells["B1"].Value = 1;
- _worksheet.Cells["B2"].Value = 2;
- _worksheet.Cells["B3"].Value = 3;
- _worksheet.Cells["B4"].Value = 2;
- _worksheet.Cells["A5"].Formula = "COUNTIFS(A1:A4, \"d*f\", B1:B3; 2)";
- _worksheet.Calculate();
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.Value), _worksheet.Cells["A5"].Value);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Database/CriteriaTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Database/CriteriaTests.cs
deleted file mode 100644
index 470c578..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Database/CriteriaTests.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Database
-{
- [TestClass]
- public class CriteriaTests
- {
- [TestMethod]
- public void CriteriaShouldReadFieldsAndValues()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = "Crit1";
- sheet.Cells["B1"].Value = "Crit2";
- sheet.Cells["A2"].Value = 1;
- sheet.Cells["B2"].Value = 2;
-
- var provider = new EpplusExcelDataProvider(package);
-
- var criteria = new ExcelDatabaseCriteria(provider, "A1:B2");
-
- Assert.AreEqual(2, criteria.Items.Count);
- Assert.AreEqual("crit1", criteria.Items.Keys.First().ToString());
- Assert.AreEqual("crit2", criteria.Items.Keys.Last().ToString());
- Assert.AreEqual(1, criteria.Items.Values.First());
- Assert.AreEqual(2, criteria.Items.Values.Last());
- }
- }
-
- [TestMethod]
- public void CriteriaShouldIgnoreEmptyFields1()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = "Crit1";
- sheet.Cells["B1"].Value = "Crit2";
- sheet.Cells["A2"].Value = 1;
-
- var provider = new EpplusExcelDataProvider(package);
-
- var criteria = new ExcelDatabaseCriteria(provider, "A1:B2");
-
- Assert.AreEqual(1, criteria.Items.Count);
- Assert.AreEqual("crit1", criteria.Items.Keys.First().ToString());
- Assert.AreEqual(1, criteria.Items.Values.Last());
- }
- }
-
- [TestMethod]
- public void CriteriaShouldIgnoreEmptyFields2()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = "Crit1";
- sheet.Cells["A2"].Value = 1;
-
- var provider = new EpplusExcelDataProvider(package);
-
- var criteria = new ExcelDatabaseCriteria(provider, "A1:B2");
-
- Assert.AreEqual(1, criteria.Items.Count);
- Assert.AreEqual("crit1", criteria.Items.Keys.First().ToString());
- Assert.AreEqual(1, criteria.Items.Values.Last());
- }
- }
-
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Database/ExcelDatabaseTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Database/ExcelDatabaseTests.cs
deleted file mode 100644
index 8970934..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Database/ExcelDatabaseTests.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Database
-{
- [TestClass]
- public class ExcelDatabaseTests
- {
- [TestMethod]
- public void DatabaseShouldReadFields()
- {
- using (var package = new ExcelPackage())
- {
- var database = GetDatabase(package);
-
- Assert.AreEqual(2, database.Fields.Count(), "count was not 2");
- Assert.AreEqual("col1", database.Fields.First().FieldName, "first fieldname was not 'col1'");
- Assert.AreEqual("col2", database.Fields.Last().FieldName, "last fieldname was not 'col12'");
- }
- }
-
- [TestMethod]
- public void HasMoreRowsShouldBeTrueWhenInitialized()
- {
- using (var package = new ExcelPackage())
- {
- var database = GetDatabase(package);
-
- Assert.IsTrue(database.HasMoreRows);
- }
-
- }
-
- [TestMethod]
- public void HasMoreRowsShouldBeFalseWhenLastRowIsRead()
- {
- using (var package = new ExcelPackage())
- {
- var database = GetDatabase(package);
- database.Read();
-
- Assert.IsFalse(database.HasMoreRows);
- }
-
- }
-
- [TestMethod]
- public void DatabaseShouldReadFieldsInRow()
- {
- using (var package = new ExcelPackage())
- {
- var database = GetDatabase(package);
- var row = database.Read();
-
- Assert.AreEqual(1, row["col1"]);
- Assert.AreEqual(2, row["col2"]);
- }
-
- }
-
- private static ExcelDatabase GetDatabase(ExcelPackage package)
- {
- var provider = new EpplusExcelDataProvider(package);
- var sheet = package.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = "col1";
- sheet.Cells["A2"].Value = 1;
- sheet.Cells["B1"].Value = "col2";
- sheet.Cells["B2"].Value = 2;
- var database = new ExcelDatabase(provider, "A1:B2");
- return database;
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Database/RowMatcherTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Database/RowMatcherTests.cs
deleted file mode 100644
index 6c7f710..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Database/RowMatcherTests.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
-using Rhino.Mocks;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Database
-{
- [TestClass]
- public class RowMatcherTests
- {
- private ExcelDatabaseCriteria GetCriteria(Dictionary<ExcelDatabaseCriteriaField, object> items)
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- var criteria = MockRepository.GenerateStub<ExcelDatabaseCriteria>(provider, string.Empty);
-
- criteria.Stub(x => x.Items).Return(items);
- return criteria;
- }
- [TestMethod]
- public void IsMatchShouldReturnTrueIfCriteriasMatch()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = 1;
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField("Crit1")] = 1;
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsTrue(matcher.IsMatch(data, criteria));
- }
-
- [TestMethod]
- public void IsMatchShouldReturnFalseIfCriteriasDoesNotMatch()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = 1;
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField("Crit1")] = 1;
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 4;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsFalse(matcher.IsMatch(data, criteria));
- }
-
- [TestMethod]
- public void IsMatchShouldMatchStrings1()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = "1";
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField("Crit1")] = "1";
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsTrue(matcher.IsMatch(data, criteria));
- }
-
- [TestMethod]
- public void IsMatchShouldMatchStrings2()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = "2";
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField("Crit1")] = "1";
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsFalse(matcher.IsMatch(data, criteria));
- }
-
- [TestMethod]
- public void IsMatchShouldMatchWildcardStrings()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = "test";
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField("Crit1")] = "t*t";
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsTrue(matcher.IsMatch(data, criteria));
- }
-
- [TestMethod]
- public void IsMatchShouldMatchNumericExpression()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = "test";
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField("Crit2")] = "<3";
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsTrue(matcher.IsMatch(data, criteria));
- }
-
- [TestMethod]
- public void IsMatchShouldHandleFieldIndex()
- {
- var data = new ExcelDatabaseRow();
- data["Crit1"] = "test";
- data["Crit2"] = 2;
- data["Crit3"] = 3;
-
- var crit = new Dictionary<ExcelDatabaseCriteriaField, object>();
- crit[new ExcelDatabaseCriteriaField(2)] = "<3";
- crit[new ExcelDatabaseCriteriaField("Crit3")] = 3;
-
- var matcher = new RowMatcher();
-
- var criteria = GetCriteria(crit);
-
- Assert.IsTrue(matcher.IsMatch(data, criteria));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/DateTimeFunctionsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/DateTimeFunctionsTests.cs
deleted file mode 100644
index d20f931..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/DateTimeFunctionsTests.cs
+++ /dev/null
@@ -1,472 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Threading;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class DateTimeFunctionsTests
- {
- private ParsingContext _parsingContext = ParsingContext.Create();
-
- private double GetTime(int hour, int minute, int second)
- {
- var secInADay = DateTime.Today.AddDays(1).Subtract(DateTime.Today).TotalSeconds;
- var secondsOfExample = (double)(hour * 60 * 60 + minute * 60 + second);
- return secondsOfExample / secInADay;
- }
- [TestMethod]
- public void DateFunctionShouldReturnADate()
- {
- var func = new Date();
- var args = FunctionsHelper.CreateArgs(2012, 4, 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(DataType.Date, result.DataType);
- }
-
- [TestMethod]
- public void DateFunctionShouldReturnACorrectDate()
- {
- var expectedDate = new DateTime(2012, 4, 3);
- var func = new Date();
- var args = FunctionsHelper.CreateArgs(2012, 4, 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedDate.ToOADate(), result.Result);
- }
-
- [TestMethod]
- public void DateFunctionShouldMonthFromPrevYearIfMonthIsNegative()
- {
- var expectedDate = new DateTime(2011, 11, 3);
- var func = new Date();
- var args = FunctionsHelper.CreateArgs(2012, -1, 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedDate.ToOADate(), result.Result);
- }
-
- [TestMethod]
- public void NowFunctionShouldReturnNow()
- {
- var startTime = DateTime.Now;
- Thread.Sleep(1);
- var func = new Now();
- var args = new FunctionArgument[0];
- var result = func.Execute(args, _parsingContext);
- Thread.Sleep(1);
- var endTime = DateTime.Now;
- var resultDate = DateTime.FromOADate((double)result.Result);
- Assert.IsTrue(resultDate > startTime && resultDate < endTime);
- }
-
- [TestMethod]
- public void TodayFunctionShouldReturnTodaysDate()
- {
- var func = new Today();
- var args = new FunctionArgument[0];
- var result = func.Execute(args, _parsingContext);
- var resultDate = DateTime.FromOADate((double)result.Result);
- Assert.AreEqual(DateTime.Now.Date, resultDate);
- }
-
- [TestMethod]
- public void DayShouldReturnDayInMonth()
- {
- var date = new DateTime(2012, 3, 12);
- var func = new Day();
- var args = FunctionsHelper.CreateArgs(date.ToOADate());
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(12, result.Result);
- }
-
- [TestMethod]
- public void DayShouldReturnMonthOfYearWithStringParam()
- {
- var date = new DateTime(2012, 3, 12);
- var func = new Day();
- var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-12"), _parsingContext);
- Assert.AreEqual(12, result.Result);
- }
-
- [TestMethod]
- public void MonthShouldReturnMonthOfYear()
- {
- var date = new DateTime(2012, 3, 12);
- var func = new Month();
- var result = func.Execute(FunctionsHelper.CreateArgs(date.ToOADate()), _parsingContext);
- Assert.AreEqual(3, result.Result);
- }
-
- [TestMethod]
- public void MonthShouldReturnMonthOfYearWithStringParam()
- {
- var date = new DateTime(2012, 3, 12);
- var func = new Month();
- var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-12"), _parsingContext);
- Assert.AreEqual(3, result.Result);
- }
-
- [TestMethod]
- public void YearShouldReturnCorrectYear()
- {
- var date = new DateTime(2012, 3, 12);
- var func = new Year();
- var result = func.Execute(FunctionsHelper.CreateArgs(date.ToOADate()), _parsingContext);
- Assert.AreEqual(2012, result.Result);
- }
-
- [TestMethod]
- public void YearShouldReturnCorrectYearWithStringParam()
- {
- var date = new DateTime(2012, 3, 12);
- var func = new Year();
- var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-12"), _parsingContext);
- Assert.AreEqual(2012, result.Result);
- }
-
- [TestMethod]
- public void TimeShouldReturnACorrectSerialNumber()
- {
- var expectedResult = GetTime(10, 11, 12);
- var func = new Time();
- var result = func.Execute(FunctionsHelper.CreateArgs(10, 11, 12), _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod]
- public void TimeShouldParseStringCorrectly()
- {
- var expectedResult = GetTime(10, 11, 12);
- var func = new Time();
- var result = func.Execute(FunctionsHelper.CreateArgs("10:11:12"), _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void TimeShouldThrowExceptionIfSecondsIsOutOfRange()
- {
- var func = new Time();
- var result = func.Execute(FunctionsHelper.CreateArgs(10, 11, 60), _parsingContext);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void TimeShouldThrowExceptionIfMinuteIsOutOfRange()
- {
- var func = new Time();
- var result = func.Execute(FunctionsHelper.CreateArgs(10, 60, 12), _parsingContext);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void TimeShouldThrowExceptionIfHourIsOutOfRange()
- {
- var func = new Time();
- var result = func.Execute(FunctionsHelper.CreateArgs(24, 12, 12), _parsingContext);
- }
-
- [TestMethod]
- public void HourShouldReturnCorrectResult()
- {
- var func = new Hour();
- var result = func.Execute(FunctionsHelper.CreateArgs(GetTime(9, 13, 14)), _parsingContext);
- Assert.AreEqual(9, result.Result);
-
- result = func.Execute(FunctionsHelper.CreateArgs(GetTime(23, 13, 14)), _parsingContext);
- Assert.AreEqual(23, result.Result);
- }
-
- [TestMethod]
- public void MinuteShouldReturnCorrectResult()
- {
- var func = new Minute();
- var result = func.Execute(FunctionsHelper.CreateArgs(GetTime(9, 14, 14)), _parsingContext);
- Assert.AreEqual(14, result.Result);
-
- result = func.Execute(FunctionsHelper.CreateArgs(GetTime(9, 55, 14)), _parsingContext);
- Assert.AreEqual(55, result.Result);
- }
-
- [TestMethod]
- public void SecondShouldReturnCorrectResult()
- {
- var func = new Second();
- var result = func.Execute(FunctionsHelper.CreateArgs(GetTime(9, 14, 17)), _parsingContext);
- Assert.AreEqual(17, result.Result);
- }
-
- [TestMethod]
- public void SecondShouldReturnCorrectResultWithStringArgument()
- {
- var func = new Second();
- var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-27 10:11:12"), _parsingContext);
- Assert.AreEqual(12, result.Result);
- }
-
- [TestMethod]
- public void MinuteShouldReturnCorrectResultWithStringArgument()
- {
- var func = new Minute();
- var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-27 10:11:12"), _parsingContext);
- Assert.AreEqual(11, result.Result);
- }
-
- [TestMethod]
- public void HourShouldReturnCorrectResultWithStringArgument()
- {
- var func = new Hour();
- var result = func.Execute(FunctionsHelper.CreateArgs("2012-03-27 10:11:12"), _parsingContext);
- Assert.AreEqual(10, result.Result);
- }
-
- [TestMethod]
- public void WeekdayShouldReturnCorrectResultForASundayWhenReturnTypeIs1()
- {
- var func = new Weekday();
- var result = func.Execute(FunctionsHelper.CreateArgs(new DateTime(2012, 4, 1).ToOADate(), 1), _parsingContext);
- Assert.AreEqual(1, result.Result);
- }
-
- [TestMethod]
- public void WeekdayShouldReturnCorrectResultForASundayWhenReturnTypeIs2()
- {
- var func = new Weekday();
- var result = func.Execute(FunctionsHelper.CreateArgs(new DateTime(2012, 4, 1).ToOADate(), 2), _parsingContext);
- Assert.AreEqual(7, result.Result);
- }
-
- [TestMethod]
- public void WeekdayShouldReturnCorrectResultForASundayWhenReturnTypeIs3()
- {
- var func = new Weekday();
- var result = func.Execute(FunctionsHelper.CreateArgs(new DateTime(2012, 4, 1).ToOADate(), 3), _parsingContext);
- Assert.AreEqual(6, result.Result);
- }
-
- [TestMethod]
- public void WeekNumShouldReturnCorrectResult()
- {
- var func = new Weeknum();
- var dt1 = new DateTime(2012, 12, 31).ToOADate();
- var dt2 = new DateTime(2012, 1, 1).ToOADate();
- var dt3 = new DateTime(2013, 1, 20).ToOADate();
-
- var r1 = func.Execute(FunctionsHelper.CreateArgs(dt1), _parsingContext);
- var r2 = func.Execute(FunctionsHelper.CreateArgs(dt2), _parsingContext);
- var r3 = func.Execute(FunctionsHelper.CreateArgs(dt3, 2), _parsingContext);
-
- Assert.AreEqual(53, r1.Result, "r1.Result was not 53, but " + r1.Result.ToString());
- Assert.AreEqual(1, r2.Result, "r2.Result was not 1, but " + r2.Result.ToString());
- Assert.AreEqual(3, r3.Result, "r3.Result was not 3, but " + r3.Result.ToString());
- }
-
- [TestMethod]
- public void EdateShouldReturnCorrectResult()
- {
- var func = new Edate();
-
- var dt1arg = new DateTime(2012, 1, 31).ToOADate();
- var dt2arg = new DateTime(2013, 1, 1).ToOADate();
- var dt3arg = new DateTime(2013, 2, 28).ToOADate();
-
- var r1 = func.Execute(FunctionsHelper.CreateArgs(dt1arg, 1), _parsingContext);
- var r2 = func.Execute(FunctionsHelper.CreateArgs(dt2arg, -1), _parsingContext);
- var r3 = func.Execute(FunctionsHelper.CreateArgs(dt3arg, 2), _parsingContext);
-
- var dt1 = DateTime.FromOADate((double) r1.Result);
- var dt2 = DateTime.FromOADate((double)r2.Result);
- var dt3 = DateTime.FromOADate((double)r3.Result);
-
- var exp1 = new DateTime(2012, 2, 29);
- var exp2 = new DateTime(2012, 12, 1);
- var exp3 = new DateTime(2013, 4, 28);
-
- Assert.AreEqual(exp1, dt1, "dt1 was not " + exp1.ToString("yyyy-MM-dd") + ", but " + dt1.ToString("yyyy-MM-dd"));
- Assert.AreEqual(exp2, dt2, "dt1 was not " + exp2.ToString("yyyy-MM-dd") + ", but " + dt2.ToString("yyyy-MM-dd"));
- Assert.AreEqual(exp3, dt3, "dt1 was not " + exp3.ToString("yyyy-MM-dd") + ", but " + dt3.ToString("yyyy-MM-dd"));
- }
-
- [TestMethod]
- public void Days360ShouldReturnCorrectResultWithNoMethodSpecified2()
- {
- var func = new Days360();
-
- var dt1arg = new DateTime(2013, 1, 1).ToOADate();
- var dt2arg = new DateTime(2013, 3, 31).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg), _parsingContext);
-
- Assert.AreEqual(90, result.Result);
- }
-
- [TestMethod]
- public void Days360ShouldReturnCorrectResultWithEuroMethodSpecified()
- {
- var func = new Days360();
-
- var dt1arg = new DateTime(2013, 1, 1).ToOADate();
- var dt2arg = new DateTime(2013, 3, 31).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg, true), _parsingContext);
-
- Assert.AreEqual(89, result.Result);
- }
-
- [TestMethod]
- public void Days360ShouldHandleFebWithEuroMethodSpecified()
- {
- var func = new Days360();
-
- var dt1arg = new DateTime(2012, 2, 29).ToOADate();
- var dt2arg = new DateTime(2013, 2, 28).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg, true), _parsingContext);
-
- Assert.AreEqual(359, result.Result);
- }
-
- [TestMethod]
- public void Days360ShouldHandleFebWithUsMethodSpecified()
- {
- var func = new Days360();
-
- var dt1arg = new DateTime(2012, 2, 29).ToOADate();
- var dt2arg = new DateTime(2013, 2, 28).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg, false), _parsingContext);
-
- Assert.AreEqual(358, result.Result);
- }
-
- [TestMethod]
- public void Days360ShouldHandleFebWithUsMethodSpecified2()
- {
- var func = new Days360();
-
- var dt1arg = new DateTime(2013, 2, 28).ToOADate();
- var dt2arg = new DateTime(2013, 3, 31).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg, false), _parsingContext);
-
- Assert.AreEqual(30, result.Result);
- }
-
- [TestMethod]
- public void YearFracShouldReturnCorrectResultWithUsBasis()
- {
- var func = new Yearfrac();
- var dt1arg = new DateTime(2013, 2, 28).ToOADate();
- var dt2arg = new DateTime(2013, 3, 31).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg), _parsingContext);
-
- var roundedResult = Math.Round((double) result.Result, 4);
-
- Assert.IsTrue(Math.Abs(0.0861 - roundedResult) < double.Epsilon);
- }
-
- [TestMethod]
- public void YearFracShouldReturnCorrectResultWithEuroBasis()
- {
- var func = new Yearfrac();
- var dt1arg = new DateTime(2013, 2, 28).ToOADate();
- var dt2arg = new DateTime(2013, 3, 31).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg, 4), _parsingContext);
-
- var roundedResult = Math.Round((double)result.Result, 4);
-
- Assert.IsTrue(Math.Abs(0.0889 - roundedResult) < double.Epsilon);
- }
-
- [TestMethod]
- public void YearFracActualActual()
- {
- var func = new Yearfrac();
- var dt1arg = new DateTime(2012, 2, 28).ToOADate();
- var dt2arg = new DateTime(2013, 3, 31).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(dt1arg, dt2arg, 1), _parsingContext);
-
- var roundedResult = Math.Round((double)result.Result, 4);
-
- Assert.IsTrue(Math.Abs(1.0862 - roundedResult) < double.Epsilon);
- }
-
- [TestMethod]
- public void IsoWeekShouldReturn1When1StJan()
- {
- var func = new IsoWeekNum();
- var arg = new DateTime(2013, 1, 1).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(arg), _parsingContext);
-
- Assert.AreEqual(1, result.Result);
- }
-
- [TestMethod]
- public void EomonthShouldReturnCorrectResultWithPositiveArg()
- {
- var func = new Eomonth();
- var arg = new DateTime(2013, 2, 2).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(arg, 3), _parsingContext);
-
- Assert.AreEqual(41425d, result.Result);
- }
-
- [TestMethod]
- public void EomonthShouldReturnCorrectResultWithNegativeArg()
- {
- var func = new Eomonth();
- var arg = new DateTime(2013, 2, 2).ToOADate();
-
- var result = func.Execute(FunctionsHelper.CreateArgs(arg, -3), _parsingContext);
-
- Assert.AreEqual(41243d, result.Result);
- }
-
- [TestMethod]
- public void WorkdayShouldReturnCorrectResultIfNoHolidayIsSupplied()
- {
- var inputDate = new DateTime(2014, 1, 1).ToOADate();
- var expectedDate = new DateTime(2014, 1, 29).ToOADate();
-
- var func = new Workday();
- var args = FunctionsHelper.CreateArgs(inputDate, 20);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedDate, result.Result);
- }
-
- [TestMethod]
- public void WorkdayShouldReturnCorrectResultWithFourDaysSupplied()
- {
- var inputDate = new DateTime(2014, 1, 1).ToOADate();
- var expectedDate = new DateTime(2014, 1, 7).ToOADate();
-
- var func = new Workday();
- var args = FunctionsHelper.CreateArgs(inputDate, 4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedDate, result.Result);
- }
-
- [TestMethod]
- public void WorkdayShouldReturnCorrectWhenArrayOfHolidayDatesIsSupplied()
- {
- var inputDate = new DateTime(2014, 1, 1).ToOADate();
- var holidayDate1 = new DateTime(2014, 1, 2).ToOADate();
- var holidayDate2 = new DateTime(2014, 1, 3).ToOADate();
- var expectedDate = new DateTime(2014, 1, 9).ToOADate();
-
- var func = new Workday();
- var args = FunctionsHelper.CreateArgs(inputDate, 4, FunctionsHelper.CreateArgs(holidayDate1, holidayDate2));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedDate, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/ExcelFunctionTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/ExcelFunctionTests.cs
deleted file mode 100644
index 36162e2..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/ExcelFunctionTests.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class ExcelFunctionTests
- {
- private class ExcelFunctionTester : ExcelFunction
- {
- public IEnumerable<double> ArgsToDoubleEnumerableImpl(IEnumerable<FunctionArgument> args)
- {
- return ArgsToDoubleEnumerable(args, ParsingContext.Create());
- }
- #region Other members
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- throw new NotImplementedException();
- }
- #endregion
- }
-
- [TestMethod]
- public void ArgsToDoubleEnumerableShouldHandleInnerEnumerables()
- {
- var args = FunctionsHelper.CreateArgs(1, 2, FunctionsHelper.CreateArgs(3, 4));
- var tester = new ExcelFunctionTester();
- var result = tester.ArgsToDoubleEnumerableImpl(args);
- Assert.AreEqual(4, result.Count());
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/FunctionArgumentTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/FunctionArgumentTests.cs
deleted file mode 100644
index d12b888..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/FunctionArgumentTests.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.Excel;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class FunctionArgumentTests
- {
- [TestMethod]
- public void ShouldSetExcelState()
- {
- var arg = new FunctionArgument(2);
- arg.SetExcelStateFlag(ExcelCellState.HiddenCell);
- Assert.IsTrue(arg.ExcelStateFlagIsSet(ExcelCellState.HiddenCell));
- }
-
- [TestMethod]
- public void ExcelStateFlagIsSetShouldReturnFalseWhenNotSet()
- {
- var arg = new FunctionArgument(2);
- Assert.IsFalse(arg.ExcelStateFlagIsSet(ExcelCellState.HiddenCell));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/FunctionRepositoryTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/FunctionRepositoryTests.cs
deleted file mode 100644
index eef3134..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/FunctionRepositoryTests.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph.FunctionCompilers;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions
-{
- [TestClass]
- public class FunctionRepositoryTests
- {
- #region LoadModule Tests
- [TestMethod]
- public void LoadModulePopulatesFunctionsAndCustomCompilers()
- {
- var functionRepository = FunctionRepository.Create();
- Assert.IsFalse(functionRepository.IsFunctionName(MyFunction.Name));
- Assert.IsFalse(functionRepository.CustomCompilers.ContainsKey(typeof(MyFunction)));
- functionRepository.LoadModule(new TestFunctionModule());
- Assert.IsTrue(functionRepository.IsFunctionName(MyFunction.Name));
- Assert.IsTrue(functionRepository.CustomCompilers.ContainsKey(typeof(MyFunction)));
- // Make sure reloading the module overwrites previous functions and compilers
- functionRepository.LoadModule(new TestFunctionModule());
- }
- #endregion
-
- #region Nested Classes
- public class TestFunctionModule : FunctionsModule
- {
- public TestFunctionModule()
- {
- var myFunction = new MyFunction();
- var customCompiler = new MyFunctionCompiler(myFunction);
- base.Functions.Add(MyFunction.Name, myFunction);
- base.CustomCompilers.Add(typeof(MyFunction), customCompiler);
- }
- }
-
- public class MyFunction : ExcelFunction
- {
- public const string Name = "MyFunction";
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- throw new NotImplementedException();
- }
- }
-
- public class MyFunctionCompiler : FunctionCompiler
- {
- public MyFunctionCompiler(MyFunction function) : base(function) { }
- public override CompileResult Compile(IEnumerable<Expression> children, ParsingContext context)
- {
- throw new NotImplementedException();
- }
- }
- #endregion
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/InformationFunctionsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/InformationFunctionsTests.cs
deleted file mode 100644
index cb37df7..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/InformationFunctionsTests.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-using OfficeOpenXml;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class InformationFunctionsTests
- {
- private ParsingContext _context;
-
- [TestInitialize]
- public void Setup()
- {
- _context = ParsingContext.Create();
- }
-
- [TestMethod]
- public void IsBlankShouldReturnTrueIfFirstArgIsNull()
- {
- var func = new IsBlank();
- var args = FunctionsHelper.CreateArgs(new object[]{null});
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsBlankShouldReturnTrueIfFirstArgIsEmptyString()
- {
- var func = new IsBlank();
- var args = FunctionsHelper.CreateArgs(string.Empty);
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsNumberShouldReturnTrueWhenArgIsNumeric()
- {
- var func = new IsNumber();
- var args = FunctionsHelper.CreateArgs(1d);
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsNumberShouldReturnfalseWhenArgIsNonNumeric()
- {
- var func = new IsNumber();
- var args = FunctionsHelper.CreateArgs("1");
- var result = func.Execute(args, _context);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void IsErrorShouldReturnTrueIfArgIsAnErrorCode()
- {
- var args = FunctionsHelper.CreateArgs(ExcelErrorValue.Parse("#DIV/0!"));
- var func = new IsError();
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsErrorShouldReturnFalseIfArgIsNotAnError()
- {
- var args = FunctionsHelper.CreateArgs("A", 1);
- var func = new IsError();
- var result = func.Execute(args, _context);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void IsTextShouldReturnTrueWhenFirstArgIsAString()
- {
- var args = FunctionsHelper.CreateArgs("1");
- var func = new IsText();
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsTextShouldReturnFalseWhenFirstArgIsNotAString()
- {
- var args = FunctionsHelper.CreateArgs(1);
- var func = new IsText();
- var result = func.Execute(args, _context);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void IsNonTextShouldReturnFalseWhenFirstArgIsAString()
- {
- var args = FunctionsHelper.CreateArgs("1");
- var func = new IsNonText();
- var result = func.Execute(args, _context);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void IsNonTextShouldReturnTrueWhenFirstArgIsNotAString()
- {
- var args = FunctionsHelper.CreateArgs(1);
- var func = new IsNonText();
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsOddShouldReturnCorrectResult()
- {
- var args = FunctionsHelper.CreateArgs(3.123);
- var func = new IsOdd();
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsEvenShouldReturnCorrectResult()
- {
- var args = FunctionsHelper.CreateArgs(4.123);
- var func = new IsEven();
- var result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IsLogicalShouldReturnCorrectResult()
- {
- var func = new IsLogical();
-
- var args = FunctionsHelper.CreateArgs(1);
- var result = func.Execute(args, _context);
- Assert.IsFalse((bool)result.Result);
-
- args = FunctionsHelper.CreateArgs("true");
- result = func.Execute(args, _context);
- Assert.IsFalse((bool)result.Result);
-
- args = FunctionsHelper.CreateArgs(false);
- result = func.Execute(args, _context);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void NshouldReturnCorrectResult()
- {
- var func = new N();
-
- var args = FunctionsHelper.CreateArgs(1.2);
- var result = func.Execute(args, _context);
- Assert.AreEqual(1.2, result.Result);
-
- args = FunctionsHelper.CreateArgs("abc");
- result = func.Execute(args, _context);
- Assert.AreEqual(0d, result.Result);
-
- args = FunctionsHelper.CreateArgs(true);
- result = func.Execute(args, _context);
- Assert.AreEqual(1d, result.Result);
-
- var errorCode = ExcelErrorValue.Create(eErrorType.Value);
- args = FunctionsHelper.CreateArgs(errorCode);
- result = func.Execute(args, _context);
- Assert.AreEqual(errorCode, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/LogicalFunctionsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/LogicalFunctionsTests.cs
deleted file mode 100644
index ac76bf2..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/LogicalFunctionsTests.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
-using OfficeOpenXml;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class LogicalFunctionsTests
- {
- private ParsingContext _parsingContext = ParsingContext.Create();
-
- [TestMethod]
- public void IfShouldReturnCorrectResult()
- {
- var func = new If();
- var args = FunctionsHelper.CreateArgs(true, "A", "B");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual("A", result.Result);
- }
-
- [TestMethod]
- public void NotShouldReturnFalseIfArgumentIsTrue()
- {
- var func = new Not();
- var args = FunctionsHelper.CreateArgs(true);
- var result = func.Execute(args, _parsingContext);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void NotShouldReturnTrueIfArgumentIs0()
- {
- var func = new Not();
- var args = FunctionsHelper.CreateArgs(0);
- var result = func.Execute(args, _parsingContext);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void NotShouldReturnFalseIfArgumentIs1()
- {
- var func = new Not();
- var args = FunctionsHelper.CreateArgs(1);
- var result = func.Execute(args, _parsingContext);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void NotShouldHandleExcelReference()
- {
- using(var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("sheet1");
- sheet.Cells["A1"].Value = false;
- sheet.Cells["A2"].Formula = "NOT(A1)";
- sheet.Calculate();
- Assert.IsTrue((bool)sheet.Cells["A2"].Value);
- }
- }
-
- [TestMethod]
- public void AndShouldReturnTrueIfAllArgumentsAreTrue()
- {
- var func = new And();
- var args = FunctionsHelper.CreateArgs(true, true, true);
- var result = func.Execute(args, _parsingContext);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void AndShouldReturnTrueIfAllArgumentsAreTrueOr1()
- {
- var func = new And();
- var args = FunctionsHelper.CreateArgs(true, true, 1, true, 1);
- var result = func.Execute(args, _parsingContext);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void AndShouldReturnFalseIfOneArgumentIsFalse()
- {
- var func = new And();
- var args = FunctionsHelper.CreateArgs(true, false, true);
- var result = func.Execute(args, _parsingContext);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void AndShouldReturnFalseIfOneArgumentIs0()
- {
- var func = new And();
- var args = FunctionsHelper.CreateArgs(true, 0, true);
- var result = func.Execute(args, _parsingContext);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void OrShouldReturnTrueIfOneArgumentIsTrue()
- {
- var func = new Or();
- var args = FunctionsHelper.CreateArgs(true, false, false);
- var result = func.Execute(args, _parsingContext);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void IfErrorShouldReturnSecondArgIfCriteriaEvaluatesAsAnError()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "IFERROR(0/0, \"hello\")";
- s1.Calculate();
- Assert.AreEqual("hello", s1.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void IfErrorShouldReturnSecondArgIfCriteriaEvaluatesAsAnError2()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "IFERROR(A2, \"hello\")";
- s1.Cells["A2"].Formula = "23/0";
- s1.Calculate();
- Assert.AreEqual("hello", s1.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void IfErrorShouldReturnResultOfFormulaIfNoError()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "IFERROR(A2, \"hello\")";
- s1.Cells["A2"].Value = "hi there";
- s1.Calculate();
- Assert.AreEqual("hi there", s1.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void IfNaShouldReturnSecondArgIfCriteriaEvaluatesAsAnError2()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "IFERROR(A2, \"hello\")";
- s1.Cells["A2"].Value = ExcelErrorValue.Create(eErrorType.NA);
- s1.Calculate();
- Assert.AreEqual("hello", s1.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void IfNaShouldReturnResultOfFormulaIfNoError()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "IFNA(A2, \"hello\")";
- s1.Cells["A2"].Value = "hi there";
- s1.Calculate();
- Assert.AreEqual("hi there", s1.Cells["A1"].Value);
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageATests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageATests.cs
deleted file mode 100644
index 08aaae8..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageATests.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Math
-{
- [TestClass]
- public class AverageATests
- {
- [TestMethod]
- public void AverageALiterals()
- {
- // For literals, AverageA always parses and include numeric strings, date strings, bools, etc.
- // The only exception is unparsable string literals, which cause a #VALUE.
- AverageA average = new AverageA();
- var date1 = new DateTime(2013, 1, 5);
- var date2 = new DateTime(2013, 1, 15);
- double value1 = 1000;
- double value2 = 2000;
- double value3 = 6000;
- double value4 = 1;
- double value5 = date1.ToOADate();
- double value6 = date2.ToOADate();
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(value1.ToString("n")),
- new FunctionArgument(value2),
- new FunctionArgument(value3.ToString("n")),
- new FunctionArgument(true),
- new FunctionArgument(date1),
- new FunctionArgument(date2.ToString("d"))
- }, ParsingContext.Create());
- Assert.AreEqual((value1 + value2 + value3 + value4 + value5 + value6) / 6, result.Result);
- }
-
- [TestMethod]
- public void AverageACellReferences()
- {
- // For cell references, AverageA divides by all cells, but only adds actual numbers, dates, and booleans.
- ExcelPackage package = new ExcelPackage();
- var worksheet = package.Workbook.Worksheets.Add("Test");
- double[] values =
- {
- 0,
- 2000,
- 0,
- 1,
- new DateTime(2013, 1, 5).ToOADate(),
- 0
- };
- ExcelRange range1 = worksheet.Cells[1, 1];
- range1.Formula = "\"1000\"";
- range1.Calculate();
- var range2 = worksheet.Cells[1, 2];
- range2.Value = 2000;
- var range3 = worksheet.Cells[1, 3];
- range3.Formula = $"\"{new DateTime(2013, 1, 5).ToString("d")}\"";
- range3.Calculate();
- var range4 = worksheet.Cells[1, 4];
- range4.Value = true;
- var range5 = worksheet.Cells[1, 5];
- range5.Value = new DateTime(2013, 1, 5);
- var range6 = worksheet.Cells[1, 6];
- range6.Value = "Test";
- AverageA average = new AverageA();
- var rangeInfo1 = new EpplusExcelDataProvider.RangeInfo(worksheet, 1, 1, 1, 3);
- var rangeInfo2 = new EpplusExcelDataProvider.RangeInfo(worksheet, 1, 4, 1, 4);
- var rangeInfo3 = new EpplusExcelDataProvider.RangeInfo(worksheet, 1, 5, 1, 6);
- var context = ParsingContext.Create();
- var address = new OfficeOpenXml.FormulaParsing.ExcelUtilities.RangeAddress();
- address.FromRow = address.ToRow = address.FromCol = address.ToCol = 2;
- context.Scopes.NewScope(address);
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(rangeInfo1),
- new FunctionArgument(rangeInfo2),
- new FunctionArgument(rangeInfo3)
- }, context);
- Assert.AreEqual(values.Average(), result.Result);
- }
-
- [TestMethod]
- public void AverageAArray()
- {
- // For arrays, AverageA completely ignores booleans. It divides by strings and numbers, but only
- // numbers are added to the total. Real dates cannot be specified and string dates are not parsed.
- AverageA average = new AverageA();
- var date = new DateTime(2013, 1, 15);
- double[] values =
- {
- 0,
- 2000,
- 0,
- 0,
- 0
- };
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(new FunctionArgument[]
- {
- new FunctionArgument(1000.ToString("n")),
- new FunctionArgument(2000),
- new FunctionArgument(6000.ToString("n")),
- new FunctionArgument(true),
- new FunctionArgument(date.ToString("d")),
- new FunctionArgument("test")
- })
- }, ParsingContext.Create());
- Assert.AreEqual(values.Average(), result.Result);
- }
-
- [TestMethod]
- [ExpectedException(typeof(ExcelErrorValueException))]
- public void AverageAUnparsableLiteral()
- {
- // In the case of literals, any unparsable string literal results in a #VALUE.
- AverageA average = new AverageA();
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(1000),
- new FunctionArgument("Test")
- }, ParsingContext.Create());
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageIfTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageIfTests.cs
deleted file mode 100644
index 4859498..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageIfTests.cs
+++ /dev/null
@@ -1,286 +0,0 @@
-using EPPlusTest.FormulaParsing.TestHelpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using static OfficeOpenXml.FormulaParsing.ExcelDataProvider;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Math
-{
- [TestClass]
- public class AverageIfTests
- {
- private ExcelPackage _package;
- private EpplusExcelDataProvider _provider;
- private ParsingContext _parsingContext;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _provider = new EpplusExcelDataProvider(_package);
- _parsingContext = ParsingContext.Create();
- _parsingContext.Scopes.NewScope(RangeAddress.Empty);
- _worksheet = _package.Workbook.Worksheets.Add("testsheet");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void AverageIfNumeric()
- {
- _worksheet.Cells["A1"].Value = 1d;
- _worksheet.Cells["A2"].Value = 2d;
- _worksheet.Cells["A3"].Value = 3d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">1", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(4d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfNonNumeric()
- {
- _worksheet.Cells["A1"].Value = "Monday";
- _worksheet.Cells["A2"].Value = "Tuesday";
- _worksheet.Cells["A3"].Value = "Thursday";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "T*day", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(4d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfNumericExpression()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = 1d;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new AverageIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, 1d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfEqualToEmptyString()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfNotEqualToNull()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<>", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(4d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 0d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfNotEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 0d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<>0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfGreaterThanZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfGreaterThanOrEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">=0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfLessThanZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = -1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfLessThanOrEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = -1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<=0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfLessThanCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfLessThanOrEqualToCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<=a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfGreaterThanCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void AverageIfGreaterThanOrEqualToCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new AverageIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">=a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageTests.cs
deleted file mode 100644
index d5a09c4..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Math/AverageTests.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Math
-{
- [TestClass]
- public class AverageTests
- {
- [TestMethod]
- public void AverageLiterals()
- {
- // In the case of literals, Average DOES parse and include numeric strings, date strings, bools, etc.
- Average average = new Average();
- var date1 = new DateTime(2013, 1, 5);
- var date2 = new DateTime(2013, 1, 15);
- double value1 = 1000;
- double value2 = 2000;
- double value3 = 6000;
- double value4 = 1;
- double value5 = date1.ToOADate();
- double value6 = date2.ToOADate();
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(value1.ToString("n")),
- new FunctionArgument(value2),
- new FunctionArgument(value3.ToString("n")),
- new FunctionArgument(true),
- new FunctionArgument(date1),
- new FunctionArgument(date2.ToString("d"))
- }, ParsingContext.Create());
- Assert.AreEqual((value1 + value2 + value3 + value4 + value5 + value6) / 6, result.Result);
- }
-
- [TestMethod]
- public void AverageCellReferences()
- {
- // In the case of cell references, Average DOES NOT parse and include numeric strings, date strings, bools, unparsable strings, etc.
- ExcelPackage package = new ExcelPackage();
- var worksheet = package.Workbook.Worksheets.Add("Test");
- ExcelRange range1 = worksheet.Cells[1, 1];
- range1.Formula = "\"1000\"";
- range1.Calculate();
- var range2 = worksheet.Cells[1, 2];
- range2.Value = 2000;
- var range3 = worksheet.Cells[1, 3];
- range3.Formula = $"\"{new DateTime(2013, 1, 5).ToString("d")}\"";
- range3.Calculate();
- var range4 = worksheet.Cells[1, 4];
- range4.Value = true;
- var range5 = worksheet.Cells[1, 5];
- range5.Value = new DateTime(2013, 1, 5);
- var range6 = worksheet.Cells[1, 6];
- range6.Value = "Test";
- Average average = new Average();
- var rangeInfo1 = new EpplusExcelDataProvider.RangeInfo(worksheet, 1, 1, 1, 3);
- var rangeInfo2 = new EpplusExcelDataProvider.RangeInfo(worksheet, 1, 4, 1, 4);
- var rangeInfo3 = new EpplusExcelDataProvider.RangeInfo(worksheet, 1, 5, 1, 6);
- var context = ParsingContext.Create();
- var address = new OfficeOpenXml.FormulaParsing.ExcelUtilities.RangeAddress();
- address.FromRow = address.ToRow = address.FromCol = address.ToCol = 2;
- context.Scopes.NewScope(address);
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(rangeInfo1),
- new FunctionArgument(rangeInfo2),
- new FunctionArgument(rangeInfo3)
- }, context);
- Assert.AreEqual((2000 + new DateTime(2013, 1, 5).ToOADate()) / 2, result.Result);
- }
-
- [TestMethod]
- public void AverageArray()
- {
- // In the case of arrays, Average DOES NOT parse and include numeric strings, date strings, bools, unparsable strings, etc.
- Average average = new Average();
- var date1 = new DateTime(2013, 1, 5);
- var date2 = new DateTime(2013, 1, 15);
- double value = 2000;
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(new FunctionArgument[]
- {
- new FunctionArgument(1000.ToString("n")),
- new FunctionArgument(value),
- new FunctionArgument(6000.ToString("n")),
- new FunctionArgument(true),
- new FunctionArgument(date1),
- new FunctionArgument(date2.ToString("d")),
- new FunctionArgument("test")
- })
- }, ParsingContext.Create());
- Assert.AreEqual((2000 + date1.ToOADate()) / 2, result.Result);
- }
-
- [TestMethod]
- [ExpectedException(typeof(ExcelErrorValueException))]
- public void AverageUnparsableLiteral()
- {
- // In the case of literals, any unparsable string literal results in a #VALUE.
- Average average = new Average();
- var result = average.Execute(new FunctionArgument[]
- {
- new FunctionArgument(1000),
- new FunctionArgument("Test")
- }, ParsingContext.Create());
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Math/CountIfTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Math/CountIfTests.cs
deleted file mode 100644
index a4b9616..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Math/CountIfTests.cs
+++ /dev/null
@@ -1,244 +0,0 @@
-using EPPlusTest.FormulaParsing.TestHelpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using static OfficeOpenXml.FormulaParsing.ExcelDataProvider;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Math
-{
- [TestClass]
- public class CountIfTests
- {
- private ExcelPackage _package;
- private EpplusExcelDataProvider _provider;
- private ParsingContext _parsingContext;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _provider = new EpplusExcelDataProvider(_package);
- _parsingContext = ParsingContext.Create();
- _parsingContext.Scopes.NewScope(RangeAddress.Empty);
- _worksheet = _package.Workbook.Worksheets.Add("testsheet");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void CountIfNumeric()
- {
- _worksheet.Cells["A1"].Value = 1d;
- _worksheet.Cells["A2"].Value = 2d;
- _worksheet.Cells["A3"].Value = 3d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, ">1");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void CountIfNonNumeric()
- {
- _worksheet.Cells["A1"].Value = "Monday";
- _worksheet.Cells["A2"].Value = "Tuesday";
- _worksheet.Cells["A3"].Value = "Thursday";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "T*day");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- public void CountIfNullExpression()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = 1d;
- _worksheet.Cells["A3"].Value = null;
- _worksheet.Cells["B2"].Value = null;
- var func = new CountIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 2, 2, 2, 2);
- var args = FunctionsHelper.CreateArgs(range1, range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(0d, result.Result);
- }
-
- [TestMethod]
- public void CountIfNumericExpression()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = 1d;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, 1d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
-[TestMethod]
- public void CountIfEqualToEmptyString()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfNotEqualToNull()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "<>");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void CountIfEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 0d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "0");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfNotEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 0d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "<>0");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void CountIfGreaterThanZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 1d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, ">0");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfGreaterThanOrEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 1d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, ">=0");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfLessThanZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = -1d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "<0");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfLessThanOrEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = -1d;
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "<=0");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfLessThanCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "<a");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfLessThanOrEqualToCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, "<=a");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfGreaterThanCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, ">a");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CountIfGreaterThanOrEqualToCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new CountIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, ">=a");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/Math/SumIfTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/Math/SumIfTests.cs
deleted file mode 100644
index 3ef11ef..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/Math/SumIfTests.cs
+++ /dev/null
@@ -1,319 +0,0 @@
-using EPPlusTest.FormulaParsing.TestHelpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using static OfficeOpenXml.FormulaParsing.ExcelDataProvider;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.Math
-{
- [TestClass]
- public class SumIfTests
- {
- private ExcelPackage _package;
- private EpplusExcelDataProvider _provider;
- private ParsingContext _parsingContext;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _provider = new EpplusExcelDataProvider(_package);
- _parsingContext = ParsingContext.Create();
- _parsingContext.Scopes.NewScope(RangeAddress.Empty);
- _worksheet = _package.Workbook.Worksheets.Add("testsheet");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void SumIfNumeric()
- {
- _worksheet.Cells["A1"].Value = 1d;
- _worksheet.Cells["A2"].Value = 2d;
- _worksheet.Cells["A3"].Value = 3d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">1", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(8d, result.Result);
- }
-
- [TestMethod]
- public void SumIfNonNumeric()
- {
- _worksheet.Cells["A1"].Value = "Monday";
- _worksheet.Cells["A2"].Value = "Tuesday";
- _worksheet.Cells["A3"].Value = "Thursday";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "T*day", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(8d, result.Result);
- }
-
- [TestMethod]
- public void SumIfNumericExpression()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = 1d;
- _worksheet.Cells["A3"].Value = "Not Empty";
- var func = new SumIf();
- IRangeInfo range = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- var args = FunctionsHelper.CreateArgs(range, 1d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void SumIfEqualToEmptyString()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void SumIfNotEqualToNull()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<>", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(8d, result.Result);
- }
-
- [TestMethod]
- public void SumIfEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 0d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfNotEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 0d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<>0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(4d, result.Result);
- }
-
- [TestMethod]
- public void SumIfGreaterThanZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfGreaterThanOrEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = 1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">=0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfLessThanZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = -1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfLessThanOrEqualToZero()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = -1d;
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<=0", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfLessThanCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void SumIfLessThanOrEqualToCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, "<=a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void SumIfGreaterThanCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfGreaterThanOrEqualToCharacter()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">=a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfHandleDates()
- {
- _worksheet.Cells["A1"].Value = null;
- _worksheet.Cells["A2"].Value = string.Empty;
- _worksheet.Cells["A3"].Value = "Not Empty";
- _worksheet.Cells["B1"].Value = 1d;
- _worksheet.Cells["B2"].Value = 3d;
- _worksheet.Cells["B3"].Value = 5d;
- var func = new SumIf();
- IRangeInfo range1 = _provider.GetRange(_worksheet.Name, 1, 1, 3, 1);
- IRangeInfo range2 = _provider.GetRange(_worksheet.Name, 1, 2, 3, 2);
- var args = FunctionsHelper.CreateArgs(range1, ">=a", range2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumIfShouldHandleBooleanArg()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = true;
- sheet.Cells["B1"].Value = 1;
- sheet.Cells["A2"].Value = false;
- sheet.Cells["B2"].Value = 1;
- sheet.Cells["C1"].Formula = "SUMIF(A1:A2,TRUE,B1:B2)";
- sheet.Calculate();
- Assert.AreEqual(1d, sheet.Cells["C1"].Value);
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/MathFunctionsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/MathFunctionsTests.cs
deleted file mode 100644
index de21e10..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/MathFunctionsTests.cs
+++ /dev/null
@@ -1,1056 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Threading;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.Excel;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class MathFunctionsTests
- {
- private ParsingContext _parsingContext;
-
- [TestInitialize]
- public void Initialize()
- {
- _parsingContext = ParsingContext.Create();
- _parsingContext.Scopes.NewScope(RangeAddress.Empty);
- }
-
- [TestMethod]
- public void PiShouldReturnPIConstant()
- {
- var expectedValue = (double)Math.Round(Math.PI, 14);
- var func = new Pi();
- var args = FunctionsHelper.CreateArgs(0);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod]
- public void AbsShouldReturnCorrectResult()
- {
- var expectedValue = 3d;
- var func = new Abs();
- var args = FunctionsHelper.CreateArgs(-3d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod]
- public void AsinShouldReturnCorrectResult()
- {
- const double expectedValue = 1.5708;
- var func = new Asin();
- var args = FunctionsHelper.CreateArgs(1d);
- var result = func.Execute(args, _parsingContext);
- var rounded = Math.Round((double)result.Result, 4);
- Assert.AreEqual(expectedValue, rounded);
- }
-
- [TestMethod]
- public void AsinhShouldReturnCorrectResult()
- {
- const double expectedValue = 0.0998;
- var func = new Asinh();
- var args = FunctionsHelper.CreateArgs(0.1d);
- var result = func.Execute(args, _parsingContext);
- var rounded = Math.Round((double)result.Result, 4);
- Assert.AreEqual(expectedValue, rounded);
- }
-
- [TestMethod]
- public void CeilingShouldRoundUpAccordingToParamsSignificanceLowerThan0()
- {
- var expectedValue = 22.36d;
- var func = new Ceiling();
- var args = FunctionsHelper.CreateArgs(22.35d, 0.01);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod]
- public void CeilingShouldRoundTowardsZeroIfSignificanceAndNumberIsMinus0point1()
- {
- var expectedValue = -22.4d;
- var func = new Ceiling();
- var args = FunctionsHelper.CreateArgs(-22.35d, -0.1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, System.Math.Round((double)result.Result, 2));
- }
-
- [TestMethod]
- public void CeilingShouldRoundUpAccordingToParamsSignificanceIs1()
- {
- var expectedValue = 23d;
- var func = new Ceiling();
- var args = FunctionsHelper.CreateArgs(22.35d, 1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod]
- public void CeilingShouldRoundUpAccordingToParamsSignificanceIs10()
- {
- var expectedValue = 30d;
- var func = new Ceiling();
- var args = FunctionsHelper.CreateArgs(22.35d, 10);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod]
- public void CeilingShouldRoundTowardsZeroIfSignificanceAndNumberIsNegative()
- {
- var expectedValue = -30d;
- var func = new Ceiling();
- var args = FunctionsHelper.CreateArgs(-22.35d, -10);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void CeilingShouldThrowExceptionIfNumberIsPositiveAndSignificanceIsNegative()
- {
- var expectedValue = 30d;
- var func = new Ceiling();
- var args = FunctionsHelper.CreateArgs(22.35d, -1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedValue, result.Result);
- }
-
- [TestMethod]
- public void SumShouldCalculate2Plus3AndReturn5()
- {
- var func = new Sum();
- var args = FunctionsHelper.CreateArgs(2, 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void SumShouldCalculateEnumerableOf2Plus5Plus3AndReturn10()
- {
- var func = new Sum();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(2, 5), 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(10d, result.Result);
- }
-
- [TestMethod]
- public void SumShouldIgnoreHiddenValuesWhenIgnoreHiddenValuesIsSet()
- {
- var func = new Sum();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(2, 5), 3, 4);
- args.Last().SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(10d, result.Result);
- }
-
- [TestMethod]
- public void SumIfShouldCalculateMatchingValuesOnly()
- {
- var func = new SumIf();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(3, 4, 5), "4");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(4d, result.Result);
- }
-
- [TestMethod]
- public void SumIfShouldCalculateWithExpression()
- {
- var func = new SumIf();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(3, 4, 5), ">3");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(9d, result.Result);
- }
-
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void SumIfShouldThrowIfCriteriaIsLargerThan255Chars()
- {
- var longString = "a";
- for (var x = 0; x < 256; x++) { longString = string.Concat(longString, "a"); }
- var func = new SumIf();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(3, 4, 5), longString, (FunctionsHelper.CreateArgs(3, 2, 1)));
- var result = func.Execute(args, _parsingContext);
- }
-
- [TestMethod]
- public void SumSqShouldCalculateArray()
- {
- var func = new Sumsq();
- var args = FunctionsHelper.CreateArgs(2, 4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(20d, result.Result);
- }
-
- [TestMethod]
- public void SumSqShouldIncludeTrueAsOne()
- {
- var func = new Sumsq();
- var args = FunctionsHelper.CreateArgs(2, 4, true);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(21d, result.Result);
- }
-
- [TestMethod]
- public void SumSqShouldNoCountTrueTrueInArray()
- {
- var func = new Sumsq();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(2, 4, true));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(20d, result.Result);
- }
-
- [TestMethod]
- public void StdevShouldCalculateCorrectResult()
- {
- var func = new Stdev();
- var args = FunctionsHelper.CreateArgs(1, 3, 5);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void StdevShouldIgnoreHiddenValuesWhenIgnoreHiddenValuesIsSet()
- {
- var func = new Stdev();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(1, 3, 5, 6);
- args.Last().SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void StdevPShouldCalculateCorrectResult()
- {
- var func = new StdevP();
- var args = FunctionsHelper.CreateArgs(2, 3, 4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(0.8165d, Math.Round((double)result.Result, 5));
- }
-
- [TestMethod]
- public void StdevPShouldIgnoreHiddenValuesWhenIgnoreHiddenValuesIsSet()
- {
- var func = new StdevP();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(2, 3, 4, 165);
- args.Last().SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(0.8165d, Math.Round((double)result.Result, 5));
- }
-
- [TestMethod]
- public void ExpShouldCalculateCorrectResult()
- {
- var func = new Exp();
- var args = FunctionsHelper.CreateArgs(4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(54.59815003d, System.Math.Round((double)result.Result, 8));
- }
-
- [TestMethod]
- public void MaxShouldCalculateCorrectResult()
- {
- var func = new Max();
- var args = FunctionsHelper.CreateArgs(4, 2, 5, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void MaxShouldIgnoreHiddenValuesIfIgnoreHiddenValuesIsTrue()
- {
- var func = new Max();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(4, 2, 5, 2);
- args.ElementAt(2).SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(4d, result.Result);
- }
-
- [TestMethod]
- public void MaxaShouldCalculateCorrectResult()
- {
- var func = new Maxa();
- var args = FunctionsHelper.CreateArgs(-1, 0, 1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void MaxaShouldCalculateCorrectResultUsingBool()
- {
- var func = new Maxa();
- var args = FunctionsHelper.CreateArgs(-1, 0, true);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void MaxaShouldCalculateCorrectResultUsingString()
- {
- var func = new Maxa();
- var args = FunctionsHelper.CreateArgs(-1, "test");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(0d, result.Result);
- }
-
- [TestMethod]
- public void MinShouldCalculateCorrectResult()
- {
- var func = new Min();
- var args = FunctionsHelper.CreateArgs(4, 2, 5, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void MinShouldIgnoreHiddenValuesIfIgnoreHiddenValuesIsTrue()
- {
- var func = new Min();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(4, 2, 5, 3);
- args.ElementAt(1).SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void AverageShouldCalculateCorrectResult()
- {
- var expectedResult = (4d + 2d + 5d + 2d) / 4d;
- var func = new Average();
- var args = FunctionsHelper.CreateArgs(4d, 2d, 5d, 2d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod]
- public void AverageShouldCalculateCorrectResultWithEnumerableAndBoolMembers()
- {
- var expectedResult = (4d + 2d + 5d + 2d + 1d) / 5d;
- var func = new Average();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4d, 2d), 5d, 2d, true);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod]
- public void AverageShouldIgnoreHiddenFieldsIfIgnoreHiddenValuesIsTrue()
- {
- var expectedResult = (4d + 2d + 2d + 1d) / 4d;
- var func = new Average();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4d, 2d), 5d, 2d, true);
- args.ElementAt(1).SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod]
- public void AverageShouldThrowDivByZeroExcelErrorValueIfEmptyArgs()
- {
- eErrorType errorType = eErrorType.Value;
-
- var func = new Average();
- var args = new FunctionArgument[0];
- try
- {
- func.Execute(args, _parsingContext);
- }
- catch (ExcelErrorValueException e)
- {
- errorType = e.ErrorValue.Type;
- }
- Assert.AreEqual(eErrorType.Div0, errorType);
- }
-
- [TestMethod]
- public void AverageAShouldCalculateCorrectResult()
- {
- var expectedResult = (4d + 2d + 5d + 2d) / 4d;
- var func = new AverageA();
- var args = FunctionsHelper.CreateArgs(4d, 2d, 5d, 2d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod]
- public void AverageAShouldIncludeTrueAs1()
- {
- var expectedResult = (4d + 2d + 5d + 2d + 1d) / 5d;
- var func = new AverageA();
- var args = FunctionsHelper.CreateArgs(4d, 2d, 5d, 2d, true);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void AverageAShouldThrowValueExceptionIfNonNumericTextIsSupplied()
- {
- var func = new AverageA();
- var args = FunctionsHelper.CreateArgs(4d, 2d, 5d, 2d, "ABC");
- var result = func.Execute(args, _parsingContext);
- }
-
- [TestMethod]
- public void AverageAShouldCountValueAs0IfNonNumericTextIsSuppliedInArray()
- {
- var func = new AverageA();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(1d, 2d, 3d, "ABC"));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1.5d,result.Result);
- }
-
- [TestMethod]
- public void AverageAShouldCountNumericStringWithValue()
- {
- var func = new AverageA();
- var args = FunctionsHelper.CreateArgs(4d, 2d, "9");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void RoundShouldReturnCorrectResult()
- {
- var func = new Round();
- var args = FunctionsHelper.CreateArgs(2.3433, 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2.343d, result.Result);
- }
-
- [TestMethod]
- public void RoundShouldReturnCorrectResultWhenNbrOfDecimalsIsNegative()
- {
- var func = new Round();
- var args = FunctionsHelper.CreateArgs(9333, -3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(9000d, result.Result);
- }
-
- [TestMethod]
- public void FloorShouldReturnCorrectResultWhenSignificanceIsBetween0And1()
- {
- var func = new Floor();
- var args = FunctionsHelper.CreateArgs(26.75d, 0.1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(26.7d, result.Result);
- }
-
- [TestMethod]
- public void FloorShouldReturnCorrectResultWhenSignificanceIs1()
- {
- var func = new Floor();
- var args = FunctionsHelper.CreateArgs(26.75d, 1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(26d, result.Result);
- }
-
- [TestMethod]
- public void FloorShouldReturnCorrectResultWhenSignificanceIsMinus1()
- {
- var func = new Floor();
- var args = FunctionsHelper.CreateArgs(-26.75d, -1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(-26d, result.Result);
- }
-
- [TestMethod]
- public void RandShouldReturnAValueBetween0and1()
- {
- var func = new Rand();
- var args = new FunctionArgument[0];
- var result1 = func.Execute(args, _parsingContext);
- Assert.IsTrue(((double)result1.Result) > 0 && ((double) result1.Result) < 1);
- var result2 = func.Execute(args, _parsingContext);
- Assert.AreNotEqual(result1.Result, result2.Result, "The two numbers were the same");
- Assert.IsTrue(((double)result2.Result) > 0 && ((double)result2.Result) < 1);
- }
-
- [TestMethod]
- public void RandBetweenShouldReturnAnIntegerValueBetweenSuppliedValues()
- {
- var func = new RandBetween();
- var args = FunctionsHelper.CreateArgs(1, 5);
- var result = func.Execute(args, _parsingContext);
- CollectionAssert.Contains(new List<double> { 1d, 2d, 3d, 4d, 5d }, result.Result);
- }
-
- [TestMethod]
- public void RandBetweenShouldReturnAnIntegerValueBetweenSuppliedValuesWhenLowIsNegative()
- {
- var func = new RandBetween();
- var args = FunctionsHelper.CreateArgs(-5, 0);
- var result = func.Execute(args, _parsingContext);
- CollectionAssert.Contains(new List<double> { 0d, -1d, -2d, -3d, -4d, -5d }, result.Result);
- }
-
- [TestMethod]
- public void CountShouldReturnNumberOfNumericItems()
- {
- var func = new Count();
- var args = FunctionsHelper.CreateArgs(1d, 2m, 3, new DateTime(2012, 4, 1), "4");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void CountShouldIncludeNumericStringsAndDatesInArray()
- {
- var func = new Count();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(1d, 2m, 3, new DateTime(2012, 4, 1), "4"));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
-
- [TestMethod]
- public void CountShouldIncludeEnumerableMembers()
- {
- var func = new Count();
- var args = FunctionsHelper.CreateArgs(1d, FunctionsHelper.CreateArgs(12, 13));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod, Ignore]
- public void CountShouldIgnoreHiddenValuesIfIgnoreHiddenValuesIsTrue()
- {
- var func = new Count();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(1d, FunctionsHelper.CreateArgs(12, 13));
- args.ElementAt(0).SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void CountAShouldReturnNumberOfNonWhitespaceItems()
- {
- var func = new CountA();
- var args = FunctionsHelper.CreateArgs(1d, 2m, 3, new DateTime(2012, 4, 1), "4", null, string.Empty);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void CountAShouldIncludeEnumerableMembers()
- {
- var func = new CountA();
- var args = FunctionsHelper.CreateArgs(1d, FunctionsHelper.CreateArgs(12, 13));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void CountAShouldIgnoreHiddenValuesIfIgnoreHiddenValuesIsTrue()
- {
- var func = new CountA();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(1d, FunctionsHelper.CreateArgs(12, 13));
- args.ElementAt(0).SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void CountIfShouldReturnNbrOfNumericItemsThatMatch()
- {
- var func = new CountIf();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(1d, 2d, 3d), ">1");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void CountIfShouldReturnNbrOfAlphaNumItemsThatMatch()
- {
- var func = new CountIf();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs("Monday", "Tuesday", "Thursday"), "T*day");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod]
- public void ProductShouldMultiplyArguments()
- {
- var func = new Product();
- var args = FunctionsHelper.CreateArgs(2d, 2d, 4d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(16d, result.Result);
- }
-
- [TestMethod]
- public void ProductShouldHandleEnumerable()
- {
- var func = new Product();
- var args = FunctionsHelper.CreateArgs(2d, 2d, FunctionsHelper.CreateArgs(4d, 2d));
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(32d, result.Result);
- }
-
- [TestMethod]
- public void ProductShouldIgnoreHiddenValuesIfIgnoreHiddenIsTrue()
- {
- var func = new Product();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(2d, 2d, FunctionsHelper.CreateArgs(4d, 2d));
- args.ElementAt(1).SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(16d, result.Result);
- }
-
- [TestMethod]
- public void ProductShouldHandleFirstItemIsEnumerable()
- {
- var func = new Product();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4d, 2d), 2d, 2d);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(32d, result.Result);
- }
-
- [TestMethod]
- public void VarShouldReturnCorrectResult()
- {
- var func = new Var();
- var args = FunctionsHelper.CreateArgs(1, 2, 3, 4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1.6667d, System.Math.Round((double)result.Result, 4));
- }
-
- [TestMethod]
- public void VarShouldIgnoreHiddenValuesIfIgnoreHiddenIsTrue()
- {
- var func = new Var();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(1, 2, 3, 4, 9);
- args.Last().SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1.6667d, System.Math.Round((double)result.Result, 4));
- }
-
- [TestMethod]
- public void VarPShouldReturnCorrectResult()
- {
- var func = new VarP();
- var args = FunctionsHelper.CreateArgs(1, 2, 3, 4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1.25d, result.Result);
- }
-
- [TestMethod]
- public void VarPShouldIgnoreHiddenValuesIfIgnoreHiddenIsTrue()
- {
- var func = new VarP();
- func.IgnoreHiddenValues = true;
- var args = FunctionsHelper.CreateArgs(1, 2, 3, 4, 9);
- args.Last().SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1.25d, result.Result);
- }
-
- [TestMethod]
- public void ModShouldReturnCorrectResult()
- {
- var func = new Mod();
- var args = FunctionsHelper.CreateArgs(5, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void CosShouldReturnCorrectResult()
- {
- var func = new Cos();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(-0.416146837d, roundedResult);
- }
-
- [TestMethod]
- public void CosHShouldReturnCorrectResult()
- {
- var func = new Cosh();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(3.762195691, roundedResult);
- }
-
- [TestMethod]
- public void AcosShouldReturnCorrectResult()
- {
- var func = new Acos();
- var args = FunctionsHelper.CreateArgs(0.1);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 4);
- Assert.AreEqual(1.4706, roundedResult);
- }
-
- [TestMethod]
- public void ACosHShouldReturnCorrectResult()
- {
- var func = new Acosh();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 3);
- Assert.AreEqual(1.317, roundedResult);
- }
-
- [TestMethod]
- public void SinShouldReturnCorrectResult()
- {
- var func = new Sin();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(0.909297427, roundedResult);
- }
-
- [TestMethod]
- public void SinhShouldReturnCorrectResult()
- {
- var func = new Sinh();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(3.626860408d, roundedResult);
- }
-
- [TestMethod]
- public void TanShouldReturnCorrectResult()
- {
- var func = new Tan();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(-2.185039863d, roundedResult);
- }
-
- [TestMethod]
- public void TanhShouldReturnCorrectResult()
- {
- var func = new Tanh();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(0.96402758d, roundedResult);
- }
-
- [TestMethod]
- public void AtanShouldReturnCorrectResult()
- {
- var func = new Atan();
- var args = FunctionsHelper.CreateArgs(10);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double) result.Result, 9);
- Assert.AreEqual(1.471127674d, roundedResult);
- }
-
- [TestMethod]
- public void Atan2ShouldReturnCorrectResult()
- {
- var func = new Atan2();
- var args = FunctionsHelper.CreateArgs(1,2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(1.107148718d, roundedResult);
- }
-
- [TestMethod]
- public void AtanhShouldReturnCorrectResult()
- {
- var func = new Atanh();
- var args = FunctionsHelper.CreateArgs(0.1);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 4);
- Assert.AreEqual(0.1003d, roundedResult);
- }
-
- [TestMethod]
- public void LogShouldReturnCorrectResult()
- {
- var func = new Log();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(0.301029996d, roundedResult);
- }
-
- [TestMethod]
- public void LogShouldReturnCorrectResultWithBase()
- {
- var func = new Log();
- var args = FunctionsHelper.CreateArgs(2, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void Log10ShouldReturnCorrectResult()
- {
- var func = new Log10();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(0.301029996d, roundedResult);
- }
-
- [TestMethod]
- public void LnShouldReturnCorrectResult()
- {
- var func = new Ln();
- var args = FunctionsHelper.CreateArgs(5);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 5);
- Assert.AreEqual(1.60944d, roundedResult);
- }
-
- [TestMethod]
- public void SqrtPiShouldReturnCorrectResult()
- {
- var func = new SqrtPi();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext);
- var roundedResult = Math.Round((double)result.Result, 9);
- Assert.AreEqual(2.506628275d, roundedResult);
- }
-
- [TestMethod]
- public void SignShouldReturnMinus1IfArgIsNegative()
- {
- var func = new Sign();
- var args = FunctionsHelper.CreateArgs(-2);
- var result = func.Execute(args, _parsingContext).Result;
- Assert.AreEqual(-1d, result);
- }
-
- [TestMethod]
- public void SignShouldReturn1IfArgIsPositive()
- {
- var func = new Sign();
- var args = FunctionsHelper.CreateArgs(2);
- var result = func.Execute(args, _parsingContext).Result;
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void RounddownShouldReturnCorrectResultWithPositiveNumber()
- {
- var func = new Rounddown();
- var args = FunctionsHelper.CreateArgs(9.999, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(9.99, result.Result);
- }
-
- [TestMethod]
- public void RounddownShouldHandleNegativeNumber()
- {
- var func = new Rounddown();
- var args = FunctionsHelper.CreateArgs(-9.999, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(-9.99, result.Result);
- }
-
- [TestMethod]
- public void RounddownShouldHandleNegativeNumDigits()
- {
- var func = new Rounddown();
- var args = FunctionsHelper.CreateArgs(999.999, -2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(900d, result.Result);
- }
-
- [TestMethod]
- public void RounddownShouldReturn0IfNegativeNumDigitsIsTooLarge()
- {
- var func = new Rounddown();
- var args = FunctionsHelper.CreateArgs(999.999, -4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(0d, result.Result);
- }
-
- [TestMethod]
- public void RounddownShouldHandleZeroNumDigits()
- {
- var func = new Rounddown();
- var args = FunctionsHelper.CreateArgs(999.999, 0);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(999d, result.Result);
- }
-
- [TestMethod]
- public void RoundupShouldReturnCorrectResultWithPositiveNumber()
- {
- var func = new Roundup();
- var args = FunctionsHelper.CreateArgs(9.9911, 3);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(9.992, result.Result);
- }
-
- [TestMethod]
- public void RoundupShouldHandleNegativeNumDigits()
- {
- var func = new Roundup();
- var args = FunctionsHelper.CreateArgs(99123, -2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(99200d, result.Result);
- }
-
- [TestMethod]
- public void RoundupShouldHandleZeroNumDigits()
- {
- var func = new Roundup();
- var args = FunctionsHelper.CreateArgs(999.999, 0);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1000d, result.Result);
- }
-
- [TestMethod]
- public void TruncShouldReturnCorrectResult()
- {
- var func = new Trunc();
- var args = FunctionsHelper.CreateArgs(99.99);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(99d, result.Result);
- }
-
- [TestMethod]
- public void FactShouldRoundDownAndReturnCorrectResult()
- {
- var func = new Fact();
- var args = FunctionsHelper.CreateArgs(5.99);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(120d, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof (ExcelErrorValueException))]
- public void FactShouldThrowWhenNegativeNumber()
- {
- var func = new Fact();
- var args = FunctionsHelper.CreateArgs(-1);
- func.Execute(args, _parsingContext);
- }
-
- [TestMethod]
- public void QuotientShouldReturnCorrectResult()
- {
- var func = new Quotient();
- var args = FunctionsHelper.CreateArgs(5, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void QuotientShouldThrowWhenDenomIs0()
- {
- var func = new Quotient();
- var args = FunctionsHelper.CreateArgs(1, 0);
- func.Execute(args, _parsingContext);
- }
-
- [TestMethod]
- public void LargeShouldReturnTheLargestNumberIf1()
- {
- var func = new Large();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(1, 2, 3), 1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void LargeShouldReturnTheSecondLargestNumberIf2()
- {
- var func = new Large();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void LargeShouldThrowIfIndexOutOfBounds()
- {
- var func = new Large();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 6);
- var result = func.Execute(args, _parsingContext);
- }
-
- [TestMethod]
- public void SmallShouldReturnTheSmallestNumberIf1()
- {
- var func = new Small();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(1, 2, 3), 1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void SmallShouldReturnTheSecondSmallestNumberIf2()
- {
- var func = new Small();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2d, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void SmallShouldThrowIfIndexOutOfBounds()
- {
- var func = new Small();
- var args = FunctionsHelper.CreateArgs(FunctionsHelper.CreateArgs(4, 1, 2, 3), 6);
- var result = func.Execute(args, _parsingContext);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void MedianShouldThrowIfNoArgs()
- {
- var func = new Median();
- var args = FunctionsHelper.Empty();
- func.Execute(args, _parsingContext);
- }
-
- [TestMethod]
- public void MedianShouldCalculateCorrectlyWithOneMember()
- {
- var func = new Median();
- var args = FunctionsHelper.CreateArgs(1);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(1d, result.Result);
- }
-
- [TestMethod]
- public void MedianShouldCalculateCorrectlyWithOddMembers()
- {
- var func = new Median();
- var args = FunctionsHelper.CreateArgs(3, 5, 1, 4, 2);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void MedianShouldCalculateCorrectlyWithEvenMembers()
- {
- var func = new Median();
- var args = FunctionsHelper.CreateArgs(1, 2, 3, 4);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2.5d, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/NumberFunctionsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/NumberFunctionsTests.cs
deleted file mode 100644
index 64d6882..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/NumberFunctionsTests.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Numeric;
-using EPPlusTest.FormulaParsing.TestHelpers;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class NumberFunctionsTests
- {
- private ParsingContext _parsingContext = ParsingContext.Create();
-
- [TestMethod]
- public void CIntShouldConvertTextToInteger()
- {
- var func = new CInt();
- var args = FunctionsHelper.CreateArgs("2");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void IntShouldConvertDecimalToInteger()
- {
- var func = new CInt();
- var args = FunctionsHelper.CreateArgs(2.88m);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void IntShouldConvertNegativeDecimalToInteger()
- {
- var func = new CInt();
- var args = FunctionsHelper.CreateArgs(-2.88m);
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(-3, result.Result);
- }
-
- [TestMethod]
- public void IntShouldConvertStringToInteger()
- {
- var func = new CInt();
- var args = FunctionsHelper.CreateArgs("-2.88");
- var result = func.Execute(args, _parsingContext);
- Assert.AreEqual(-3, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/ChooseTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/ChooseTests.cs
deleted file mode 100644
index 1abd928..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/ChooseTests.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System;
-using System.IO;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.RefAndLookup
-{
- [TestClass]
- public class ChooseTests
- {
- private ParsingContext _parsingContext;
- private ExcelPackage _package;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _parsingContext = ParsingContext.Create();
- _package = new ExcelPackage(new MemoryStream());
- _worksheet = _package.Workbook.Worksheets.Add("test");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void ChooseSingleValue()
- {
- fillChooseOptions();
- _worksheet.Cells["B1"].Formula = "CHOOSE(4, A1, A2, A3, A4, A5)";
- _worksheet.Calculate();
-
- Assert.AreEqual("5", _worksheet.Cells["B1"].Value);
- }
-
- [TestMethod]
- public void ChooseSingleFormula()
- {
- fillChooseOptions();
- _worksheet.Cells["B1"].Formula = "CHOOSE(6, A1, A2, A3, A4, A5, A6)";
- _worksheet.Calculate();
-
- Assert.AreEqual("12", _worksheet.Cells["B1"].Value);
- }
-
- [TestMethod]
- public void ChooseMultipleValues()
- {
- fillChooseOptions();
- _worksheet.Cells["B1"].Formula = "SUM(CHOOSE({1,3,4}, A1, A2, A3, A4, A5))";
- _worksheet.Calculate();
-
- Assert.AreEqual(9D, _worksheet.Cells["B1"].Value);
- }
-
- [TestMethod]
- public void ChooseValueAndFormula()
- {
- fillChooseOptions();
- _worksheet.Cells["B1"].Formula = "SUM(CHOOSE({2,6}, A1, A2, A3, A4, A5, A6))";
- _worksheet.Calculate();
-
- Assert.AreEqual(14D, _worksheet.Cells["B1"].Value);
- }
-
- private void fillChooseOptions()
- {
- _worksheet.Cells["A1"].Value = 1d;
- _worksheet.Cells["A2"].Value = 2d;
- _worksheet.Cells["A3"].Value = 3d;
- _worksheet.Cells["A4"].Value = 5d;
- _worksheet.Cells["A5"].Value = 7d;
- _worksheet.Cells["A6"].Formula = "A4 + A5";
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/IndexTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/IndexTests.cs
deleted file mode 100644
index e803eef..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/IndexTests.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.IO;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.RefAndLookup
-{
- [TestClass]
- public class IndexTests
- {
- private ParsingContext _parsingContext;
- private ExcelPackage _package;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _parsingContext = ParsingContext.Create();
- _package = new ExcelPackage(new MemoryStream());
- _worksheet = _package.Workbook.Worksheets.Add("test");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void Index_Should_Return_Value_By_Index()
- {
- var func = new Index();
- var result = func.Execute(
- FunctionsHelper.CreateArgs(
- FunctionsHelper.CreateArgs(1, 2, 5),
- 3
- ),_parsingContext);
- Assert.AreEqual(5, result.Result);
- }
-
- [TestMethod]
- public void Index_Should_Handle_SingleRange()
- {
- _worksheet.Cells["A1"].Value = 1d;
- _worksheet.Cells["A2"].Value = 3d;
- _worksheet.Cells["A3"].Value = 5d;
-
- _worksheet.Cells["A4"].Formula = "INDEX(A1:A3;3)";
-
- _worksheet.Calculate();
-
- Assert.AreEqual(5d, _worksheet.Cells["A4"].Value);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/LookupNavigatorFactoryTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/LookupNavigatorFactoryTests.cs
deleted file mode 100644
index 471decc..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/LookupNavigatorFactoryTests.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.IO;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions.RefAndLookup
-{
- [TestClass]
- public class LookupNavigatorFactoryTests
- {
- private ExcelPackage _excelPackage;
- private ParsingContext _context;
-
- [TestInitialize]
- public void Initialize()
- {
- _excelPackage = new ExcelPackage(new MemoryStream());
- _excelPackage.Workbook.Worksheets.Add("Test");
- _context = ParsingContext.Create();
- _context.ExcelDataProvider = new EpplusExcelDataProvider(_excelPackage);
- _context.Scopes.NewScope(RangeAddress.Empty);
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _excelPackage.Dispose();
- }
-
- [TestMethod]
- public void Should_Return_ExcelLookupNavigator_When_Range_Is_Set()
- {
- var args = new LookupArguments(FunctionsHelper.CreateArgs(8, "A:B", 1));
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Horizontal, args, _context);
- Assert.IsInstanceOfType(navigator, typeof(ExcelLookupNavigator));
- }
-
- [TestMethod]
- public void Should_Return_ArrayLookupNavigator_When_Array_Is_Supplied()
- {
- var args = new LookupArguments(FunctionsHelper.CreateArgs(8, FunctionsHelper.CreateArgs(1,2), 1));
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Horizontal, args, _context);
- Assert.IsInstanceOfType(navigator, typeof(ArrayLookupNavigator));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/LookupNavigatorTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/LookupNavigatorTests.cs
deleted file mode 100644
index 25ee05b..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/LookupNavigatorTests.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.Excel.Functions.RefAndLookup
-{
- [TestClass]
- public class LookupNavigatorTests
- {
- const string WorksheetName = "";
- private LookupArguments GetArgs(params object[] args)
- {
- var lArgs = FunctionsHelper.CreateArgs(args);
- return new LookupArguments(lArgs);
- }
-
- private ParsingContext GetContext(ExcelDataProvider provider)
- {
- var ctx = ParsingContext.Create();
- ctx.Scopes.NewScope(new RangeAddress(){Worksheet = WorksheetName, FromCol = 1, FromRow = 1});
- ctx.ExcelDataProvider = provider;
- return ctx;
- }
-
- //[TestMethod]
- //public void NavigatorShouldEvaluateFormula()
- //{
- // var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- // provider.Stub(x => x.GetCellValue(WorksheetName,0, 0)).Return(new ExcelCell(3);
- // provider.Stub(x => x.GetCellValue(WorksheetName,1, 0)).Return("B5");
- // var args = GetArgs(4, "A1:B2", 1);
- // var context = GetContext(provider);
- // var parser = MockRepository.GenerateMock<FormulaParser>(provider);
- // context.Parser = parser;
- // var navigator = new LookupNavigator(LookupDirection.Vertical, args, context);
- // navigator.MoveNext();
- // parser.AssertWasCalled(x => x.Parse("B5"));
- //}
-
- [TestMethod]
- public void CurrentValueShouldBeFirstCell()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(4);
- var args = GetArgs(3, "A1:B2", 1);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- Assert.AreEqual(3, navigator.CurrentValue);
- }
-
- [TestMethod]
- public void MoveNextShouldReturnFalseIfLastCell()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(4);
- var args = GetArgs(3, "A1:B1", 1);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- Assert.IsFalse(navigator.MoveNext());
- }
-
- [TestMethod]
- public void HasNextShouldBeTrueIfNotLastCell()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetDimensionEnd(Arg<string>.Is.Anything)).Return(new ExcelCellAddress(5, 5));
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(4);
- var args = GetArgs(3, "A1:B2", 1);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- Assert.IsTrue(navigator.MoveNext());
- }
-
- [TestMethod]
- public void MoveNextShouldNavigateVertically()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(4);
- var args = GetArgs(6, "A1:B2", 1);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- navigator.MoveNext();
- Assert.AreEqual(4, navigator.CurrentValue);
- }
-
- [TestMethod]
- public void MoveNextShouldIncreaseIndex()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetDimensionEnd(Arg<string>.Is.Anything)).Return(new ExcelCellAddress(5, 5));
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(4);
- var args = GetArgs(6, "A1:B2", 1);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- Assert.AreEqual(0, navigator.Index);
- navigator.MoveNext();
- Assert.AreEqual(1, navigator.Index);
- }
-
- [TestMethod]
- public void GetLookupValueShouldReturnCorrespondingValue()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetDimensionEnd(Arg<string>.Is.Anything)).Return(new ExcelCellAddress(5, 5));
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(4);
- var args = GetArgs(6, "A1:B2", 2);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- Assert.AreEqual(4, navigator.GetLookupValue());
- }
-
- [TestMethod]
- public void GetLookupValueShouldReturnCorrespondingValueWithOffset()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetDimensionEnd(Arg<string>.Is.Anything)).Return(new ExcelCellAddress(5, 5));
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName, 3, 3)).Return(4);
- var args = new LookupArguments(3, "A1:A4", 3, 2, false);
- var navigator = LookupNavigatorFactory.Create(LookupDirection.Vertical, args, GetContext(provider));
- Assert.AreEqual(4, navigator.GetLookupValue());
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/RefAndLookupTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/RefAndLookupTests.cs
deleted file mode 100644
index 6c1e64c..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/RefAndLookup/RefAndLookupTests.cs
+++ /dev/null
@@ -1,481 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using Rhino.Mocks;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using AddressFunction = OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup.Address;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class RefAndLookupTests
- {
- const string WorksheetName = null;
- [TestMethod]
- public void LookupArgumentsShouldSetSearchedValue()
- {
- var args = FunctionsHelper.CreateArgs(1, "A:B", 2);
- var lookupArgs = new LookupArguments(args);
- Assert.AreEqual(1, lookupArgs.SearchedValue);
- }
-
- [TestMethod]
- public void LookupArgumentsShouldSetRangeAddress()
- {
- var args = FunctionsHelper.CreateArgs(1, "A:B", 2);
- var lookupArgs = new LookupArguments(args);
- Assert.AreEqual("A:B", lookupArgs.RangeAddress);
- }
-
- [TestMethod]
- public void LookupArgumentsShouldSetColIndex()
- {
- var args = FunctionsHelper.CreateArgs(1, "A:B", 2);
- var lookupArgs = new LookupArguments(args);
- Assert.AreEqual(2, lookupArgs.LookupIndex);
- }
-
- [TestMethod]
- public void LookupArgumentsShouldSetRangeLookupToTrueAsDefaultValue()
- {
- var args = FunctionsHelper.CreateArgs(1, "A:B", 2);
- var lookupArgs = new LookupArguments(args);
- Assert.IsTrue(lookupArgs.RangeLookup);
- }
-
- [TestMethod]
- public void LookupArgumentsShouldSetRangeLookupToTrueWhenTrueIsSupplied()
- {
- var args = FunctionsHelper.CreateArgs(1, "A:B", 2, true);
- var lookupArgs = new LookupArguments(args);
- Assert.IsTrue(lookupArgs.RangeLookup);
- }
-
- [TestMethod]
- public void VLookupShouldReturnResultFromMatchingRow()
- {
- var func = new VLookup();
- var args = FunctionsHelper.CreateArgs(2, "A1:B2", 2);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(2);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 2)).Return(5);
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(5, result.Result);
- }
-
- [TestMethod]
- public void VLookupShouldReturnClosestValueBelowWhenRangeLookupIsTrue()
- {
- var func = new VLookup();
- var args = FunctionsHelper.CreateArgs(4, "A1:B2", 2, true);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(5);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 2)).Return(4);
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(1, result.Result);
- }
-
- [TestMethod]
- public void VLookupShouldReturnClosestStringValueBelowWhenRangeLookupIsTrue()
- {
- var func = new VLookup();
- var args = FunctionsHelper.CreateArgs("B", "A1:B2", 2, true);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- //provider.Stub(x => x.GetCellValue(WorksheetName,0, 0)).Return(new ExcelCell("A", null, 0, 0));
- //provider.Stub(x => x.GetCellValue(WorksheetName,0, 1)).Return(new ExcelCell(1, null, 0, 0));
- //provider.Stub(x => x.GetCellValue(WorksheetName,1, 0)).Return(new ExcelCell("C", null, 0, 0));
- //provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(new ExcelCell(4, null, 0, 0));
-
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return("A");
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return("C");
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 2)).Return(4);
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(1, result.Result);
- }
-
- [TestMethod]
- public void HLookupShouldReturnResultFromMatchingRow()
- {
- var func = new HLookup();
- var args = FunctionsHelper.CreateArgs(2, "A1:B2", 2);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- //provider.Stub(x => x.GetCellValue(WorksheetName,0, 0)).Return(new ExcelCell(3, null, 0, 0));
- //provider.Stub(x => x.GetCellValue(WorksheetName,0, 1)).Return(new ExcelCell(1, null, 0, 0));
- //provider.Stub(x => x.GetCellValue(WorksheetName,1, 0)).Return(new ExcelCell(2, null, 0, 0));
- //provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(new ExcelCell(5, null, 0, 0));
-
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(2);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 2)).Return(5);
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(5, result.Result);
- }
-
- [TestMethod]
- public void HLookupShouldReturnNaErrorIfNoMatchingRecordIsFoundWhenRangeLookupIsFalse()
- {
- var func = new HLookup();
- var args = FunctionsHelper.CreateArgs(2, "A1:B2", 2, false);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
-
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(2);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 2)).Return(5);
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- var expectedResult = ExcelErrorValue.Create(eErrorType.NA);
- Assert.AreEqual(expectedResult, result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void HLookupShouldThrowIfNoMatchingRecordIsFoundWhenRangeLookupIsTrue()
- {
- var func = new HLookup();
- var args = FunctionsHelper.CreateArgs(1, "A1:B2", 2, true);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
-
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 1)).Return(2);
- provider.Stub(x => x.GetCellValue(WorksheetName, 1, 2)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName, 2, 2)).Return(5);
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- }
-
- [TestMethod]
- public void LookupShouldReturnResultFromMatchingRowArrayVertical()
- {
- var func = new Lookup();
- var args = FunctionsHelper.CreateArgs(4, "A1:B3", 2);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return("A");
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 2)).Return("B");
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 1)).Return(5);
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 2)).Return("C");
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual("B", result.Result);
- }
-
- [TestMethod]
- public void LookupShouldReturnResultFromMatchingRowArrayHorizontal()
- {
- var func = new Lookup();
- var args = FunctionsHelper.CreateArgs(4, "A1:C2", 2);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return("A");
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 2)).Return("B");
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 3)).Return("C");
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual("B", result.Result);
- }
-
- [TestMethod]
- public void LookupShouldReturnResultFromMatchingSecondArrayHorizontal()
- {
- var func = new Lookup();
- var args = FunctionsHelper.CreateArgs(4, "A1:C1", "A3:C3");
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 1)).Return("A");
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 2)).Return("B");
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 3)).Return("C");
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual("B", result.Result);
- }
-
- [TestMethod]
- public void LookupShouldReturnResultFromMatchingSecondArrayHorizontalWithOffset()
- {
- var func = new Lookup();
- var args = FunctionsHelper.CreateArgs(4, "A1:C1", "B3:D3");
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 2)).Return("A");
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 3)).Return("B");
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 4)).Return("C");
-
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual("B", result.Result);
- }
-
- [TestMethod]
- public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeExact()
- {
- var func = new Match();
- var args = FunctionsHelper.CreateArgs(3, "A1:C1", 0);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void MatchShouldReturnIndexOfMatchingValVertical_MatchTypeExact()
- {
- var func = new Match();
- var args = FunctionsHelper.CreateArgs(3, "A1:A3", 0);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,3, 1)).Return(5);
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeClosestBelow()
- {
- var func = new Match();
- var args = FunctionsHelper.CreateArgs(4, "A1:C1", 1);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(1);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(3);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void MatchShouldReturnIndexOfMatchingValHorizontal_MatchTypeClosestAbove()
- {
- var func = new Match();
- var args = FunctionsHelper.CreateArgs(6, "A1:C1", -1);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(10);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(8);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void MatchShouldReturnFirstItemWhenExactMatch_MatchTypeClosestAbove()
- {
- var func = new Match();
- var args = FunctionsHelper.CreateArgs(10, "A1:C1", -1);
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
-
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(10);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(8);
- provider.Stub(x => x.GetCellValue(WorksheetName,1, 3)).Return(5);
- parsingContext.ExcelDataProvider = provider;
- var result = func.Execute(args, parsingContext);
- Assert.AreEqual(1, result.Result);
- }
-
- [TestMethod]
- public void RowShouldReturnRowFromCurrentScopeIfNoAddressIsSupplied()
- {
- var func = new Row();
- var parsingContext = ParsingContext.Create();
- var rangeAddressFactory = new RangeAddressFactory(MockRepository.GenerateStub<ExcelDataProvider>());
- parsingContext.Scopes.NewScope(rangeAddressFactory.Create("A2"));
- var result = func.Execute(Enumerable.Empty<FunctionArgument>(), parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void RowShouldReturnRowSuppliedAddress()
- {
- var func = new Row();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- var result = func.Execute(FunctionsHelper.CreateArgs("A3"), parsingContext);
- Assert.AreEqual(3, result.Result);
- }
-
- [TestMethod]
- public void ColumnShouldReturnRowFromCurrentScopeIfNoAddressIsSupplied()
- {
- var func = new Column();
- var parsingContext = ParsingContext.Create();
- var rangeAddressFactory = new RangeAddressFactory(MockRepository.GenerateStub<ExcelDataProvider>());
- parsingContext.Scopes.NewScope(rangeAddressFactory.Create("B2"));
- var result = func.Execute(Enumerable.Empty<FunctionArgument>(), parsingContext);
- Assert.AreEqual(2, result.Result);
- }
-
- [TestMethod]
- public void ColumnShouldReturnRowSuppliedAddress()
- {
- var func = new Column();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- var result = func.Execute(FunctionsHelper.CreateArgs("E3"), parsingContext);
- Assert.AreEqual(5, result.Result);
- }
-
- [TestMethod]
- public void RowsShouldReturnNbrOfRowsSuppliedRange()
- {
- var func = new Rows();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- var result = func.Execute(FunctionsHelper.CreateArgs("A1:B3"), parsingContext);
- Assert.AreEqual(3, result.Result);
- }
-
- [TestMethod]
- public void RowsShouldReturnNbrOfRowsForEntireColumn()
- {
- var func = new Rows();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- var result = func.Execute(FunctionsHelper.CreateArgs("A:B"), parsingContext);
- Assert.AreEqual(1048576, result.Result);
- }
-
- [TestMethod]
- public void ColumnssShouldReturnNbrOfRowsSuppliedRange()
- {
- var func = new Columns();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- var result = func.Execute(FunctionsHelper.CreateArgs("A1:E3"), parsingContext);
- Assert.AreEqual(5, result.Result);
- }
-
- [TestMethod]
- public void ChooseShouldReturnItemByIndex()
- {
- var func = new Choose();
- var parsingContext = ParsingContext.Create();
- var result = func.Execute(FunctionsHelper.CreateArgs(1, "A", "B"), parsingContext);
- Assert.AreEqual("A", result.Result);
- }
-
- [TestMethod]
- public void AddressShouldReturnAddressByIndexWithDefaultRefType()
- {
- var func = new AddressFunction();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- parsingContext.ExcelDataProvider.Stub(x => x.ExcelMaxRows).Return(10);
- var result = func.Execute(FunctionsHelper.CreateArgs(1, 2), parsingContext);
- Assert.AreEqual("$B$1", result.Result);
- }
-
- [TestMethod]
- public void AddressShouldReturnAddressByIndexWithRelativeType()
- {
- var func = new AddressFunction();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- parsingContext.ExcelDataProvider.Stub(x => x.ExcelMaxRows).Return(10);
- var result = func.Execute(FunctionsHelper.CreateArgs(1, 2, (int)ExcelReferenceType.RelativeRowAndColumn), parsingContext);
- Assert.AreEqual("B1", result.Result);
- }
-
- [TestMethod]
- public void AddressShouldReturnAddressByWithSpecifiedWorksheet()
- {
- var func = new AddressFunction();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- parsingContext.ExcelDataProvider.Stub(x => x.ExcelMaxRows).Return(10);
- var result = func.Execute(FunctionsHelper.CreateArgs(1, 2, (int)ExcelReferenceType.RelativeRowAndColumn, true, "Worksheet1"), parsingContext);
- Assert.AreEqual("Worksheet1!B1", result.Result);
- }
-
- [TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void AddressShouldThrowIfR1C1FormatIsSpecified()
- {
- var func = new AddressFunction();
- var parsingContext = ParsingContext.Create();
- parsingContext.ExcelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- parsingContext.ExcelDataProvider.Stub(x => x.ExcelMaxRows).Return(10);
- var result = func.Execute(FunctionsHelper.CreateArgs(1, 2, (int)ExcelReferenceType.RelativeRowAndColumn, false), parsingContext);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/SubtotalTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/SubtotalTests.cs
deleted file mode 100644
index b9a419c..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/SubtotalTests.cs
+++ /dev/null
@@ -1,239 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.Excel;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class SubtotalTests
- {
- private ParsingContext _context;
-
- [TestInitialize]
- public void Setup()
- {
- _context = ParsingContext.Create();
- _context.Scopes.NewScope(RangeAddress.Empty);
- }
-
- [TestMethod, ExpectedException(typeof(ExcelErrorValueException))]
- public void ShouldThrowIfInvalidFuncNumber()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(139, 1);
- func.Execute(args, _context);
- }
-
- [TestMethod]
- public void ShouldCalculateAverageWhenCalcTypeIs1()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(1, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(30d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateCountWhenCalcTypeIs2()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(2, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateCountAWhenCalcTypeIs3()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(3, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateMaxWhenCalcTypeIs4()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(4, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(50d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateMinWhenCalcTypeIs5()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(5, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(10d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateProductWhenCalcTypeIs6()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(6, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(12000000d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateStdevWhenCalcTypeIs7()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(7, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- var resultRounded = Math.Round((double)result.Result, 5);
- Assert.AreEqual(15.81139d, resultRounded);
- }
-
- [TestMethod]
- public void ShouldCalculateStdevPWhenCalcTypeIs8()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(8, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- var resultRounded = Math.Round((double)result.Result, 8);
- Assert.AreEqual(14.14213562, resultRounded);
- }
-
- [TestMethod]
- public void ShouldCalculateSumWhenCalcTypeIs9()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(9, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(150d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateVarWhenCalcTypeIs10()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(10, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(250d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateVarPWhenCalcTypeIs11()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(11, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(200d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateAverageWhenCalcTypeIs101()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(101, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(30d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateCountWhenCalcTypeIs102()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(102, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateCountAWhenCalcTypeIs103()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(103, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(5d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateMaxWhenCalcTypeIs104()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(104, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(50d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateMinWhenCalcTypeIs105()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(105, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(10d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateProductWhenCalcTypeIs106()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(106, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(12000000d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateStdevWhenCalcTypeIs107()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(107, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- var resultRounded = Math.Round((double)result.Result, 5);
- Assert.AreEqual(15.81139d, resultRounded);
- }
-
- [TestMethod]
- public void ShouldCalculateStdevPWhenCalcTypeIs108()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(108, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- var resultRounded = Math.Round((double)result.Result, 8);
- Assert.AreEqual(14.14213562, resultRounded);
- }
-
- [TestMethod]
- public void ShouldCalculateSumWhenCalcTypeIs109()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(109, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(150d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateVarWhenCalcTypeIs110()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(110, 10, 20, 30, 40, 50, 51);
- args.Last().SetExcelStateFlag(ExcelCellState.HiddenCell);
- var result = func.Execute(args, _context);
- Assert.AreEqual(250d, result.Result);
- }
-
- [TestMethod]
- public void ShouldCalculateVarPWhenCalcTypeIs111()
- {
- var func = new Subtotal();
- var args = FunctionsHelper.CreateArgs(111, 10, 20, 30, 40, 50);
- var result = func.Execute(args, _context);
- Assert.AreEqual(200d, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/SumIfsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/SumIfsTests.cs
deleted file mode 100644
index 85bf8c0..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/SumIfsTests.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.Excel.Functions
-{
- [TestClass]
- public class SumIfsTests
- {
- private ExcelPackage _package;
- private ExcelWorksheet _sheet;
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- var s1 = _package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Value = 1;
- s1.Cells["A2"].Value = 2;
- s1.Cells["A3"].Value = 3;
- s1.Cells["A4"].Value = 4;
-
- s1.Cells["B1"].Value = 5;
- s1.Cells["B2"].Value = 6;
- s1.Cells["B3"].Value = 7;
- s1.Cells["B4"].Value = 8;
-
- s1.Cells["C1"].Value = 5;
- s1.Cells["C2"].Value = 6;
- s1.Cells["C3"].Value = 7;
- s1.Cells["C4"].Value = 8;
-
- _sheet = s1;
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void ShouldCalculateTwoCriteriaRanges()
- {
- _sheet.Cells["A5"].Formula = "SUMIFS(A1:A4;B1:B5;\">5\";C1:C5;\">4\")";
- _sheet.Calculate();
-
- Assert.AreEqual(9d, _sheet.Cells["A5"].Value);
- }
-
- [TestMethod]
- public void ShouldIgnoreErrorInCriteriaRange()
- {
- _sheet.Cells["B3"].Value = ExcelErrorValue.Create(eErrorType.Div0);
-
- _sheet.Cells["A5"].Formula = "SUMIFS(A1:A4;B1:B5;\">5\";C1:C5;\">4\")";
- _sheet.Calculate();
-
- Assert.AreEqual(6d, _sheet.Cells["A5"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleDateInSumRange()
- {
- _sheet.Cells["A2"].Formula = "DATE(2015;1;1)";
- _sheet.Cells["A5"].Formula = "SUMIFS(A1:A4;B1:B5;\">5\";C1:C5;\">4\")";
- _sheet.Calculate();
-
- Assert.AreEqual(42012d, _sheet.Cells["A5"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleExcelRangesInCriteria()
- {
- _sheet.Cells["D1"].Value = 6;
- _sheet.Cells["A5"].Formula = "SUMIFS(A1:A4;B1:B5;\">5\";C1:C5;D1)";
- _sheet.Calculate();
-
- Assert.AreEqual(2d, _sheet.Cells["A5"].Value);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/TextFunctionsTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/TextFunctionsTests.cs
deleted file mode 100644
index 205bd2c..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/TextFunctionsTests.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
-using EPPlusTest.FormulaParsing.TestHelpers;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.Excel.Functions.Text
-{
- [TestClass]
- public class TextFunctionsTests
- {
- private ParsingContext _parsingContext = ParsingContext.Create();
-
- [TestMethod]
- public void CStrShouldConvertNumberToString()
- {
- var func = new CStr();
- var result = func.Execute(FunctionsHelper.CreateArgs(1), _parsingContext);
- Assert.AreEqual(DataType.String, result.DataType);
- Assert.AreEqual("1", result.Result);
- }
-
- [TestMethod]
- public void LenShouldReturnStringsLength()
- {
- var func = new Len();
- var result = func.Execute(FunctionsHelper.CreateArgs("abc"), _parsingContext);
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void LowerShouldReturnLowerCaseString()
- {
- var func = new Lower();
- var result = func.Execute(FunctionsHelper.CreateArgs("ABC"), _parsingContext);
- Assert.AreEqual("abc", result.Result);
- }
-
- [TestMethod]
- public void UpperShouldReturnUpperCaseString()
- {
- var func = new Upper();
- var result = func.Execute(FunctionsHelper.CreateArgs("abc"), _parsingContext);
- Assert.AreEqual("ABC", result.Result);
- }
-
- [TestMethod]
- public void LeftShouldReturnSubstringFromLeft()
- {
- var func = new Left();
- var result = func.Execute(FunctionsHelper.CreateArgs("abcd", 2), _parsingContext);
- Assert.AreEqual("ab", result.Result);
- }
-
- [TestMethod]
- public void RightShouldReturnSubstringFromRight()
- {
- var func = new Right();
- var result = func.Execute(FunctionsHelper.CreateArgs("abcd", 2), _parsingContext);
- Assert.AreEqual("cd", result.Result);
- }
-
- [TestMethod]
- public void MidShouldReturnSubstringAccordingToParams()
- {
- var func = new Mid();
- var result = func.Execute(FunctionsHelper.CreateArgs("abcd", 1, 2), _parsingContext);
- Assert.AreEqual("ab", result.Result);
- }
-
- [TestMethod]
- public void ReplaceShouldReturnAReplacedStringAccordingToParamsWhenStartIxIs1()
- {
- var func = new Replace();
- var result = func.Execute(FunctionsHelper.CreateArgs("testar", 1, 2, "hej"), _parsingContext);
- Assert.AreEqual("hejstar", result.Result);
- }
-
- [TestMethod]
- public void ReplaceShouldReturnAReplacedStringAccordingToParamsWhenStartIxIs3()
- {
- var func = new Replace();
- var result = func.Execute(FunctionsHelper.CreateArgs("testar", 3, 3, "hej"), _parsingContext);
- Assert.AreEqual("tehejr", result.Result);
- }
-
- [TestMethod]
- public void SubstituteShouldReturnAReplacedStringAccordingToParamsWhen()
- {
- var func = new Substitute();
- var result = func.Execute(FunctionsHelper.CreateArgs("testar testar", "es", "xx"), _parsingContext);
- Assert.AreEqual("txxtar txxtar", result.Result);
- }
-
- [TestMethod]
- public void ConcatenateShouldConcatenateThreeStrings()
- {
- var func = new Concatenate();
- var result = func.Execute(FunctionsHelper.CreateArgs("One", "Two", "Three"), _parsingContext);
- Assert.AreEqual("OneTwoThree", result.Result);
- }
-
- [TestMethod]
- public void ConcatenateShouldConcatenateStringWithInt()
- {
- var func = new Concatenate();
- var result = func.Execute(FunctionsHelper.CreateArgs(1, "Two"), _parsingContext);
- Assert.AreEqual("1Two", result.Result);
- }
-
- [TestMethod]
- public void ExactShouldReturnTrueWhenTwoEqualStrings()
- {
- var func = new Exact();
- var result = func.Execute(FunctionsHelper.CreateArgs("abc", "abc"), _parsingContext);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void ExactShouldReturnTrueWhenEqualStringAndDouble()
- {
- var func = new Exact();
- var result = func.Execute(FunctionsHelper.CreateArgs("1", 1d), _parsingContext);
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void ExactShouldReturnFalseWhenStringAndNull()
- {
- var func = new Exact();
- var result = func.Execute(FunctionsHelper.CreateArgs("1", null), _parsingContext);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void ExactShouldReturnFalseWhenTwoEqualStringsWithDifferentCase()
- {
- var func = new Exact();
- var result = func.Execute(FunctionsHelper.CreateArgs("abc", "Abc"), _parsingContext);
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void FindShouldReturnIndexOfFoundPhrase()
- {
- var func = new Find();
- var result = func.Execute(FunctionsHelper.CreateArgs("hopp", "hej hopp"), _parsingContext);
- Assert.AreEqual(5, result.Result);
- }
-
- [TestMethod]
- public void FindShouldReturnIndexOfFoundPhraseBasedOnStartIndex()
- {
- var func = new Find();
- var result = func.Execute(FunctionsHelper.CreateArgs("hopp", "hopp hopp", 2), _parsingContext);
- Assert.AreEqual(6, result.Result);
- }
-
- [TestMethod]
- public void ProperShouldSetFirstLetterToUpperCase()
- {
- var func = new Proper();
- var result = func.Execute(FunctionsHelper.CreateArgs("this IS A tEst.wi3th SOME w0rds östEr"), _parsingContext);
- Assert.AreEqual("This Is A Test.Wi3Th Some W0Rds Öster", result.Result);
- }
-
- [TestMethod]
- public void HyperLinkShouldReturnArgIfOneArgIsSupplied()
- {
- var func = new Hyperlink();
- var result = func.Execute(FunctionsHelper.CreateArgs("http://epplus.codeplex.com"), _parsingContext);
- Assert.AreEqual("http://epplus.codeplex.com", result.Result);
- }
-
- [TestMethod]
- public void HyperLinkShouldReturnLastArgIfTwoArgsAreSupplied()
- {
- var func = new Hyperlink();
- var result = func.Execute(FunctionsHelper.CreateArgs("http://epplus.codeplex.com", "EPPlus"), _parsingContext);
- Assert.AreEqual("EPPlus", result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/Functions/TimeStringParserTests.cs b/EPPlusTest/FormulaParsing/Excel/Functions/TimeStringParserTests.cs
deleted file mode 100644
index fb13fce..0000000
--- a/EPPlusTest/FormulaParsing/Excel/Functions/TimeStringParserTests.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
-
-namespace EPPlusTest.Excel.Functions
-{
- [TestClass]
- public class TimeStringParserTests
- {
- private double GetSerialNumber(int hour, int minute, int second)
- {
- var secondsInADay = 24d * 60d * 60d;
- return ((double)hour * 60 * 60 + (double)minute * 60 + (double)second) / secondsInADay;
- }
-
- [TestMethod]
- public void CanParseShouldHandleValid24HourPatterns()
- {
- var parser = new TimeStringParser();
- Assert.IsTrue(parser.CanParse("10:12:55"), "Could not parse 10:12:55");
- Assert.IsTrue(parser.CanParse("22:12:55"), "Could not parse 13:12:55");
- Assert.IsTrue(parser.CanParse("13"), "Could not parse 13");
- Assert.IsTrue(parser.CanParse("13:12"), "Could not parse 13:12");
- }
-
- [TestMethod]
- public void CanParseShouldHandleValid12HourPatterns()
- {
- var parser = new TimeStringParser();
- Assert.IsTrue(parser.CanParse("10:12:55 AM"), "Could not parse 10:12:55 AM");
- Assert.IsTrue(parser.CanParse("9:12:55 PM"), "Could not parse 9:12:55 PM");
- Assert.IsTrue(parser.CanParse("7 AM"), "Could not parse 7 AM");
- Assert.IsTrue(parser.CanParse("4:12 PM"), "Could not parse 4:12 PM");
- }
-
- [TestMethod]
- public void ParseShouldIdentifyPatternAndReturnCorrectResult()
- {
- var parser = new TimeStringParser();
- var result = parser.Parse("10:12:55");
- Assert.AreEqual(GetSerialNumber(10, 12, 55), result);
- }
-
- [TestMethod, ExpectedException(typeof(FormatException))]
- public void ParseShouldThrowExceptionIfSecondIsOutOfRange()
- {
- var parser = new TimeStringParser();
- var result = parser.Parse("10:12:60");
- }
-
- [TestMethod, ExpectedException(typeof(FormatException))]
- public void ParseShouldThrowExceptionIfMinuteIsOutOfRange()
- {
- var parser = new TimeStringParser();
- var result = parser.Parse("10:60:55");
- }
-
- [TestMethod]
- public void ParseShouldIdentify12HourAMPatternAndReturnCorrectResult()
- {
- var parser = new TimeStringParser();
- var result = parser.Parse("10:12:55 AM");
- Assert.AreEqual(GetSerialNumber(10, 12, 55), result);
- }
-
- [TestMethod]
- public void ParseShouldIdentify12HourPMPatternAndReturnCorrectResult()
- {
- var parser = new TimeStringParser();
- var result = parser.Parse("10:12:55 PM");
- Assert.AreEqual(GetSerialNumber(22, 12, 55), result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/Excel/OperatorsTests.cs b/EPPlusTest/FormulaParsing/Excel/OperatorsTests.cs
deleted file mode 100644
index 7cbdf95..0000000
--- a/EPPlusTest/FormulaParsing/Excel/OperatorsTests.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.Excel
-{
- [TestClass]
- public class OperatorsTests
- {
- [TestMethod]
- public void OperatorPlusShouldThrowExceptionIfNonNumericOperand()
- {
- var result = Operator.Plus.Apply(new CompileResult(1, DataType.Integer), new CompileResult("a", DataType.String));
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.Value), result.Result);
- }
-
- [TestMethod]
- public void OperatorPlusShouldAddNumericStringAndNumber()
- {
- var result = Operator.Plus.Apply(new CompileResult(1, DataType.Integer), new CompileResult("2", DataType.String));
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void OperatorMinusShouldThrowExceptionIfNonNumericOperand()
- {
- var result = Operator.Minus.Apply(new CompileResult(1, DataType.Integer), new CompileResult("a", DataType.String));
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.Value), result.Result);
- }
-
- [TestMethod]
- public void OperatorMinusShouldSubtractNumericStringAndNumber()
- {
- var result = Operator.Minus.Apply(new CompileResult(5, DataType.Integer), new CompileResult("2", DataType.String));
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void OperatorDivideShouldReturnDivideByZeroIfRightOperandIsZero()
- {
- var result = Operator.Divide.Apply(new CompileResult(1d, DataType.Decimal), new CompileResult(0d, DataType.Decimal));
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.Div0), result.Result);
- }
-
- [TestMethod]
- public void OperatorDivideShouldDivideCorrectly()
- {
- var result = Operator.Divide.Apply(new CompileResult(9d, DataType.Decimal), new CompileResult(3d, DataType.Decimal));
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void OperatorDivideShouldReturnValueErrorIfNonNumericOperand()
- {
- var result = Operator.Divide.Apply(new CompileResult(1, DataType.Integer), new CompileResult("a", DataType.String));
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.Value), result.Result);
- }
-
- [TestMethod]
- public void OperatorDivideShouldDivideNumericStringAndNumber()
- {
- var result = Operator.Divide.Apply(new CompileResult(9, DataType.Integer), new CompileResult("3", DataType.String));
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void OperatorMultiplyShouldThrowExceptionIfNonNumericOperand()
- {
- Operator.Multiply.Apply(new CompileResult(1, DataType.Integer), new CompileResult("a", DataType.String));
- }
-
- [TestMethod]
- public void OperatoMultiplyShouldMultiplyNumericStringAndNumber()
- {
- var result = Operator.Multiply.Apply(new CompileResult(1, DataType.Integer), new CompileResult("3", DataType.String));
- Assert.AreEqual(3d, result.Result);
- }
-
- [TestMethod]
- public void OperatorConcatShouldConcatTwoStrings()
- {
- var result = Operator.Concat.Apply(new CompileResult("a", DataType.String), new CompileResult("b", DataType.String));
- Assert.AreEqual("ab", result.Result);
- }
-
- [TestMethod]
- public void OperatorConcatShouldConcatANumberAndAString()
- {
- var result = Operator.Concat.Apply(new CompileResult(12, DataType.Integer), new CompileResult("b", DataType.String));
- Assert.AreEqual("12b", result.Result);
- }
-
- [TestMethod]
- public void OperatorEqShouldReturnTruefSuppliedValuesAreEqual()
- {
- var result = Operator.Eq.Apply(new CompileResult(12, DataType.Integer), new CompileResult(12, DataType.Integer));
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void OperatorEqShouldReturnFalsefSuppliedValuesDiffer()
- {
- var result = Operator.Eq.Apply(new CompileResult(11, DataType.Integer), new CompileResult(12, DataType.Integer));
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void OperatorNotEqualToShouldReturnTruefSuppliedValuesDiffer()
- {
- var result = Operator.NotEqualsTo.Apply(new CompileResult(11, DataType.Integer), new CompileResult(12, DataType.Integer));
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void OperatorNotEqualToShouldReturnFalsefSuppliedValuesAreEqual()
- {
- var result = Operator.NotEqualsTo.Apply(new CompileResult(11, DataType.Integer), new CompileResult(11, DataType.Integer));
- Assert.IsFalse((bool)result.Result);
- }
-
- [TestMethod]
- public void OperatorGreaterThanToShouldReturnTrueIfLeftIsSetAndRightIsNull()
- {
- var result = Operator.GreaterThan.Apply(new CompileResult(11, DataType.Integer), new CompileResult(null, DataType.Empty));
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void OperatorGreaterThanToShouldReturnTrueIfLeftIs11AndRightIs10()
- {
- var result = Operator.GreaterThan.Apply(new CompileResult(11, DataType.Integer), new CompileResult(10, DataType.Integer));
- Assert.IsTrue((bool)result.Result);
- }
-
- [TestMethod]
- public void OperatorExpShouldReturnCorrectResult()
- {
- var result = Operator.Exp.Apply(new CompileResult(2, DataType.Integer), new CompileResult(3, DataType.Integer));
- Assert.AreEqual(8d, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/AddressTranslatorTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/AddressTranslatorTests.cs
deleted file mode 100644
index 2a0f23e..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/AddressTranslatorTests.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class AddressTranslatorTests
- {
- private AddressTranslator _addressTranslator;
- private ExcelDataProvider _excelDataProvider;
- private const int ExcelMaxRows = 1356;
-
- [TestInitialize]
- public void Setup()
- {
- _excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _excelDataProvider.Stub(x => x.ExcelMaxRows).Return(ExcelMaxRows);
- _addressTranslator = new AddressTranslator(_excelDataProvider);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void ConstructorShouldThrowIfProviderIsNull()
- {
- new AddressTranslator(null);
- }
-
- [TestMethod]
- public void ShouldTranslateRowNumber()
- {
- int col, row;
- _addressTranslator.ToColAndRow("A2", out col, out row);
- Assert.AreEqual(2, row);
- }
-
- [TestMethod]
- public void ShouldTranslateLettersToColumnIndex()
- {
- int col, row;
- _addressTranslator.ToColAndRow("C1", out col, out row);
- Assert.AreEqual(3, col);
- _addressTranslator.ToColAndRow("AA2", out col, out row);
- Assert.AreEqual(27, col);
- _addressTranslator.ToColAndRow("BC1", out col, out row);
- Assert.AreEqual(55, col);
- }
-
- [TestMethod]
- public void ShouldTranslateLetterAddressUsingMaxRowsFromProviderLower()
- {
- int col, row;
- _addressTranslator.ToColAndRow("A", out col, out row);
- Assert.AreEqual(1, row);
- }
-
- [TestMethod]
- public void ShouldTranslateLetterAddressUsingMaxRowsFromProviderUpper()
- {
- int col, row;
- _addressTranslator.ToColAndRow("A", out col, out row, AddressTranslator.RangeCalculationBehaviour.LastPart);
- Assert.AreEqual(ExcelMaxRows, row);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/CellReferenceProviderTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/CellReferenceProviderTests.cs
deleted file mode 100644
index 8c6fabe..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/CellReferenceProviderTests.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class CellReferenceProviderTests
- {
- private ExcelDataProvider _provider;
-
- [TestInitialize]
- public void Setup()
- {
- _provider = MockRepository.GenerateStub<ExcelDataProvider>();
- _provider.Stub(x => x.ExcelMaxRows).Return(5000);
- }
-
- [TestMethod]
- public void ShouldReturnReferencedSingleAddress()
- {
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
- parsingContext.Configuration.SetLexer(new Lexer(parsingContext.Configuration.FunctionRepository, parsingContext.NameValueProvider));
- parsingContext.RangeAddressFactory = new RangeAddressFactory(_provider);
- var provider = new CellReferenceProvider();
- var result = provider.GetReferencedAddresses("A1", parsingContext);
- Assert.AreEqual("A1", result.First());
- }
-
- [TestMethod]
- public void ShouldReturnReferencedMultipleAddresses()
- {
- var parsingContext = ParsingContext.Create();
- parsingContext.Scopes.NewScope(RangeAddress.Empty);
- parsingContext.Configuration.SetLexer(new Lexer(parsingContext.Configuration.FunctionRepository, parsingContext.NameValueProvider));
- parsingContext.RangeAddressFactory = new RangeAddressFactory(_provider);
- var provider = new CellReferenceProvider();
- var result = provider.GetReferencedAddresses("A1:A2", parsingContext);
- Assert.AreEqual("A1", result.First());
- Assert.AreEqual("A2", result.Last());
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/ExcelAddressInfoTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/ExcelAddressInfoTests.cs
deleted file mode 100644
index bac104b..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/ExcelAddressInfoTests.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class ExcelAddressInfoTests
- {
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void ParseShouldThrowIfAddressIsNull()
- {
- ExcelAddressInfo.Parse(null);
- }
-
- [TestMethod]
- public void ParseShouldSetWorksheet()
- {
- var info = ExcelAddressInfo.Parse("Worksheet!A1");
- Assert.AreEqual("Worksheet", info.Worksheet);
- }
-
- [TestMethod]
- public void WorksheetIsSpecifiedShouldBeTrueWhenWorksheetIsSupplied()
- {
- var info = ExcelAddressInfo.Parse("Worksheet!A1");
- Assert.IsTrue(info.WorksheetIsSpecified);
- }
-
- [TestMethod]
- public void ShouldIndicateMultipleCellsWhenAddressContainsAColon()
- {
- var info = ExcelAddressInfo.Parse("A1:A2");
- Assert.IsTrue(info.IsMultipleCells);
- }
-
- [TestMethod]
- public void ShouldSetStartCell()
- {
- var info = ExcelAddressInfo.Parse("A1:A2");
- Assert.AreEqual("A1", info.StartCell);
- }
-
- [TestMethod]
- public void ShouldSetEndCell()
- {
- var info = ExcelAddressInfo.Parse("A1:A2");
- Assert.AreEqual("A2", info.EndCell);
- }
-
- [TestMethod]
- public void ParseShouldSetAddressOnSheet()
- {
- var info = ExcelAddressInfo.Parse("Worksheet!A1:A2");
- Assert.AreEqual("A1:A2", info.AddressOnSheet);
- }
-
- [TestMethod]
- public void AddressOnSheetShouldBeSameAsAddressIfNoWorksheetIsSpecified()
- {
- var info = ExcelAddressInfo.Parse("A1:A2");
- Assert.AreEqual("A1:A2", info.AddressOnSheet);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/ExpressionEvaluatorTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/ExpressionEvaluatorTests.cs
deleted file mode 100644
index b730e74..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/ExpressionEvaluatorTests.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Diagnostics.Design;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class ExpressionEvaluatorTests
- {
- private ExpressionEvaluator _evaluator;
-
- [TestInitialize]
- public void Setup()
- {
- _evaluator = new ExpressionEvaluator();
- }
-
- #region Numeric Expression Tests
- [TestMethod]
- public void EvaluateShouldReturnTrueIfOperandsAreEqual()
- {
- var result = _evaluator.Evaluate("1", "1");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldReturnTrueIfOperandsAreMatchingButDifferentTypes()
- {
- var result = _evaluator.Evaluate(1d, "1");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldEvaluateOperator()
- {
- var result = _evaluator.Evaluate(1d, "<2");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldEvaluateNumericString()
- {
- var result = _evaluator.Evaluate("1", ">0");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldHandleBooleanArg()
- {
- var result = _evaluator.Evaluate(true, "TRUE");
- Assert.IsTrue(result);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void EvaluateShouldThrowIfOperatorIsNotBoolean()
- {
- var result = _evaluator.Evaluate(1d, "+1");
- }
- #endregion
-
- #region Date tests
- [TestMethod]
- public void EvaluateShouldHandleDateArg()
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- var result = _evaluator.Evaluate(new DateTime(2016,6,28), "2016-06-28");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldHandleDateArgWithOperator()
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- var result = _evaluator.Evaluate(new DateTime(2016, 6, 28), ">2016-06-27");
- Assert.IsTrue(result);
- }
- #endregion
-
- #region Blank Expression Tests
- [TestMethod]
- public void EvaluateBlankExpressionEqualsNull()
- {
- var result = _evaluator.Evaluate(null, "");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateBlankExpressionEqualsEmptyString()
- {
- var result = _evaluator.Evaluate(string.Empty, "");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateBlankExpressionEqualsZero()
- {
- var result = _evaluator.Evaluate(0d, "");
- Assert.IsFalse(result);
- }
- #endregion
-
- #region Quotes Expression Tests
- [TestMethod]
- public void EvaluateQuotesExpressionEqualsNull()
- {
- var result = _evaluator.Evaluate(null, "\"\"");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateQuotesExpressionEqualsZero()
- {
- var result = _evaluator.Evaluate(0d, "\"\"");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateQuotesExpressionEqualsCharacter()
- {
- var result = _evaluator.Evaluate("a", "\"\"");
- Assert.IsFalse(result);
- }
- #endregion
-
- #region NotEqualToZero Expression Tests
- [TestMethod]
- public void EvaluateNotEqualToZeroExpressionEqualsNull()
- {
- var result = _evaluator.Evaluate(null, "<>0");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToZeroExpressionEqualsEmptyString()
- {
- var result = _evaluator.Evaluate(string.Empty, "<>0");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToZeroExpressionEqualsCharacter()
- {
- var result = _evaluator.Evaluate("a", "<>0");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToZeroExpressionEqualsNonZero()
- {
- var result = _evaluator.Evaluate(1d, "<>0");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToZeroExpressionEqualsZero()
- {
- var result = _evaluator.Evaluate(0d, "<>0");
- Assert.IsFalse(result);
- }
- #endregion
-
- #region NotEqualToBlank Expression Tests
- [TestMethod]
- public void EvaluateNotEqualToBlankExpressionEqualsNull()
- {
- var result = _evaluator.Evaluate(null, "<>");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToBlankExpressionEqualsEmptyString()
- {
- var result = _evaluator.Evaluate(string.Empty, "<>");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToBlankExpressionEqualsCharacter()
- {
- var result = _evaluator.Evaluate("a", "<>");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToBlankExpressionEqualsNonZero()
- {
- var result = _evaluator.Evaluate(1d, "<>");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateNotEqualToBlankExpressionEqualsZero()
- {
- var result = _evaluator.Evaluate(0d, "<>");
- Assert.IsTrue(result);
- }
- #endregion
-
- #region Character Expression Tests
- [TestMethod]
- public void EvaluateCharacterExpressionEqualNull()
- {
- var result = _evaluator.Evaluate(null, "a");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterExpressionEqualsEmptyString()
- {
- var result = _evaluator.Evaluate(string.Empty, "a");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterExpressionEqualsNumeral()
- {
- var result = _evaluator.Evaluate(1d, "a");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterExpressionEqualsSameCharacter()
- {
- var result = _evaluator.Evaluate("a", "a");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterExpressionEqualsDifferentCharacter()
- {
- var result = _evaluator.Evaluate("b", "a");
- Assert.IsFalse(result);
- }
- #endregion
-
- #region CharacterWithOperator Expression Tests
- [TestMethod]
- public void EvaluateCharacterWithOperatorExpressionEqualNull()
- {
- var result = _evaluator.Evaluate(null, ">a");
- Assert.IsFalse(result);
- result = _evaluator.Evaluate(null, "<a");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterWithOperatorExpressionEqualsEmptyString()
- {
- var result = _evaluator.Evaluate(string.Empty, ">a");
- Assert.IsFalse(result);
- result = _evaluator.Evaluate(string.Empty, "<a");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterWithOperatorExpressionEqualsNumeral()
- {
- var result = _evaluator.Evaluate(1d, ">a");
- Assert.IsFalse(result);
- result = _evaluator.Evaluate(1d, "<a");
- Assert.IsFalse(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterWithOperatorExpressionEqualsSameCharacter()
- {
- var result = _evaluator.Evaluate("a", ">a");
- Assert.IsFalse(result);
- result = _evaluator.Evaluate("a", ">=a");
- Assert.IsTrue(result);
- result = _evaluator.Evaluate("a", "<a");
- Assert.IsFalse(result);
- result = _evaluator.Evaluate("a", ">=a");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateCharacterWithOperatorExpressionEqualsDifferentCharacter()
- {
- var result = _evaluator.Evaluate("b", ">a");
- Assert.IsTrue(result);
- result = _evaluator.Evaluate("b", "<a");
- Assert.IsFalse(result);
- }
- #endregion
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/IndexToAddressTranslatorTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/IndexToAddressTranslatorTests.cs
deleted file mode 100644
index c832a96..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/IndexToAddressTranslatorTests.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class IndexToAddressTranslatorTests
- {
- private ExcelDataProvider _excelDataProvider;
- private IndexToAddressTranslator _indexToAddressTranslator;
-
- [TestInitialize]
- public void Setup()
- {
- SetupTranslator(12345, ExcelReferenceType.RelativeRowAndColumn);
- }
-
- private void SetupTranslator(int maxRows, ExcelReferenceType refType)
- {
- _excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _excelDataProvider.Stub(x => x.ExcelMaxRows).Return(maxRows);
- _indexToAddressTranslator = new IndexToAddressTranslator(_excelDataProvider, refType);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void ShouldThrowIfExcelDataProviderIsNull()
- {
- new IndexToAddressTranslator(null);
- }
-
- [TestMethod]
- public void ShouldTranslate1And1ToA1()
- {
- var result = _indexToAddressTranslator.ToAddress(1, 1);
- Assert.AreEqual("A1", result);
- }
-
- [TestMethod]
- public void ShouldTranslate27And1ToAA1()
- {
- var result = _indexToAddressTranslator.ToAddress(27, 1);
- Assert.AreEqual("AA1", result);
- }
-
- [TestMethod]
- public void ShouldTranslate53And1ToBA1()
- {
- var result = _indexToAddressTranslator.ToAddress(53, 1);
- Assert.AreEqual("BA1", result);
- }
-
- [TestMethod]
- public void ShouldTranslate702And1ToZZ1()
- {
- var result = _indexToAddressTranslator.ToAddress(702, 1);
- Assert.AreEqual("ZZ1", result);
- }
-
- [TestMethod]
- public void ShouldTranslate703ToAAA4()
- {
- var result = _indexToAddressTranslator.ToAddress(703, 4);
- Assert.AreEqual("AAA4", result);
- }
-
- [TestMethod]
- public void ShouldTranslateToEntireColumnWhenRowIsEqualToMaxRows()
- {
- _excelDataProvider.Stub(x => x.ExcelMaxRows).Return(123456);
- var result = _indexToAddressTranslator.ToAddress(1, 123456);
- Assert.AreEqual("A", result);
- }
-
- [TestMethod]
- public void ShouldTranslateToAbsoluteAddress()
- {
- SetupTranslator(123456, ExcelReferenceType.AbsoluteRowAndColumn);
- var result = _indexToAddressTranslator.ToAddress(1, 1);
- Assert.AreEqual("$A$1", result);
- }
-
- [TestMethod]
- public void ShouldTranslateToAbsoluteRowAndRelativeCol()
- {
- SetupTranslator(123456, ExcelReferenceType.AbsoluteRowRelativeColumn);
- var result = _indexToAddressTranslator.ToAddress(1, 1);
- Assert.AreEqual("A$1", result);
- }
-
- [TestMethod]
- public void ShouldTranslateToRelativeRowAndAbsoluteCol()
- {
- SetupTranslator(123456, ExcelReferenceType.RelativeRowAbsolutColumn);
- var result = _indexToAddressTranslator.ToAddress(1, 1);
- Assert.AreEqual("$A1", result);
- }
-
- [TestMethod]
- public void ShouldTranslateToRelativeRowAndCol()
- {
- SetupTranslator(123456, ExcelReferenceType.RelativeRowAndColumn);
- var result = _indexToAddressTranslator.ToAddress(1, 1);
- Assert.AreEqual("A1", result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/NumericExpressionEvaluatorTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/NumericExpressionEvaluatorTests.cs
deleted file mode 100644
index 6a33725..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/NumericExpressionEvaluatorTests.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class NumericExpressionEvaluatorTests
- {
- private NumericExpressionEvaluator _evaluator;
-
- [TestInitialize]
- public void Setup()
- {
- _evaluator = new NumericExpressionEvaluator();
- }
-
- [TestMethod]
- public void EvaluateShouldReturnTrueIfOperandsAreEqual()
- {
- var result = _evaluator.Evaluate("1", "1");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldReturnTrueIfOperandsAreMatchingButDifferentTypes()
- {
- var result = _evaluator.Evaluate(1d, "1");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldEvaluateOperator()
- {
- var result = _evaluator.Evaluate(1d, "<2");
- Assert.IsTrue(result);
- }
-
- [TestMethod]
- public void EvaluateShouldEvaluateNumericString()
- {
- var result = _evaluator.Evaluate("1", ">0");
- Assert.IsTrue(result);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void EvaluateShouldThrowIfOperatorIsNotBoolean()
- {
- var result = _evaluator.Evaluate(1d, "+1");
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/RangeAddressFactoryTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/RangeAddressFactoryTests.cs
deleted file mode 100644
index 6e6b75e..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/RangeAddressFactoryTests.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class RangeAddressFactoryTests
- {
- private RangeAddressFactory _factory;
- private const int ExcelMaxRows = 1048576;
-
- [TestInitialize]
- public void Setup()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- provider.Stub(x => x.ExcelMaxRows).Return(ExcelMaxRows);
- _factory = new RangeAddressFactory(provider);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void CreateShouldThrowIfSuppliedAddressIsNull()
- {
- _factory.Create(null);
- }
-
- [TestMethod]
- public void CreateShouldReturnAndInstanceWithColPropertiesSet()
- {
- var address = _factory.Create("A2");
- Assert.AreEqual(1, address.FromCol, "FromCol was not 1");
- Assert.AreEqual(1, address.ToCol, "ToCol was not 1");
- }
-
- [TestMethod]
- public void CreateShouldReturnAndInstanceWithRowPropertiesSet()
- {
- var address = _factory.Create("A2");
- Assert.AreEqual(2, address.FromRow, "FromRow was not 2");
- Assert.AreEqual(2, address.ToRow, "ToRow was not 2");
- }
-
- [TestMethod]
- public void CreateShouldReturnAnInstanceWithFromAndToColSetWhenARangeAddressIsSupplied()
- {
- var address = _factory.Create("A1:B2");
- Assert.AreEqual(1, address.FromCol);
- Assert.AreEqual(2, address.ToCol);
- }
-
- [TestMethod]
- public void CreateShouldReturnAnInstanceWithFromAndToRowSetWhenARangeAddressIsSupplied()
- {
- var address = _factory.Create("A1:B3");
- Assert.AreEqual(1, address.FromRow);
- Assert.AreEqual(3, address.ToRow);
- }
-
- [TestMethod]
- public void CreateShouldSetWorksheetNameIfSuppliedInAddress()
- {
- var address = _factory.Create("Ws!A1");
- Assert.AreEqual("Ws", address.Worksheet);
- }
-
- [TestMethod]
- public void CreateShouldReturnAnInstanceWithStringAddressSet()
- {
- var address = _factory.Create(1, 1);
- Assert.AreEqual("A1", address.ToString());
- }
-
- [TestMethod]
- public void CreateShouldReturnAnInstanceWithFromAndToColSet()
- {
- var address = _factory.Create(1, 0);
- Assert.AreEqual(1, address.FromCol);
- Assert.AreEqual(1, address.ToCol);
- }
-
- [TestMethod]
- public void CreateShouldReturnAnInstanceWithFromAndToRowSet()
- {
- var address = _factory.Create(0, 1);
- Assert.AreEqual(1, address.FromRow);
- Assert.AreEqual(1, address.ToRow);
- }
-
- [TestMethod]
- public void CreateShouldReturnAnInstanceWithWorksheetSetToEmptyString()
- {
- var address = _factory.Create(0, 1);
- Assert.AreEqual(string.Empty, address.Worksheet);
- }
-
- [TestMethod]
- public void CreateShouldReturnEntireColumnRangeWhenNoRowsAreSpecified()
- {
- var address = _factory.Create("A:B");
- Assert.AreEqual(1, address.FromCol);
- Assert.AreEqual(2, address.ToCol);
- Assert.AreEqual(1, address.FromRow);
- Assert.AreEqual(ExcelMaxRows, address.ToRow);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/RangeAddressTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/RangeAddressTests.cs
deleted file mode 100644
index f8527b9..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/RangeAddressTests.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class RangeAddressTests
- {
- private RangeAddressFactory _factory;
-
- [TestInitialize]
- public void Setup()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- _factory = new RangeAddressFactory(provider);
- }
-
- [TestMethod]
- public void CollideShouldReturnTrueIfRangesCollides()
- {
- var address1 = _factory.Create("A1:A6");
- var address2 = _factory.Create("A5");
- Assert.IsTrue(address1.CollidesWith(address2));
- }
-
- [TestMethod]
- public void CollideShouldReturnFalseIfRangesDoesNotCollide()
- {
- var address1 = _factory.Create("A1:A6");
- var address2 = _factory.Create("A8");
- Assert.IsFalse(address1.CollidesWith(address2));
- }
-
- [TestMethod]
- public void CollideShouldReturnFalseIfRangesCollidesButWorksheetNameDiffers()
- {
- var address1 = _factory.Create("Ws!A1:A6");
- var address2 = _factory.Create("A5");
- Assert.IsFalse(address1.CollidesWith(address2));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/RangesTest.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/RangesTest.cs
deleted file mode 100644
index 543725d..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/RangesTest.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class RangesTest
- {
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/ValueMatcherTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/ValueMatcherTests.cs
deleted file mode 100644
index 0b33b94..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/ValueMatcherTests.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class ValueMatcherTests
- {
- private ValueMatcher _matcher;
-
- [TestInitialize]
- public void Setup()
- {
- _matcher = new ValueMatcher();
- }
-
- [TestMethod]
- public void ShouldReturn1WhenFirstParamIsSomethingAndSecondParamIsNull()
- {
- object o1 = 1;
- object o2 = null;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(1, result);
- }
-
- [TestMethod]
- public void ShouldReturnMinus1WhenFirstParamIsNullAndSecondParamIsSomething()
- {
- object o1 = null;
- object o2 = 1;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(-1, result);
- }
-
- [TestMethod]
- public void ShouldReturn0WhenBothParamsAreNull()
- {
- object o1 = null;
- object o2 = null;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(0, result);
- }
-
- [TestMethod]
- public void ShouldReturn0WhenBothParamsAreEqual()
- {
- object o1 = 1d;
- object o2 = 1d;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(0, result);
- }
-
- [TestMethod]
- public void ShouldReturnMinus1WhenFirstParamIsLessThanSecondParam()
- {
- object o1 = 1d;
- object o2 = 5d;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(-1, result);
- }
-
- [TestMethod]
- public void ShouldReturn1WhenFirstParamIsGreaterThanSecondParam()
- {
- object o1 = 3d;
- object o2 = 1d;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(1, result);
- }
-
- [TestMethod]
- public void ShouldReturn0WhenWhenParamsAreEqualStrings()
- {
- object o1 = "T";
- object o2 = "T";
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(0, result);
- }
-
- [TestMethod]
- public void ShouldReturn0WhenParamsAreEqualButDifferentTypes()
- {
- object o1 = "2";
- object o2 = 2d;
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(0, result, "IsMatch did not return 0 as expected when first param is a string and second a double");
-
- o1 = 2d;
- o2 = "2";
- result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(0, result, "IsMatch did not return 0 as expected when first param is a double and second a string");
- }
-
- [TestMethod]
- public void ShouldReturnMînus2WhenTypesDifferAndStringConversionToDoubleFails()
- {
- object o1 = 2d;
- object o2 = "T";
- var result = _matcher.IsMatch(o1, o2);
- Assert.AreEqual(-2, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExcelUtilities/WildCardValueMatcherTests.cs b/EPPlusTest/FormulaParsing/ExcelUtilities/WildCardValueMatcherTests.cs
deleted file mode 100644
index 60126e9..0000000
--- a/EPPlusTest/FormulaParsing/ExcelUtilities/WildCardValueMatcherTests.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.ExcelUtilities
-{
- [TestClass]
- public class WildCardValueMatcherTests
- {
- private WildCardValueMatcher _matcher;
-
- [TestInitialize]
- public void Setup()
- {
- _matcher = new WildCardValueMatcher();
- }
-
- [TestMethod]
- public void IsMatchShouldReturn0WhenSingleCharWildCardMatches()
- {
- var string1 = "a?c?";
- var string2 = "abcd";
- var result = _matcher.IsMatch(string1, string2);
- Assert.AreEqual(0, result);
- }
-
- [TestMethod]
- public void IsMatchShouldReturn0WhenMultipleCharWildCardMatches()
- {
- var string1 = "a*c.";
- var string2 = "abcc.";
- var result = _matcher.IsMatch(string1, string2);
- Assert.AreEqual(0, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/BooleanExpressionTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/BooleanExpressionTests.cs
deleted file mode 100644
index 555e372..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/BooleanExpressionTests.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class BooleanExpressionTests
- {
- //[TestMethod]
- //public void CompileShouldHandlePercent()
- //{
- // var exp1 = new BooleanExpression("TRUE");
- // exp1.Operator = Operator.Percent;
- // exp1.Next = ConstantExpressions.Percent;
- // var result = exp1.Compile();
- // Assert.AreEqual(0.01, result.Result);
- // Assert.AreEqual(DataType.Decimal, result.DataType);
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/CompileResultFactoryTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/CompileResultFactoryTests.cs
deleted file mode 100644
index cec246e..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/CompileResultFactoryTests.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System.Globalization;
-using System.Threading;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class CompileResultFactoryTests
- {
- [TestMethod]
- public void CalculateUsingEuropeanDates()
- {
- var us = CultureInfo.CreateSpecificCulture("en-US");
- Thread.CurrentThread.CurrentCulture = us;
- var crf = new CompileResultFactory();
- var result = crf.Create("1/15/2014");
- var numeric = result.ResultNumeric;
- Assert.AreEqual(41654, numeric);
- var gb = CultureInfo.CreateSpecificCulture("en-GB");
- Thread.CurrentThread.CurrentCulture = gb;
- var euroResult = crf.Create("15/1/2014");
- var eNumeric = euroResult.ResultNumeric;
- Assert.AreEqual(41654, eNumeric);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/CompileResultTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/CompileResultTests.cs
deleted file mode 100644
index a71ba91..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/CompileResultTests.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class CompileResultTests
- {
- [TestMethod]
- public void NumericStringCompileResult()
- {
- var expected = 124.24;
- string numericString = expected.ToString("n");
- CompileResult result = new CompileResult(numericString, DataType.String);
- Assert.IsFalse(result.IsNumeric);
- Assert.IsTrue(result.IsNumericString);
- Assert.AreEqual(expected, result.ResultNumeric);
- }
-
- [TestMethod]
- public void DateStringCompileResult()
- {
- var expected = new DateTime(2013, 1, 15);
- string dateString = expected.ToString("d");
- CompileResult result = new CompileResult(dateString, DataType.String);
- Assert.IsFalse(result.IsNumeric);
- Assert.IsTrue(result.IsDateString);
- Assert.AreEqual(expected.ToOADate(), result.ResultNumeric);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/DecimalExpressionTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/DecimalExpressionTests.cs
deleted file mode 100644
index 0bd6464..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/DecimalExpressionTests.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class DecimalExpressionTests
- {
- //[TestMethod]
- //public void CompileShouldHandlePercent()
- //{
- // var exp1 = new DecimalExpression("1");
- // exp1.Operator = Operator.Percent;
- // exp1.Next = ConstantExpressions.Percent;
- // var result = exp1.Compile();
- // Assert.AreEqual(0.01, result.Result);
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/EnumerableExpressionTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/EnumerableExpressionTests.cs
deleted file mode 100644
index ac39160..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/EnumerableExpressionTests.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class EnumerableExpressionTests
- {
- [TestMethod]
- public void CompileShouldReturnEnumerableOfCompiledChildExpressions()
- {
- var expression = new EnumerableExpression();
- expression.AddChild(new IntegerExpression("2"));
- expression.AddChild(new IntegerExpression("3"));
- var result = expression.Compile();
-
- Assert.IsInstanceOfType(result.Result, typeof(IEnumerable<object>));
- var resultList = (IEnumerable<object>)result.Result;
- Assert.AreEqual(2d, resultList.ElementAt(0));
- Assert.AreEqual(3d, resultList.ElementAt(1));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/ExcelAddressExpressionTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/ExcelAddressExpressionTests.cs
deleted file mode 100644
index daec740..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/ExcelAddressExpressionTests.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class ExcelAddressExpressionTests
- {
- private ParsingContext _parsingContext;
- private ParsingScope _scope;
-
- private ExcelCell CreateItem(object val)
- {
- return new ExcelCell(val, null, 0, 0);
- }
-
- [TestInitialize]
- public void Setup()
- {
- _parsingContext = ParsingContext.Create();
- _scope = _parsingContext.Scopes.NewScope(RangeAddress.Empty);
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _scope.Dispose();
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void ConstructorShouldThrowIfExcelDataProviderIsNull()
- {
- new ExcelAddressExpression("A1", null, _parsingContext);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void ConstructorShouldThrowIfParsingContextIsNull()
- {
- new ExcelAddressExpression("A1", MockRepository.GenerateStub<ExcelDataProvider>(), null);
- }
-
- //TODO:Fix Test /Janne
- //[TestMethod]
- //public void ShouldCallReturnResultFromProvider()
- //{
- // var expectedAddress = "A1";
- // var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- // provider
- // .Stub(x => x.GetRangeValues(string.Empty, expectedAddress))
- // .Return(new object[]{ 1 });
-
- // var expression = new ExcelAddressExpression(expectedAddress, provider, _parsingContext);
- // var result = expression.Compile();
- // Assert.AreEqual(1, result.Result);
- //}
-
- //TODO:Fix Test /Janne
- //[TestMethod]
- //public void CompileShouldReturnAddress()
- //{
- // var expectedAddress = "A1";
- // var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- // provider
- // .Stub(x => x.GetRangeValues(expectedAddress))
- // .Return(new ExcelCell[] { CreateItem(1) });
-
- // var expression = new ExcelAddressExpression(expectedAddress, provider, _parsingContext);
- // expression.ParentIsLookupFunction = true;
- // var result = expression.Compile();
- // Assert.AreEqual(expectedAddress, result.Result);
-
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionCompilerTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionCompilerTests.cs
deleted file mode 100644
index 6f46366..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionCompilerTests.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using ExpGraph = OfficeOpenXml.FormulaParsing.ExpressionGraph.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class ExpressionCompilerTests
- {
- private IExpressionCompiler _expressionCompiler;
- private ExpGraph _graph;
-
- [TestInitialize]
- public void Setup()
- {
- _expressionCompiler = new ExpressionCompiler();
- _graph = new ExpGraph();
- }
-
- [TestMethod]
- public void ShouldCompileTwoInterExpressionsToCorrectResult()
- {
- var exp1 = new IntegerExpression("2");
- exp1.Operator = Operator.Plus;
- _graph.Add(exp1);
- var exp2 = new IntegerExpression("2");
- _graph.Add(exp2);
-
- var result = _expressionCompiler.Compile(_graph.Expressions);
-
- Assert.AreEqual(4d, result.Result);
- }
-
-
- [TestMethod]
- public void CompileShouldMultiplyGroupExpressionWithFollowingIntegerExpression()
- {
- var groupExpression = new GroupExpression(false);
- groupExpression.AddChild(new IntegerExpression("2"));
- groupExpression.Children.First().Operator = Operator.Plus;
- groupExpression.AddChild(new IntegerExpression("3"));
- groupExpression.Operator = Operator.Multiply;
-
- _graph.Add(groupExpression);
- _graph.Add(new IntegerExpression("2"));
-
- var result = _expressionCompiler.Compile(_graph.Expressions);
-
- Assert.AreEqual(10d, result.Result);
- }
-
- [TestMethod]
- public void CompileShouldCalculateMultipleExpressionsAccordingToPrecedence()
- {
- var exp1 = new IntegerExpression("2");
- exp1.Operator = Operator.Multiply;
- _graph.Add(exp1);
- var exp2 = new IntegerExpression("2");
- exp2.Operator = Operator.Plus;
- _graph.Add(exp2);
- var exp3 = new IntegerExpression("2");
- exp3.Operator = Operator.Multiply;
- _graph.Add(exp3);
- var exp4 = new IntegerExpression("2");
- _graph.Add(exp4);
-
- var result = _expressionCompiler.Compile(_graph.Expressions);
-
- Assert.AreEqual(8d, result.Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionConverterTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionConverterTests.cs
deleted file mode 100644
index 6a32834..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionConverterTests.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class ExpressionConverterTests
- {
- private IExpressionConverter _converter;
-
- [TestInitialize]
- public void Setup()
- {
- _converter = new ExpressionConverter();
- }
-
- [TestMethod]
- public void ToStringExpressionShouldConvertIntegerExpressionToStringExpression()
- {
- var integerExpression = new IntegerExpression("2");
- var result = _converter.ToStringExpression(integerExpression);
- Assert.IsInstanceOfType(result, typeof(StringExpression));
- Assert.AreEqual("2", result.Compile().Result);
- }
-
- [TestMethod]
- public void ToStringExpressionShouldCopyOperatorToStringExpression()
- {
- var integerExpression = new IntegerExpression("2");
- integerExpression.Operator = Operator.Plus;
- var result = _converter.ToStringExpression(integerExpression);
- Assert.AreEqual(integerExpression.Operator, result.Operator);
- }
-
- [TestMethod]
- public void ToStringExpressionShouldConvertDecimalExpressionToStringExpression()
- {
- var decimalExpression = new DecimalExpression("2.5");
- var result = _converter.ToStringExpression(decimalExpression);
- Assert.IsInstanceOfType(result, typeof(StringExpression));
- Assert.AreEqual("2,5", result.Compile().Result);
- }
-
- [TestMethod]
- public void FromCompileResultShouldCreateIntegerExpressionIfCompileResultIsInteger()
- {
- var compileResult = new CompileResult(1, DataType.Integer);
- var result = _converter.FromCompileResult(compileResult);
- Assert.IsInstanceOfType(result, typeof(IntegerExpression));
- Assert.AreEqual(1d, result.Compile().Result);
- }
-
- [TestMethod]
- public void FromCompileResultShouldCreateStringExpressionIfCompileResultIsString()
- {
- var compileResult = new CompileResult("abc", DataType.String);
- var result = _converter.FromCompileResult(compileResult);
- Assert.IsInstanceOfType(result, typeof(StringExpression));
- Assert.AreEqual("abc", result.Compile().Result);
- }
-
- [TestMethod]
- public void FromCompileResultShouldCreateDecimalExpressionIfCompileResultIsDecimal()
- {
- var compileResult = new CompileResult(2.5d, DataType.Decimal);
- var result = _converter.FromCompileResult(compileResult);
- Assert.IsInstanceOfType(result, typeof(DecimalExpression));
- Assert.AreEqual(2.5d, result.Compile().Result);
- }
-
- [TestMethod]
- public void FromCompileResultShouldCreateBooleanExpressionIfCompileResultIsBoolean()
- {
- var compileResult = new CompileResult("true", DataType.Boolean);
- var result = _converter.FromCompileResult(compileResult);
- Assert.IsInstanceOfType(result, typeof(BooleanExpression));
- Assert.IsTrue((bool)result.Compile().Result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionFactoryTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionFactoryTests.cs
deleted file mode 100644
index 6ab3a3f..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionFactoryTests.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class ExpressionFactoryTests
- {
- private IExpressionFactory _factory;
- private ParsingContext _parsingContext;
-
- [TestInitialize]
- public void Setup()
- {
- _parsingContext = ParsingContext.Create();
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- _factory = new ExpressionFactory(provider, _parsingContext);
- }
-
- [TestMethod]
- public void ShouldReturnIntegerExpressionWhenTokenIsInteger()
- {
- var token = new Token("2", TokenType.Integer);
- var expression = _factory.Create(token);
- Assert.IsInstanceOfType(expression, typeof(IntegerExpression));
- }
-
- [TestMethod]
- public void ShouldReturnBooleanExpressionWhenTokenIsBoolean()
- {
- var token = new Token("true", TokenType.Boolean);
- var expression = _factory.Create(token);
- Assert.IsInstanceOfType(expression, typeof(BooleanExpression));
- }
-
- [TestMethod]
- public void ShouldReturnDecimalExpressionWhenTokenIsDecimal()
- {
- var token = new Token("2.5", TokenType.Decimal);
- var expression = _factory.Create(token);
- Assert.IsInstanceOfType(expression, typeof(DecimalExpression));
- }
-
- [TestMethod]
- public void ShouldReturnExcelRangeExpressionWhenTokenIsExcelAddress()
- {
- var token = new Token("A1", TokenType.ExcelAddress);
- var expression = _factory.Create(token);
- Assert.IsInstanceOfType(expression, typeof(ExcelAddressExpression));
- }
-
- [TestMethod]
- public void ShouldReturnNamedValueExpressionWhenTokenIsNamedValue()
- {
- var token = new Token("NamedValue", TokenType.NameValue);
- var expression = _factory.Create(token);
- Assert.IsInstanceOfType(expression, typeof(NamedValueExpression));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionGraphBuilderTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionGraphBuilderTests.cs
deleted file mode 100644
index 2a40ab8..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/ExpressionGraphBuilderTests.cs
+++ /dev/null
@@ -1,286 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph.CompileStrategy;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class ExpressionGraphBuilderTests
- {
- private IExpressionGraphBuilder _graphBuilder;
- private ExcelDataProvider _excelDataProvider;
-
- [TestInitialize]
- public void Setup()
- {
- _excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- var parsingContext = ParsingContext.Create();
- _graphBuilder = new ExpressionGraphBuilder(_excelDataProvider, parsingContext);
- }
-
- [TestCleanup]
- public void Cleanup()
- {
-
- }
-
- [TestMethod]
- public void BuildShouldNotUseStringIdentifyersWhenBuildingStringExpression()
- {
- var tokens = new List<Token>
- {
- new Token("'", TokenType.String),
- new Token("abc", TokenType.StringContent),
- new Token("'", TokenType.String)
- };
-
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(1, result.Expressions.Count());
- }
-
- [TestMethod]
- public void BuildShouldNotEvaluateExpressionsWithinAString()
- {
- var tokens = new List<Token>
- {
- new Token("'", TokenType.String),
- new Token("1 + 2", TokenType.StringContent),
- new Token("'", TokenType.String)
- };
-
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual("1 + 2", result.Expressions.First().Compile().Result);
- }
-
- [TestMethod]
- public void BuildShouldSetOperatorOnGroupExpressionCorrectly()
- {
- var tokens = new List<Token>
- {
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token("+", TokenType.Operator),
- new Token("4", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis),
- new Token("*", TokenType.Operator),
- new Token("2", TokenType.Integer)
- };
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(Operator.Multiply.Operator, result.Expressions.First().Operator.Operator);
-
- }
-
- [TestMethod]
- public void BuildShouldSetChildrenOnGroupExpression()
- {
- var tokens = new List<Token>
- {
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token("+", TokenType.Operator),
- new Token("4", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis),
- new Token("*", TokenType.Operator),
- new Token("2", TokenType.Integer)
- };
- var result = _graphBuilder.Build(tokens);
-
- Assert.IsInstanceOfType(result.Expressions.First(), typeof(GroupExpression));
- Assert.AreEqual(2, result.Expressions.First().Children.Count());
- }
-
- [TestMethod]
- public void BuildShouldSetNextOnGroupedExpression()
- {
- var tokens = new List<Token>
- {
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token("+", TokenType.Operator),
- new Token("4", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis),
- new Token("*", TokenType.Operator),
- new Token("2", TokenType.Integer)
- };
- var result = _graphBuilder.Build(tokens);
-
- Assert.IsNotNull(result.Expressions.First().Next);
- Assert.IsInstanceOfType(result.Expressions.First().Next, typeof(IntegerExpression));
-
- }
-
- [TestMethod]
- public void BuildShouldBuildFunctionExpressionIfFirstTokenIsFunction()
- {
- var tokens = new List<Token>
- {
- new Token("CStr", TokenType.Function),
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis),
- };
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(1, result.Expressions.Count());
- Assert.IsInstanceOfType(result.Expressions.First(), typeof(FunctionExpression));
- }
-
- [TestMethod]
- public void BuildShouldSetChildrenOnFunctionExpression()
- {
- var tokens = new List<Token>
- {
- new Token("CStr", TokenType.Function),
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis)
- };
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(1, result.Expressions.First().Children.Count());
- Assert.IsInstanceOfType(result.Expressions.First().Children.First(), typeof(GroupExpression));
- Assert.IsInstanceOfType(result.Expressions.First().Children.First().Children.First(), typeof(IntegerExpression));
- Assert.AreEqual(2d, result.Expressions.First().Children.First().Compile().Result);
- }
-
- [TestMethod]
- public void BuildShouldAddOperatorToFunctionExpression()
- {
- var tokens = new List<Token>
- {
- new Token("CStr", TokenType.Function),
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis),
- new Token("&", TokenType.Operator),
- new Token("A", TokenType.StringContent)
- };
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(1, result.Expressions.First().Children.Count());
- Assert.AreEqual(2, result.Expressions.Count());
- }
-
- [TestMethod]
- public void BuildShouldAddCommaSeparatedFunctionArgumentsAsChildrenToFunctionExpression()
- {
- var tokens = new List<Token>
- {
- new Token("Text", TokenType.Function),
- new Token("(", TokenType.OpeningParenthesis),
- new Token("2", TokenType.Integer),
- new Token(",", TokenType.Comma),
- new Token("3", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis),
- new Token("&", TokenType.Operator),
- new Token("A", TokenType.StringContent)
- };
-
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(2, result.Expressions.First().Children.Count());
- }
-
- [TestMethod]
- public void BuildShouldCreateASingleExpressionOutOfANegatorAndANumericToken()
- {
- var tokens = new List<Token>
- {
- new Token("-", TokenType.Negator),
- new Token("2", TokenType.Integer),
- };
-
- var result = _graphBuilder.Build(tokens);
-
- Assert.AreEqual(1, result.Expressions.Count());
- Assert.AreEqual(-2d, result.Expressions.First().Compile().Result);
- }
-
- [TestMethod]
- public void BuildShouldHandleEnumerableTokens()
- {
- var tokens = new List<Token>
- {
- new Token("Text", TokenType.Function),
- new Token("(", TokenType.OpeningParenthesis),
- new Token("{", TokenType.OpeningEnumerable),
- new Token("2", TokenType.Integer),
- new Token(",", TokenType.Comma),
- new Token("3", TokenType.Integer),
- new Token("}", TokenType.ClosingEnumerable),
- new Token(")", TokenType.ClosingParenthesis)
- };
-
- var result = _graphBuilder.Build(tokens);
- var funcArgExpression = result.Expressions.First().Children.First();
- Assert.IsInstanceOfType(funcArgExpression, typeof(FunctionArgumentExpression));
-
- var enumerableExpression = funcArgExpression.Children.First();
-
- Assert.IsInstanceOfType(enumerableExpression, typeof(EnumerableExpression));
- Assert.AreEqual(2, enumerableExpression.Children.Count(), "Enumerable.Count was not 2");
- }
-
- [TestMethod]
- public void ShouldHandleInnerFunctionCall2()
- {
- var ctx = ParsingContext.Create();
- const string formula = "IF(3>2;\"Yes\";\"No\")";
- var tokenizer = new SourceCodeTokenizer(ctx.Configuration.FunctionRepository, ctx.NameValueProvider);
- var tokens = tokenizer.Tokenize(formula);
- var expression = _graphBuilder.Build(tokens);
- Assert.AreEqual(1, expression.Expressions.Count());
-
- var compiler = new ExpressionCompiler(new ExpressionConverter(), new CompileStrategyFactory());
- var result = compiler.Compile(expression.Expressions);
- Assert.AreEqual("Yes", result.Result);
- }
-
- [TestMethod]
- public void ShouldHandleInnerFunctionCall3()
- {
- var ctx = ParsingContext.Create();
- const string formula = "IF(I10>=0;IF(O10>I10;((O10-I10)*$B10)/$C$27;IF(O10<0;(O10*$B10)/$C$27;\"\"));IF(O10<0;((O10-I10)*$B10)/$C$27;IF(O10>0;(O10*$B10)/$C$27;)))";
- var tokenizer = new SourceCodeTokenizer(ctx.Configuration.FunctionRepository, ctx.NameValueProvider);
- var tokens = tokenizer.Tokenize(formula);
- var expression = _graphBuilder.Build(tokens);
- Assert.AreEqual(1, expression.Expressions.Count());
- var exp1 = expression.Expressions.First();
- Assert.AreEqual(3, exp1.Children.Count());
- }
- [TestMethod]
- public void RemoveDuplicateOperators1()
- {
- var ctx = ParsingContext.Create();
- const string formula = "++1--2++-3+-1----3-+2";
- var tokenizer = new SourceCodeTokenizer(ctx.Configuration.FunctionRepository, ctx.NameValueProvider);
- var tokens = tokenizer.Tokenize(formula).ToList();
- var expression = _graphBuilder.Build(tokens);
- Assert.AreEqual(11, tokens.Count());
- Assert.AreEqual("+", tokens[1].Value);
- Assert.AreEqual("-", tokens[3].Value);
- Assert.AreEqual("-", tokens[5].Value);
- Assert.AreEqual("+", tokens[7].Value);
- Assert.AreEqual("-", tokens[9].Value);
- }
- [TestMethod]
- public void RemoveDuplicateOperators2()
- {
- var ctx = ParsingContext.Create();
- const string formula = "++-1--(---2)++-3+-1----3-+2";
- var tokenizer = new SourceCodeTokenizer(ctx.Configuration.FunctionRepository, ctx.NameValueProvider);
- var tokens = tokenizer.Tokenize(formula).ToList();
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/FunctionCompilers/FunctionCompilerFactoryTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/FunctionCompilers/FunctionCompilerFactoryTests.cs
deleted file mode 100644
index f93de36..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/FunctionCompilers/FunctionCompilerFactoryTests.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph.FunctionCompilers;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph.FunctionCompilers
-{
- [TestClass]
- public class FunctionCompilerFactoryTests
- {
- #region Create Tests
- [TestMethod]
- public void CreateHandlesStandardFunctionCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new Sum();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(DefaultCompiler));
- }
-
- [TestMethod]
- public void CreateHandlesSpecialIfCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new If();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(IfFunctionCompiler));
- }
-
- [TestMethod]
- public void CreateHandlesSpecialIfErrorCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new IfError();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(IfErrorFunctionCompiler));
- }
-
- [TestMethod]
- public void CreateHandlesSpecialIfNaCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new IfNa();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(IfNaFunctionCompiler));
- }
-
- [TestMethod]
- public void CreateHandlesLookupFunctionCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new Column();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(LookupFunctionCompiler));
- }
-
- [TestMethod]
- public void CreateHandlesErrorFunctionCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new IsError();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(ErrorHandlingFunctionCompiler));
- }
-
- [TestMethod]
- public void CreateHandlesCustomFunctionCompiler()
- {
- var functionRepository = FunctionRepository.Create();
- functionRepository.LoadModule(new TestFunctionModule());
- var functionCompilerFactory = new FunctionCompilerFactory(functionRepository);
- var function = new MyFunction();
- var functionCompiler = functionCompilerFactory.Create(function);
- Assert.IsInstanceOfType(functionCompiler, typeof(MyFunctionCompiler));
- }
- #endregion
-
- #region Nested Classes
- public class TestFunctionModule : FunctionsModule
- {
- public TestFunctionModule()
- {
- var myFunction = new MyFunction();
- var customCompiler = new MyFunctionCompiler(myFunction);
- base.Functions.Add(MyFunction.Name, myFunction);
- base.CustomCompilers.Add(typeof(MyFunction), customCompiler);
- }
- }
-
- public class MyFunction : ExcelFunction
- {
- public const string Name = "MyFunction";
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- throw new NotImplementedException();
- }
- }
-
- public class MyFunctionCompiler : FunctionCompiler
- {
- public MyFunctionCompiler(MyFunction function) : base(function) { }
- public override CompileResult Compile(IEnumerable<Expression> children, ParsingContext context)
- {
- throw new NotImplementedException();
- }
- }
- #endregion
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ExpressionGraph/IntegerExpressionTests.cs b/EPPlusTest/FormulaParsing/ExpressionGraph/IntegerExpressionTests.cs
deleted file mode 100644
index f9cf359..0000000
--- a/EPPlusTest/FormulaParsing/ExpressionGraph/IntegerExpressionTests.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.Excel.Operators;
-
-namespace EPPlusTest.FormulaParsing.ExpressionGraph
-{
- [TestClass]
- public class IntegerExpressionTests
- {
- [TestMethod]
- public void MergeWithNextWithPlusOperatorShouldCalulateSumCorrectly()
- {
- var exp1 = new IntegerExpression("1");
- exp1.Operator = Operator.Plus;
- var exp2 = new IntegerExpression("2");
- exp1.Next = exp2;
-
- var result = exp1.MergeWithNext();
-
- Assert.AreEqual(3d, result.Compile().Result);
- }
-
- [TestMethod]
- public void MergeWithNextWithPlusOperatorShouldSetNextPointer()
- {
- var exp1 = new IntegerExpression("1");
- exp1.Operator = Operator.Plus;
- var exp2 = new IntegerExpression("2");
- exp1.Next = exp2;
-
- var result = exp1.MergeWithNext();
-
- Assert.IsNull(result.Next);
- }
-
- //[TestMethod]
- //public void CompileShouldHandlePercent()
- //{
- // var exp1 = new IntegerExpression("1");
- // exp1.Operator = Operator.Percent;
- // exp1.Next = ConstantExpressions.Percent;
- // var result = exp1.Compile();
- // Assert.AreEqual(0.01, result.Result);
- // Assert.AreEqual(DataType.Decimal, result.DataType);
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/FormulaParserManagerTests.cs b/EPPlusTest/FormulaParsing/FormulaParserManagerTests.cs
deleted file mode 100644
index 2c41964..0000000
--- a/EPPlusTest/FormulaParsing/FormulaParserManagerTests.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph.FunctionCompilers;
-
-namespace EPPlusTest.FormulaParsing
-{
- [TestClass]
- public class FormulaParserManagerTests
- {
- #region test classes
-
- private class MyFunction : ExcelFunction
- {
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- throw new NotImplementedException();
- }
- }
-
- private class MyModule : IFunctionModule
- {
- public MyModule()
- {
- Functions = new Dictionary<string, ExcelFunction>();
- Functions.Add("MyFunction", new MyFunction());
-
- CustomCompilers = new Dictionary<Type, FunctionCompiler>();
- }
- public IDictionary<string, ExcelFunction> Functions { get; }
- public IDictionary<Type, FunctionCompiler> CustomCompilers { get; }
- }
- #endregion
-
- [TestMethod]
- public void FunctionsShouldBeCopied()
- {
- using (var package1 = new ExcelPackage())
- {
- package1.Workbook.FormulaParserManager.LoadFunctionModule(new MyModule());
- using (var package2 = new ExcelPackage())
- {
- var origNumberOfFuncs = package2.Workbook.FormulaParserManager.GetImplementedFunctionNames().Count();
-
- // replace functions including the custom functions from package 1
- package2.Workbook.FormulaParserManager.CopyFunctionsFrom(package1.Workbook);
-
- // Assertions: number of functions are increased with 1, and the list of function names contains the custom function.
- Assert.AreEqual(origNumberOfFuncs + 1, package2.Workbook.FormulaParserManager.GetImplementedFunctionNames().Count());
- Assert.IsTrue(package2.Workbook.FormulaParserManager.GetImplementedFunctionNames().Contains("myfunction"));
- }
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/FormulaParserTests.cs b/EPPlusTest/FormulaParsing/FormulaParserTests.cs
deleted file mode 100644
index c3cdb14..0000000
--- a/EPPlusTest/FormulaParsing/FormulaParserTests.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-using ExGraph = OfficeOpenXml.FormulaParsing.ExpressionGraph.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-
-namespace EPPlusTest.FormulaParsing
-{
- [TestClass]
- public class FormulaParserTests
- {
- private FormulaParser _parser;
-
- [TestInitialize]
- public void Setup()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(provider);
-
- }
-
- [TestCleanup]
- public void Cleanup()
- {
-
- }
-
- [TestMethod]
- public void ParserShouldCallLexer()
- {
- var lexer = MockRepository.GenerateStub<ILexer>();
- lexer.Stub(x => x.Tokenize("ABC")).Return(Enumerable.Empty<Token>());
- _parser.Configure(x => x.SetLexer(lexer));
-
- _parser.Parse("ABC");
-
- lexer.AssertWasCalled(x => x.Tokenize("ABC"));
- }
-
- [TestMethod]
- public void ParserShouldCallGraphBuilder()
- {
- var lexer = MockRepository.GenerateStub<ILexer>();
- var tokens = new List<Token>();
- lexer.Stub(x => x.Tokenize("ABC")).Return(tokens);
- var graphBuilder = MockRepository.GenerateStub<IExpressionGraphBuilder>();
- graphBuilder.Stub(x => x.Build(tokens)).Return(new ExGraph());
-
- _parser.Configure(config =>
- {
- config
- .SetLexer(lexer)
- .SetGraphBuilder(graphBuilder);
- });
-
- _parser.Parse("ABC");
-
- graphBuilder.AssertWasCalled(x => x.Build(tokens));
- }
-
- [TestMethod]
- public void ParserShouldCallCompiler()
- {
- var lexer = MockRepository.GenerateStub<ILexer>();
- var tokens = new List<Token>();
- lexer.Stub(x => x.Tokenize("ABC")).Return(tokens);
- var expectedGraph = new ExGraph();
- expectedGraph.Add(new StringExpression("asdf"));
- var graphBuilder = MockRepository.GenerateStub<IExpressionGraphBuilder>();
- graphBuilder.Stub(x => x.Build(tokens)).Return(expectedGraph);
- var compiler = MockRepository.GenerateStub<IExpressionCompiler>();
- compiler.Stub(x => x.Compile(expectedGraph.Expressions)).Return(new CompileResult(0, DataType.Integer));
-
- _parser.Configure(config =>
- {
- config
- .SetLexer(lexer)
- .SetGraphBuilder(graphBuilder)
- .SetExpresionCompiler(compiler);
- });
-
- _parser.Parse("ABC");
-
- compiler.AssertWasCalled(x => x.Compile(expectedGraph.Expressions));
- }
-
- [TestMethod]
- public void ParseAtShouldCallExcelDataProvider()
- {
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- excelDataProvider
- .Stub(x => x.GetRangeFormula(string.Empty, 1, 1))
- .Return("Sum(1,2)");
- var parser = new FormulaParser(excelDataProvider);
- var result = parser.ParseAt("A1");
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void ParseAtShouldThrowIfAddressIsNull()
- {
- _parser.ParseAt(null);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BasicCalcTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BasicCalcTests.cs
deleted file mode 100644
index b787f5e..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BasicCalcTests.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests
-{
- [TestClass]
- public class BasicCalcTests : FormulaParserTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(excelDataProvider);
- }
-
- [TestMethod]
- public void ShouldAddIntegersCorrectly()
- {
- var result = _parser.Parse("1 + 2");
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void ShouldSubtractIntegersCorrectly()
- {
- var result = _parser.Parse("2 - 1");
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void ShouldMultiplyIntegersCorrectly()
- {
- var result = _parser.Parse("2 * 3");
- Assert.AreEqual(6d, result);
- }
-
- [TestMethod]
- public void ShouldDivideIntegersCorrectly()
- {
- var result = _parser.Parse("8 / 4");
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void ShouldDivideDecimalWithIntegerCorrectly()
- {
- var result = _parser.Parse("2.5/2");
- Assert.AreEqual(1.25d, result);
- }
-
- [TestMethod]
- public void ShouldHandleExpCorrectly()
- {
- var result = _parser.Parse("2 ^ 4");
- Assert.AreEqual(16d, result);
- }
-
- [TestMethod]
- public void ShouldHandleExpWithDecimalCorrectly()
- {
- var result = _parser.Parse("2.5 ^ 2");
- Assert.AreEqual(6.25d, result);
- }
-
- [TestMethod]
- public void ShouldMultiplyDecimalWithDecimalCorrectly()
- {
- var result = _parser.Parse("2.5 * 1.5");
- Assert.AreEqual(3.75d, result);
- }
-
- [TestMethod]
- public void ThreeGreaterThanTwoShouldBeTrue()
- {
- var result = _parser.Parse("3 > 2");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void ThreeLessThanTwoShouldBeFalse()
- {
- var result = _parser.Parse("3 < 2");
- Assert.IsFalse((bool)result);
- }
-
- [TestMethod]
- public void ThreeLessThanOrEqualToThreeShouldBeTrue()
- {
- var result = _parser.Parse("3 <= 3");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void ThreeLessThanOrEqualToTwoDotThreeShouldBeFalse()
- {
- var result = _parser.Parse("3 <= 2.3");
- Assert.IsFalse((bool)result);
- }
-
- [TestMethod]
- public void ThreeGreaterThanOrEqualToThreeShouldBeTrue()
- {
- var result = _parser.Parse("3 >= 3");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void TwoDotTwoGreaterThanOrEqualToThreeShouldBeFalse()
- {
- var result = _parser.Parse("2.2 >= 3");
- Assert.IsFalse((bool)result);
- }
-
- [TestMethod]
- public void TwelveAndTwelveShouldBeEqual()
- {
- var result = _parser.Parse("2=2");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void TenPercentShouldBe0Point1()
- {
- var result = _parser.Parse("10%");
- Assert.AreEqual(0.1, result);
- }
-
- [TestMethod]
- public void ShouldHandleMultiplePercentSigns()
- {
- var result = _parser.Parse("10%%");
- Assert.AreEqual(0.001, result);
- }
-
- [TestMethod]
- public void ShouldHandlePercentageOnFunctionResult()
- {
- var result = _parser.Parse("SUM(1;2;3)%");
- Assert.AreEqual(0.06, result);
- }
-
- [TestMethod]
- public void ShouldHandlePercentageOnParantethis()
- {
- var result = _parser.Parse("(1+2)%");
- Assert.AreEqual(0.03, result);
- }
-
- [TestMethod]
- public void ShouldIgnoreLeadingPlus()
- {
- var result = _parser.Parse("+(1-2)");
- Assert.AreEqual(-1d, result);
- }
-
- [TestMethod]
- public void ShouldHandleDecimalNumberWhenDividingIntegers()
- {
- var result = _parser.Parse("224567455/400000000*500000");
- Assert.AreEqual(280709.31875, result);
- }
-
- [TestMethod]
- public void ShouldNegateExpressionInParenthesis()
- {
- var result = _parser.Parse("-(1+2)");
- Assert.AreEqual(-3d, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/DatabaseTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/DatabaseTests.cs
deleted file mode 100644
index d46a771..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/DatabaseTests.cs
+++ /dev/null
@@ -1,296 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class DatabaseTests
- {
- [TestMethod]
- public void DgetShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
- sheet.Cells["C1"].Value = "crit3";
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
- sheet.Cells["C2"].Value = "output";
- sheet.Cells["A3"].Value = "test";
- sheet.Cells["B3"].Value = 3;
- sheet.Cells["C3"].Value = "aaa";
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
- sheet.Cells["E1"].Value = "crit2";
- sheet.Cells["E2"].Value = 2;
- // function
- sheet.Cells["F1"].Formula = "DGET(A1:C3,\"Crit3\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual("output", sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DcountShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
- sheet.Cells["C1"].Value = "crit3";
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
- sheet.Cells["C2"].Value = "output";
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = "2";
- sheet.Cells["C3"].Value = "aaa";
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
- sheet.Cells["E1"].Value = "crit2";
- sheet.Cells["E2"].Value = 2;
- // function
- sheet.Cells["F1"].Formula = "DCOUNT(A1:C3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(1, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DcountaShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
- sheet.Cells["C1"].Value = "crit3";
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
- sheet.Cells["C2"].Value = "output";
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = "2";
- sheet.Cells["C3"].Value = "aaa";
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
- sheet.Cells["E1"].Value = "crit2";
- sheet.Cells["E2"].Value = 2;
- // function
- sheet.Cells["F1"].Formula = "DCOUNTA(A1:C3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(2, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DMaxShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DMAX(A1:B3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(2d, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DMinShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DMIN(A1:B3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(1d, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DSumShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DSUM(A1:B3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(3d, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DAverageShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DAVERAGE(A1:B3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(1.5d, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DVarShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DVAR(A1:B3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(0.5d, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DVarpShouldReturnCorrectResult()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DVARP(A1:B3,\"Crit2\",D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(0.25d, sheet.Cells["F1"].Value);
- }
- }
-
- [TestMethod]
- public void DVarpShouldReturnByFieldIndex()
- {
- using (var package = new ExcelPackage())
- {
- var sheet = package.Workbook.Worksheets.Add("test");
- // database
- sheet.Cells["A1"].Value = "crit1";
- sheet.Cells["B1"].Value = "crit2";
-
- sheet.Cells["A2"].Value = "test";
- sheet.Cells["B2"].Value = 2;
-
- sheet.Cells["A3"].Value = "tesst";
- sheet.Cells["B3"].Value = 1;
- // criteria
- sheet.Cells["D1"].Value = "crit1";
- sheet.Cells["D2"].Value = "t*t";
-
- // function
- sheet.Cells["F1"].Formula = "DVARP(A1:B3,2,D1:E2)";
-
- sheet.Workbook.Calculate();
-
- Assert.AreEqual(0.25d, sheet.Cells["F1"].Value);
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/DateAndTimeFunctionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/DateAndTimeFunctionsTests.cs
deleted file mode 100644
index 28a64c4..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/DateAndTimeFunctionsTests.cs
+++ /dev/null
@@ -1,218 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using Rhino.Mocks;
-using System.IO;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class DateAndTimeFunctionsTests : FormulaParserTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(excelDataProvider);
- }
-
- [TestMethod]
- public void DateShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Date(2012, 2, 2)");
- Assert.AreEqual(new DateTime(2012, 2, 2).ToOADate(), result);
- }
-
- [TestMethod]
- public void DateShouldHandleCellReference()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = 2012d;
- sheet.Cells["A2"].Formula = "Date(A1, 2, 2)";
- sheet.Calculate();
- var result = sheet.Cells["A2"].Value;
- Assert.AreEqual(new DateTime(2012, 2, 2).ToOADate(), result);
- }
-
- }
-
- [TestMethod]
- public void TodayShouldReturnAResult()
- {
- var result = _parser.Parse("Today()");
- Assert.IsInstanceOfType(DateTime.FromOADate((double)result), typeof(DateTime));
- }
-
- [TestMethod]
- public void NowShouldReturnAResult()
- {
- var result = _parser.Parse("now()");
- Assert.IsInstanceOfType(DateTime.FromOADate((double)result), typeof(DateTime));
- }
-
- [TestMethod]
- public void DayShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Day(Date(2012, 4, 2))");
- Assert.AreEqual(2, result);
- }
-
- [TestMethod]
- public void MonthShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Month(Date(2012, 4, 2))");
- Assert.AreEqual(4, result);
- }
-
- [TestMethod]
- public void YearShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Year(Date(2012, 2, 2))");
- Assert.AreEqual(2012, result);
- }
-
- [TestMethod]
- public void TimeShouldReturnCorrectResult()
- {
- var expectedResult = ((double)(12 * 60 * 60 + 13 * 60 + 14))/((double)(24 * 60 * 60));
- var result = _parser.Parse("Time(12, 13, 14)");
- Assert.AreEqual(expectedResult, result);
- }
-
- [TestMethod]
- public void HourShouldReturnCorrectResult()
- {
- var result = _parser.Parse("HOUR(Time(12, 13, 14))");
- Assert.AreEqual(12, result);
- }
-
- [TestMethod]
- public void MinuteShouldReturnCorrectResult()
- {
- var result = _parser.Parse("minute(Time(12, 13, 14))");
- Assert.AreEqual(13, result);
- }
-
- [TestMethod]
- public void SecondShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Second(Time(12, 13, 59))");
- Assert.AreEqual(59, result);
- }
-
- [TestMethod]
- public void SecondShouldReturnCorrectResultWhenParsingString()
- {
- var result = _parser.Parse("Second(\"10:12:14\")");
- Assert.AreEqual(14, result);
- }
-
- [TestMethod]
- public void MinuteShouldReturnCorrectResultWhenParsingString()
- {
- var result = _parser.Parse("Minute(\"10:12:14 AM\")");
- Assert.AreEqual(12, result);
- }
-
- [TestMethod]
- public void HourShouldReturnCorrectResultWhenParsingString()
- {
- var result = _parser.Parse("Hour(\"10:12:14\")");
- Assert.AreEqual(10, result);
- }
-
- [TestMethod]
- public void Day360ShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Days360(Date(2012, 4, 2), Date(2012, 5, 2))");
- Assert.AreEqual(30, result);
- }
-
- [TestMethod]
- public void YearfracShouldReturnAResult()
- {
- var result = _parser.Parse("Yearfrac(Date(2012, 4, 2), Date(2012, 5, 2))");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void IsoWeekNumShouldReturnAResult()
- {
- var result = _parser.Parse("IsoWeekNum(Date(2012, 4, 2))");
- Assert.IsInstanceOfType(result, typeof(int));
- }
-
- [TestMethod]
- public void EomonthShouldReturnAResult()
- {
- var result = _parser.Parse("Eomonth(Date(2013, 2, 2), 3)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void WorkdayShouldReturnAResult()
- {
- var result = _parser.Parse("Workday(Date(2013, 2, 2), 3)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void DateNotEqualToStringShouldBeTrue()
- {
- var result = _parser.Parse("TODAY() <> \"\"");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void Calculation5()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
- ws.Cells["A1"].Value = "John";
- ws.Cells["B1"].Value = "Doe";
- ws.Cells["C1"].Formula = "B1&\", \"&A1";
- ws.Calculate();
- Assert.AreEqual("Doe, John", ws.Cells["C1"].Value);
- }
-
- [TestMethod]
- public void HourWithExcelReference()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
- ws.Cells["A1"].Value = new DateTime(2014, 1, 1, 10, 11, 12).ToOADate();
- ws.Cells["B1"].Formula = "HOUR(A1)";
- ws.Calculate();
- Assert.AreEqual(10, ws.Cells["B1"].Value);
- }
-
- [TestMethod]
- public void MinuteWithExcelReference()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
- ws.Cells["A1"].Value = new DateTime(2014, 1, 1, 10, 11, 12).ToOADate();
- ws.Cells["B1"].Formula = "MINUTE(A1)";
- ws.Calculate();
- Assert.AreEqual(11, ws.Cells["B1"].Value);
- }
-
- [TestMethod]
- public void SecondWithExcelReference()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
- ws.Cells["A1"].Value = new DateTime(2014, 1, 1, 10, 11, 12).ToOADate();
- ws.Cells["B1"].Formula = "SECOND(A1)";
- ws.Calculate();
- Assert.AreEqual(12, ws.Cells["B1"].Value);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/MathExcelRangeTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/MathExcelRangeTests.cs
deleted file mode 100644
index f3f2c9c..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/MathExcelRangeTests.cs
+++ /dev/null
@@ -1,232 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions.ExcelRanges
-{
- [TestClass]
- public class MathExcelRangeTests
- {
- private ExcelPackage _package;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _worksheet = _package.Workbook.Worksheets.Add("Test");
-
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 3;
- _worksheet.Cells["A3"].Value = 6;
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void AbsShouldReturn3()
- {
- _worksheet.Cells["A4"].Formula = "ABS(A2)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void CountShouldReturn3()
- {
- _worksheet.Cells["A4"].Formula = "COUNT(A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void CountShouldReturn2IfACellValueIsNull()
- {
- _worksheet.Cells["A2"].Value = null;
- _worksheet.Cells["A4"].Formula = "COUNT(A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void CountAShouldReturn3()
- {
- _worksheet.Cells["A4"].Formula = "COUNTA(A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void CountIfShouldReturnCorrectResult()
- {
- _worksheet.Cells["A4"].Formula = "COUNTIF(A1:A3, \">2\")";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void MaxShouldReturn6()
- {
- _worksheet.Cells["A4"].Formula = "Max(A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(6d, result);
- }
-
- [TestMethod]
- public void MinShouldReturn1()
- {
- _worksheet.Cells["A4"].Formula = "Min(A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void AverageShouldReturn3Point333333()
- {
- _worksheet.Cells["A4"].Formula = "Average(A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(3d + (1d/3d), result);
- }
-
- [TestMethod]
- public void AverageIfShouldHandleSingleRangeNumericExpressionMatch()
- {
- _worksheet.Cells["A4"].Value = "B";
- _worksheet.Cells["A5"].Value = 3;
- _worksheet.Cells["A6"].Formula = "AverageIf(A1:A5,\">1\")";
- _worksheet.Calculate();
- Assert.AreEqual(4d, _worksheet.Cells["A6"].Value);
- }
-
- [TestMethod]
- public void AverageIfShouldHandleSingleRangeStringMatch()
- {
- _worksheet.Cells["A4"].Value = "ABC";
- _worksheet.Cells["A5"].Value = "3";
- _worksheet.Cells["A6"].Formula = "AverageIf(A1:A5,\">1\")";
- _worksheet.Calculate();
- Assert.AreEqual(4.5d, _worksheet.Cells["A6"].Value);
- }
-
- [TestMethod]
- public void AverageIfShouldHandleLookupRangeStringMatch()
- {
- _worksheet.Cells["A1"].Value = "abc";
- _worksheet.Cells["A2"].Value = "abc";
- _worksheet.Cells["A3"].Value = "def";
- _worksheet.Cells["A4"].Value = "def";
- _worksheet.Cells["A5"].Value = "abd";
-
- _worksheet.Cells["B1"].Value = 1;
- _worksheet.Cells["B2"].Value = 3;
- _worksheet.Cells["B3"].Value = 5;
- _worksheet.Cells["B4"].Value = 6;
- _worksheet.Cells["B5"].Value = 7;
-
- _worksheet.Cells["A6"].Formula = "AverageIf(A1:A5,\"abc\",B1:B5)";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A6"].Value);
- }
-
- [TestMethod]
- public void AverageIfShouldHandleLookupRangeStringNumericMatch()
- {
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 3;
- _worksheet.Cells["A3"].Value = 3;
- _worksheet.Cells["A4"].Value = 5;
- _worksheet.Cells["A5"].Value = 2;
-
- _worksheet.Cells["B1"].Value = 3;
- _worksheet.Cells["B2"].Value = 3;
- _worksheet.Cells["B3"].Value = 2;
- _worksheet.Cells["B4"].Value = 1;
- _worksheet.Cells["B5"].Value = 8;
-
- _worksheet.Cells["A6"].Formula = "AverageIf(A1:A5,\">2\",B1:B5)";
- _worksheet.Calculate();
- Assert.AreEqual(2d, _worksheet.Cells["A6"].Value);
- }
-
- [TestMethod]
- public void AverageIfShouldHandleLookupRangeStringWildCardMatch()
- {
- _worksheet.Cells["A1"].Value = "abc";
- _worksheet.Cells["A2"].Value = "abc";
- _worksheet.Cells["A3"].Value = "def";
- _worksheet.Cells["A4"].Value = "def";
- _worksheet.Cells["A5"].Value = "abd";
-
- _worksheet.Cells["B1"].Value = 1;
- _worksheet.Cells["B2"].Value = 3;
- _worksheet.Cells["B3"].Value = 5;
- _worksheet.Cells["B4"].Value = 6;
- _worksheet.Cells["B5"].Value = 8;
-
- _worksheet.Cells["A6"].Formula = "AverageIf(A1:A5, \"ab*\",B1:B5)";
- _worksheet.Calculate();
- Assert.AreEqual(4d, _worksheet.Cells["A6"].Value);
- }
-
- [TestMethod]
- public void SumProductWithRange()
- {
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 2;
- _worksheet.Cells["A3"].Value = 3;
- _worksheet.Cells["B1"].Value = 5;
- _worksheet.Cells["B2"].Value = 6;
- _worksheet.Cells["B3"].Value = 4;
- _worksheet.Cells["A4"].Formula = "SUMPRODUCT(A1:A3,B1:B3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(29d, result);
- }
-
- [TestMethod]
- public void SumProductWithRangeAndValues()
- {
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 2;
- _worksheet.Cells["A3"].Value = 3;
- _worksheet.Cells["B1"].Value = 5;
- _worksheet.Cells["B2"].Value = 6;
- _worksheet.Cells["B3"].Value = 4;
- _worksheet.Cells["A4"].Formula = "SUMPRODUCT(A1:A3,B1:B3,{2,4,1})";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(70d, result);
- }
-
- [TestMethod]
- public void SignShouldReturn1WhenRefIsPositive()
- {
- _worksheet.Cells["A4"].Formula = "SIGN(A1)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void SubTotalShouldNotIncludeHiddenRow()
- {
- _worksheet.Row(2).Hidden = true;
- _worksheet.Cells["A4"].Formula = "SUBTOTAL(109,A1:A3)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(7d, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/TextExcelRangeTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/TextExcelRangeTests.cs
deleted file mode 100644
index 0c2e5b6..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/TextExcelRangeTests.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions.ExcelRanges
-{
- [TestClass]
- public class TextExcelRangeTests
- {
- private ExcelPackage _package;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _worksheet = _package.Workbook.Worksheets.Add("Test");
-
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["A2"].Value = 3;
- _worksheet.Cells["A3"].Value = 6;
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void ExactShouldReturnTrueWhenEqualValues()
- {
- _worksheet.Cells["A2"].Value = 1d;
- _worksheet.Cells["A4"].Formula = "EXACT(A1,A2)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void FindShouldReturnIndex()
- {
- _worksheet.Cells["A1"].Value = "hopp";
- _worksheet.Cells["A2"].Value = "hej hopp";
- _worksheet.Cells["A4"].Formula = "Find(A1,A2)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A4"].Value;
- Assert.AreEqual(5, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/WorksheetRefsTest.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/WorksheetRefsTest.cs
deleted file mode 100644
index 7a7a049..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/ExcelRanges/WorksheetRefsTest.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions.ExcelRanges
-{
- [TestClass]
- public class WorksheetRefsTest
- {
- private ExcelPackage _package;
- private ExcelWorksheet _firstSheet;
- private ExcelWorksheet _secondSheet;
-
- [TestInitialize]
- public void Init()
- {
- _package = new ExcelPackage();
- _firstSheet = _package.Workbook.Worksheets.Add("sheet1");
- _secondSheet = _package.Workbook.Worksheets.Add("sheet2");
- _firstSheet.Cells["A1"].Value = 1;
- _firstSheet.Cells["A2"].Value = 2;
- }
-
- [TestCleanup]
- public void Cleanup()
- {
-
- _package.Dispose();
- }
-
- [TestMethod]
- public void ShouldHandleReferenceToOtherSheet()
- {
- _secondSheet.Cells["A1"].Formula = "SUM('sheet1'!A1:A2)";
- _secondSheet.Calculate();
- Assert.AreEqual(3d, _secondSheet.Cells["A1"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleReferenceToOtherSheetWithComplexName()
- {
- var sheet = _package.Workbook.Worksheets.Add("ab#k..2");
- sheet.Cells["A1"].Value = 1;
- sheet.Cells["A2"].Value = 2;
- _secondSheet.Cells["A1"].Formula = "SUM('ab#k..2'A1:A2)";
- _secondSheet.Calculate();
- Assert.AreEqual(3d, _secondSheet.Cells["A1"].Value);
- }
-
- [TestMethod]
- public void ShouldHandleInvalidRef()
- {
- var sheet = _package.Workbook.Worksheets.Add("ab#k..2");
- sheet.Cells["A1"].Value = 1;
- sheet.Cells["A2"].Value = 2;
- _secondSheet.Cells["A1"].Formula = "SUM('ab#k..2A1:A2')";
- _secondSheet.Calculate();
- Assert.IsInstanceOfType(_secondSheet.Cells["A1"].Value, typeof(ExcelErrorValue));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/InformationFunctionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/InformationFunctionsTests.cs
deleted file mode 100644
index bf5281f..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/InformationFunctionsTests.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class InformationFunctionsTests : FormulaParserTestBase
- {
- private ExcelDataProvider _excelDataProvider;
-
- [TestInitialize]
- public void Setup()
- {
- _excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(_excelDataProvider);
- }
-
- [TestMethod]
- public void IsBlankShouldReturnCorrectValue()
- {
- var result = _parser.Parse("ISBLANK(A1)");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void IsNumberShouldReturnCorrectValue()
- {
- var result = _parser.Parse("ISNUMBER(10/2)");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void IsErrorShouldReturnTrueWhenDivBy0()
- {
- var result = _parser.Parse("ISERROR(10/0)");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void IsTextShouldReturnTrueWhenReferencedCellContainsText()
- {
- using(var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("Test");
- sheet.Cells["A1"].Value = "Abc";
- sheet.Cells["A2"].Formula = "ISTEXT(A1)";
- sheet.Calculate();
- var result = sheet.Cells["A2"].Value;
- Assert.IsTrue((bool)result);
- }
- }
-
- [TestMethod]
- public void IsErrShouldReturnFalseIfErrorCodeIsNa()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("Test");
- sheet.Cells["A1"].Value = ExcelErrorValue.Parse("#N/A");
- sheet.Cells["A2"].Formula = "ISERR(A1)";
- sheet.Calculate();
- var result = sheet.Cells["A2"].Value;
- Assert.IsFalse((bool)result);
- }
- }
-
- [TestMethod]
- public void IsNaShouldReturnTrueCodeIsNa()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("Test");
- sheet.Cells["A1"].Value = ExcelErrorValue.Parse("#N/A");
- sheet.Cells["A2"].Formula = "ISNA(A1)";
- sheet.Calculate();
- var result = sheet.Cells["A2"].Value;
- Assert.IsTrue((bool)result);
- }
- }
-
- [TestMethod]
- public void ErrorTypeShouldReturnCorrectErrorCodes()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("Test");
- sheet.Cells["A1"].Value = ExcelErrorValue.Create(eErrorType.Null);
- sheet.Cells["B1"].Formula = "ERROR.TYPE(A1)";
- sheet.Cells["A2"].Value = ExcelErrorValue.Create(eErrorType.Div0);
- sheet.Cells["B2"].Formula = "ERROR.TYPE(A2)";
- sheet.Cells["A3"].Value = ExcelErrorValue.Create(eErrorType.Value);
- sheet.Cells["B3"].Formula = "ERROR.TYPE(A3)";
- sheet.Cells["A4"].Value = ExcelErrorValue.Create(eErrorType.Ref);
- sheet.Cells["B4"].Formula = "ERROR.TYPE(A4)";
- sheet.Cells["A5"].Value = ExcelErrorValue.Create(eErrorType.Name);
- sheet.Cells["B5"].Formula = "ERROR.TYPE(A5)";
- sheet.Cells["A6"].Value = ExcelErrorValue.Create(eErrorType.Num);
- sheet.Cells["B6"].Formula = "ERROR.TYPE(A6)";
- sheet.Cells["A7"].Value = ExcelErrorValue.Create(eErrorType.NA);
- sheet.Cells["B7"].Formula = "ERROR.TYPE(A7)";
- sheet.Cells["A8"].Value = 10;
- sheet.Cells["B8"].Formula = "ERROR.TYPE(A8)";
- sheet.Calculate();
- var nullResult = sheet.Cells["B1"].Value;
- var div0Result = sheet.Cells["B2"].Value;
- var valueResult = sheet.Cells["B3"].Value;
- var refResult = sheet.Cells["B4"].Value;
- var nameResult = sheet.Cells["B5"].Value;
- var numResult = sheet.Cells["B6"].Value;
- var naResult = sheet.Cells["B7"].Value;
- var noErrorResult = sheet.Cells["B8"].Value;
- Assert.AreEqual(1, nullResult, "Null error was not 1");
- Assert.AreEqual(2, div0Result, "Div0 error was not 2");
- Assert.AreEqual(3, valueResult, "Value error was not 3");
- Assert.AreEqual(4, refResult, "Ref error was not 4");
- Assert.AreEqual(5, nameResult, "Name error was not 5");
- Assert.AreEqual(6, numResult, "Num error was not 6");
- Assert.AreEqual(7, naResult, "NA error was not 7");
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.NA), noErrorResult, "No error did not return N/A error");
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/LogicalFunctionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/LogicalFunctionsTests.cs
deleted file mode 100644
index 5364365..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/LogicalFunctionsTests.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class LogicalFunctionsTests : FormulaParserTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(excelDataProvider);
- }
-
- [TestMethod]
- public void IfShouldReturnCorrectResult()
- {
- var result = _parser.Parse("If(2 < 3, 1, 2)");
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void IIfShouldReturnCorrectResultWhenInnerFunctionExists()
- {
- var result = _parser.Parse("If(NOT(Or(true, FALSE)), 1, 2)");
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void NotShouldReturnCorrectResult()
- {
- var result = _parser.Parse("not(true)");
- Assert.IsFalse((bool)result);
-
- result = _parser.Parse("NOT(false)");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void AndShouldReturnCorrectResult()
- {
- var result = _parser.Parse("And(true, 1)");
- Assert.IsTrue((bool)result);
-
- result = _parser.Parse("AND(true, true, 1, false)");
- Assert.IsFalse((bool)result);
- }
-
- [TestMethod]
- public void OrShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Or(FALSE, 0)");
- Assert.IsFalse((bool)result);
-
- result = _parser.Parse("OR(true, true, 1, false)");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void TrueShouldReturnCorrectResult()
- {
- var result = _parser.Parse("True()");
- Assert.IsTrue((bool)result);
- }
-
- [TestMethod]
- public void FalseShouldReturnCorrectResult()
- {
- var result = _parser.Parse("False()");
- Assert.IsFalse((bool)result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/MathFunctionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/MathFunctionsTests.cs
deleted file mode 100644
index ca2faaa..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/MathFunctionsTests.cs
+++ /dev/null
@@ -1,439 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class MathFunctionsTests : FormulaParserTestBase
- {
- [TestInitialize]
- public void Setup()
- {
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(excelDataProvider);
- }
-
- [TestMethod]
- public void PowerShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Power(3, 3)");
- Assert.AreEqual(27d, result);
- }
-
- [TestMethod]
- public void SqrtShouldReturnCorrectResult()
- {
- var result = _parser.Parse("sqrt(9)");
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void PiShouldReturnCorrectResult()
- {
- var expectedValue = (double)Math.Round(Math.PI, 14);
- var result = _parser.Parse("Pi()");
- Assert.AreEqual(expectedValue, result);
- }
-
- [TestMethod]
- public void CeilingShouldReturnCorrectResult()
- {
- var expectedValue = 22.4d;
- var result = _parser.Parse("ceiling(22.35, 0.1)");
- Assert.AreEqual(expectedValue, result);
- }
-
- [TestMethod]
- public void FloorShouldReturnCorrectResult()
- {
- var expectedValue = 22.3d;
- var result = _parser.Parse("Floor(22.35, 0.1)");
- Assert.AreEqual(expectedValue, result);
- }
-
- [TestMethod]
- public void SumShouldReturnCorrectResultWithInts()
- {
- var result = _parser.Parse("sum(1, 2)");
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void SumShouldReturnCorrectResultWithDecimals()
- {
- var result = _parser.Parse("sum(1,2.5)");
- Assert.AreEqual(3.5d, result);
- }
-
- [TestMethod]
- public void SumShouldReturnCorrectResultWithEnumerable()
- {
- var result = _parser.Parse("sum({1;2;3;-1}, 2.5)");
- Assert.AreEqual(7.5d, result);
- }
-
- [TestMethod]
- public void SumsqShouldReturnCorrectResultWithEnumerable()
- {
- var result = _parser.Parse("sumsq({2;3})");
- Assert.AreEqual(13d, result);
- }
-
- [TestMethod]
- public void SumIfShouldReturnCorrectResult()
- {
- var result = _parser.Parse("sumIf({1;2;3;2}, 2)");
- Assert.AreEqual(4d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNegateExpression()
- {
- var result = _parser.Parse("-subtotal(2;{1;2})");
- Assert.AreEqual(-2d, result);
- }
-
- [TestMethod]
- public void StdevShouldReturnAResult()
- {
- var result = _parser.Parse("stdev(1;2;3;4)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void StdevPShouldReturnAResult()
- {
- var result = _parser.Parse("stdevp(2,3,4)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void ExpShouldReturnAResult()
- {
- var result = _parser.Parse("exp(4)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void MaxShouldReturnAResult()
- {
- var result = _parser.Parse("Max(4, 5)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void MaxaShouldReturnAResult()
- {
- var result = _parser.Parse("Maxa(4, 5)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void MinShouldReturnAResult()
- {
- var result = _parser.Parse("min(4, 5)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void MinaShouldCalculateStringAs0()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = 1;
- sheet.Cells["B2"].Value = "a";
- sheet.Cells["A5"].Formula = "MINA(A1:B4)";
- sheet.Calculate();
- Assert.AreEqual(0d, sheet.Cells["A5"].Value);
- }
- }
-
- [TestMethod]
- public void AverageShouldReturnAResult()
- {
- var result = _parser.Parse("Average(2, 2, 2)");
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void AverageShouldReturnDiv0IfEmptyCell()
- {
- using(var pck = new ExcelPackage())
- {
- var ws = pck.Workbook.Worksheets.Add("test");
- ws.Cells["A2"].Formula = "AVERAGE(A1)";
- ws.Calculate();
- Assert.AreEqual("#DIV/0!", ws.Cells["A2"].Value.ToString());
- }
- }
-
- [TestMethod]
- public void RoundShouldReturnAResult()
- {
- var result = _parser.Parse("Round(2.2, 0)");
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void RounddownShouldReturnAResult()
- {
- var result = _parser.Parse("Rounddown(2.99, 1)");
- Assert.AreEqual(2.9d, result);
- }
-
- [TestMethod]
- public void RoundupShouldReturnAResult()
- {
- var result = _parser.Parse("Roundup(2.99, 1)");
- Assert.AreEqual(3d, result);
- }
-
- [TestMethod]
- public void SqrtPiShouldReturnAResult()
- {
- var result = _parser.Parse("SqrtPi(2.2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void IntShouldReturnAResult()
- {
- var result = _parser.Parse("Int(2.9)");
- Assert.AreEqual(2, result);
- }
-
- [TestMethod]
- public void RandShouldReturnAResult()
- {
- var result = _parser.Parse("Rand()");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void RandBetweenShouldReturnAResult()
- {
- var result = _parser.Parse("RandBetween(1,2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void CountShouldReturnAResult()
- {
- var result = _parser.Parse("Count(1,2,2,\"4\")");
- Assert.AreEqual(4d, result);
- }
-
- [TestMethod]
- public void CountAShouldReturnAResult()
- {
- var result = _parser.Parse("CountA(1,2,2,\"\", \"a\")");
- Assert.AreEqual(4d, result);
- }
-
- [TestMethod]
- public void CountIfShouldReturnAResult()
- {
- var result = _parser.Parse("CountIf({1;2;2;\"\"}, \"2\")");
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void VarShouldReturnAResult()
- {
- var result = _parser.Parse("Var(1,2,3)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void VarPShouldReturnAResult()
- {
- var result = _parser.Parse("VarP(1,2,3)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void ModShouldReturnAResult()
- {
- var result = _parser.Parse("Mod(5,2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void SubtotalShouldReturnAResult()
- {
- var result = _parser.Parse("Subtotal(1, 10, 20)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void TruncShouldReturnAResult()
- {
- var result = _parser.Parse("Trunc(1.2345)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void ProductShouldReturnAResult()
- {
- var result = _parser.Parse("Product(1,2,3)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void CosShouldReturnAResult()
- {
- var result = _parser.Parse("Cos(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void CoshShouldReturnAResult()
- {
- var result = _parser.Parse("Cosh(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void SinShouldReturnAResult()
- {
- var result = _parser.Parse("Sin(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void SinhShouldReturnAResult()
- {
- var result = _parser.Parse("Sinh(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void TanShouldReturnAResult()
- {
- var result = _parser.Parse("Tan(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void AtanShouldReturnAResult()
- {
- var result = _parser.Parse("Atan(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void Atan2ShouldReturnAResult()
- {
- var result = _parser.Parse("Atan2(2,1)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void TanhShouldReturnAResult()
- {
- var result = _parser.Parse("Tanh(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void LogShouldReturnAResult()
- {
- var result = _parser.Parse("Log(2, 2)");
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void Log10ShouldReturnAResult()
- {
- var result = _parser.Parse("Log10(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void LnShouldReturnAResult()
- {
- var result = _parser.Parse("Ln(2)");
- Assert.IsInstanceOfType(result, typeof(double));
- }
-
- [TestMethod]
- public void FactShouldReturnAResult()
- {
- var result = _parser.Parse("Fact(0)");
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void QuotientShouldReturnAResult()
- {
- var result = _parser.Parse("Quotient(5;2)");
- Assert.AreEqual(2, result);
- }
-
- [TestMethod]
- public void MedianShouldReturnAResult()
- {
- var result = _parser.Parse("Median(1;2;3)");
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void CountBlankShouldCalculateEmptyCells()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Value = 1;
- sheet.Cells["B2"].Value = string.Empty;
- sheet.Cells["A5"].Formula = "COUNTBLANK(A1:B4)";
- sheet.Calculate();
- Assert.AreEqual(7, sheet.Cells["A5"].Value);
- }
- }
-
- [TestMethod]
- public void DegreesShouldReturnCorrectResult()
- {
- var result = _parser.Parse("DEGREES(0.5)");
- var rounded = Math.Round((double)result, 3);
- Assert.AreEqual(28.648, rounded);
- }
-
- [TestMethod]
- public void AverateIfsShouldCaluclateResult()
- {
- using (var pck = new ExcelPackage())
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["F4"].Value = 1;
- sheet.Cells["F5"].Value = 2;
- sheet.Cells["F6"].Formula = "2 + 2";
- sheet.Cells["F7"].Value = 4;
- sheet.Cells["F8"].Value = 5;
-
- sheet.Cells["H4"].Value = 3;
- sheet.Cells["H5"].Value = 3;
- sheet.Cells["H6"].Formula = "2 + 2";
- sheet.Cells["H7"].Value = 4;
- sheet.Cells["H8"].Value = 5;
-
- sheet.Cells["I4"].Value = 2;
- sheet.Cells["I5"].Value = 3;
- sheet.Cells["I6"].Formula = "2 + 2";
- sheet.Cells["I7"].Value = 5;
- sheet.Cells["I8"].Value = 1;
-
- sheet.Cells["H9"].Formula = "AVERAGEIFS(F4:F8;H4:H8;\">3\";I4:I8;\"<5\")";
- sheet.Calculate();
- Assert.AreEqual(4.5d, sheet.Cells["H9"].Value);
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/RefAndLookupTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/RefAndLookupTests.cs
deleted file mode 100644
index 800bac1..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/RefAndLookupTests.cs
+++ /dev/null
@@ -1,318 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class RefAndLookupTests : FormulaParserTestBase
- {
- private ExcelDataProvider _excelDataProvider;
- const string WorksheetName = null;
- private ExcelPackage _package;
- private ExcelWorksheet _worksheet;
-
- [TestInitialize]
- public void Initialize()
- {
- _excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _excelDataProvider.Stub(x => x.GetDimensionEnd(Arg<string>.Is.Anything)).Return(new ExcelCellAddress(10, 1));
- _parser = new FormulaParser(_excelDataProvider);
- _package = new ExcelPackage();
- _worksheet = _package.Workbook.Worksheets.Add("Test");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void VLookupShouldReturnCorrespondingValue()
- {
- using(var pck = new ExcelPackage())
- {
- var ws = pck.Workbook.Worksheets.Add("test");
- var lookupAddress = "A1:B2";
- ws.Cells["A1"].Value = 1;
- ws.Cells["B1"].Value = 1;
- ws.Cells["A2"].Value = 2;
- ws.Cells["B2"].Value = 5;
- ws.Cells["A3"].Formula = "VLOOKUP(2, " + lookupAddress + ", 2)";
- ws.Calculate();
- var result = ws.Cells["A3"].Value;
- Assert.AreEqual(5, result);
- }
- }
-
- [TestMethod]
- public void VLookupShouldReturnClosestValueBelowIfLastArgIsTrue()
- {
- using (var pck = new ExcelPackage())
- {
- var ws = pck.Workbook.Worksheets.Add("test");
- var lookupAddress = "A1:B2";
- ws.Cells["A1"].Value = 3;
- ws.Cells["B1"].Value = 1;
- ws.Cells["A2"].Value = 5;
- ws.Cells["B2"].Value = 5;
- ws.Cells["A3"].Formula = "VLOOKUP(4, " + lookupAddress + ", 2, true)";
- ws.Calculate();
- var result = ws.Cells["A3"].Value;
- Assert.AreEqual(1, result);
- }
- }
-
- [TestMethod]
- public void HLookupShouldReturnCorrespondingValue()
- {
- var lookupAddress = "A1:B2";
- _worksheet.Cells["A1"].Value = 1;
- _worksheet.Cells["B1"].Value = 2;
- _worksheet.Cells["A2"].Value = 2;
- _worksheet.Cells["B2"].Value = 5;
- _worksheet.Cells["A3"].Formula = "HLOOKUP(2, " + lookupAddress + ", 2)";
- _worksheet.Calculate();
- var result = _worksheet.Cells["A3"].Value;
- Assert.AreEqual(5, result);
- }
-
- [TestMethod]
- public void HLookupShouldReturnClosestValueBelowIfLastArgIsTrue()
- {
- var lookupAddress = "A1:B2";
- _excelDataProvider.Stub(x => x.GetDimensionEnd(Arg<string>.Is.Anything)).Return(new ExcelCellAddress(5, 5));
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(5);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(1);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,2, 2)).Return(2);
- var result = _parser.Parse("HLOOKUP(4, " + lookupAddress + ", 2, true)");
- Assert.AreEqual(1, result);
- }
-
- [TestMethod]
- public void LookupShouldReturnMatchingValue()
- {
- var lookupAddress = "A1:B2";
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(5);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,2, 1)).Return(4);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,2, 2)).Return(1);
- var result = _parser.Parse("LOOKUP(4, " + lookupAddress + ")");
- Assert.AreEqual(1, result);
- }
-
- [TestMethod]
- public void MatchShouldReturnIndexOfMatchingValue()
- {
- var lookupAddress = "A1:A2";
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,1, 1)).Return(3);
- _excelDataProvider.Stub(x => x.GetCellValue(WorksheetName,1, 2)).Return(5);
- var result = _parser.Parse("MATCH(3, " + lookupAddress + ")");
- Assert.AreEqual(1, result);
- }
-
- [TestMethod]
- public void RowShouldReturnRowNumber()
- {
- _excelDataProvider.Stub(x => x.GetRangeFormula("", 4, 1)).Return("Row()");
- var result = _parser.ParseAt("A4");
- Assert.AreEqual(4, result);
- }
-
- [TestMethod]
- public void RowSholdHandleReference()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "ROW(A4)";
- s1.Calculate();
- Assert.AreEqual(4, s1.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void ColumnShouldReturnRowNumber()
- {
- //_excelDataProvider.Stub(x => x.GetRangeValues("B4")).Return(new List<ExcelCell> { new ExcelCell(null, "Column()", 0, 0) });
- _excelDataProvider.Stub(x => x.GetRangeFormula("", 4, 2)).Return("Column()");
- var result = _parser.ParseAt("B4");
- Assert.AreEqual(2, result);
- }
-
- [TestMethod]
- public void ColumnSholdHandleReference()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("test");
- s1.Cells["A1"].Formula = "COLUMN(B4)";
- s1.Calculate();
- Assert.AreEqual(2, s1.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void RowsShouldReturnNbrOfRows()
- {
- _excelDataProvider.Stub(x => x.GetRangeFormula("", 4, 1)).Return("Rows(A5:B7)");
- var result = _parser.ParseAt("A4");
- Assert.AreEqual(3, result);
- }
-
- [TestMethod]
- public void ColumnsShouldReturnNbrOfCols()
- {
- _excelDataProvider.Stub(x => x.GetRangeFormula("", 4, 1)).Return("Columns(A5:B7)");
- var result = _parser.ParseAt("A4");
- Assert.AreEqual(2, result);
- }
-
- [TestMethod]
- public void ChooseShouldReturnCorrectResult()
- {
- var result = _parser.Parse("Choose(1, \"A\", \"B\")");
- Assert.AreEqual("A", result);
- }
-
- [TestMethod]
- public void AddressShouldReturnCorrectResult()
- {
- _excelDataProvider.Stub(x => x.ExcelMaxRows).Return(12345);
- var result = _parser.Parse("Address(1, 1)");
- Assert.AreEqual("$A$1", result);
- }
-
- [TestMethod]
- public void IndirectShouldReturnARange()
- {
- using (var package = new ExcelPackage(new MemoryStream()))
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["A1:A2"].Value = 2;
- s1.Cells["A3"].Formula = "SUM(Indirect(\"A1:A2\"))";
- s1.Calculate();
- Assert.AreEqual(4d, s1.Cells["A3"].Value);
-
- s1.Cells["A4"].Formula = "SUM(Indirect(\"A1:A\" & \"2\"))";
- s1.Calculate();
- Assert.AreEqual(4d, s1.Cells["A4"].Value);
- }
- }
-
- [TestMethod]
- public void OffsetShouldReturnASingleValue()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["B3"].Value = 1d;
- s1.Cells["A5"].Formula = "OFFSET(A1, 2, 1)";
- s1.Calculate();
- Assert.AreEqual(1d, s1.Cells["A5"].Value);
- }
- }
-
- [TestMethod]
- public void OffsetShouldReturnARange()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["B1"].Value = 1d;
- s1.Cells["B2"].Value = 1d;
- s1.Cells["B3"].Value = 1d;
- s1.Cells["A5"].Formula = "SUM(OFFSET(A1:A3, 0, 1))";
- s1.Calculate();
- Assert.AreEqual(3d, s1.Cells["A5"].Value);
- }
- }
-
- [TestMethod]
- public void OffsetDirectReferenceToMultiRangeShouldSetValueError()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["B1"].Value = 1d;
- s1.Cells["B2"].Value = 1d;
- s1.Cells["B3"].Value = 1d;
- s1.Cells["A5"].Formula = "OFFSET(A1:A3, 0, 1)";
- s1.Calculate();
- var result = s1.Cells["A5"].Value;
- Assert.AreEqual(ExcelErrorValue.Create(eErrorType.Value), result);
- }
- }
-
- [TestMethod]
- public void OffsetShouldReturnARangeAccordingToWidth()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["B1"].Value = 1d;
- s1.Cells["B2"].Value = 1d;
- s1.Cells["B3"].Value = 1d;
- s1.Cells["A5"].Formula = "SUM(OFFSET(A1:A3, 0, 1, 2))";
- s1.Calculate();
- Assert.AreEqual(2d, s1.Cells["A5"].Value);
- }
- }
-
- [TestMethod]
- public void OffsetShouldReturnARangeAccordingToHeight()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["B1"].Value = 1d;
- s1.Cells["B2"].Value = 1d;
- s1.Cells["B3"].Value = 1d;
- s1.Cells["C1"].Value = 2d;
- s1.Cells["C2"].Value = 2d;
- s1.Cells["C3"].Value = 2d;
- s1.Cells["A5"].Formula = "SUM(OFFSET(A1:A3, 0, 1, 2, 2))";
- s1.Calculate();
- Assert.AreEqual(6d, s1.Cells["A5"].Value);
- }
- }
-
- [TestMethod]
- public void OffsetShouldCoverMultipleColumns()
- {
- using (var package = new ExcelPackage())
- {
- var s1 = package.Workbook.Worksheets.Add("Test");
- s1.Cells["C1"].Value = 1d;
- s1.Cells["C2"].Value = 1d;
- s1.Cells["C3"].Value = 1d;
- s1.Cells["D1"].Value = 2d;
- s1.Cells["D2"].Value = 2d;
- s1.Cells["D3"].Value = 2d;
- s1.Cells["A5"].Formula = "SUM(OFFSET(A1:B3, 0, 2))";
- s1.Calculate();
- Assert.AreEqual(9d, s1.Cells["A5"].Value);
- }
- }
-
- [TestMethod, Ignore]
- public void VLookupShouldHandleNames()
- {
- using (var package = new ExcelPackage(new FileInfo(@"c:\temp\Book3.xlsx")))
- {
- var s1 = package.Workbook.Worksheets.First();
- var v = s1.Cells["X10"].Formula;
- //s1.Calculate();
- v = s1.Cells["X10"].Formula;
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/StringFunctionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/StringFunctionsTests.cs
deleted file mode 100644
index 3eb547d..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/StringFunctionsTests.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class StringFunctionsTests : FormulaParserTestBase
- {
- private ExcelDataProvider _provider;
- [TestInitialize]
- public void Setup()
- {
- _provider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(_provider);
- }
-
- [TestMethod]
- public void TextShouldConcatenateWithNextExpression()
- {
- _provider.Stub(x => x.GetFormat(23.5, "$0.00")).Return("$23.50");
- var result = _parser.Parse("TEXT(23.5,\"$0.00\") & \" per hour\"");
- Assert.AreEqual("$23.50 per hour", result);
- }
-
- [TestMethod]
- public void LenShouldAddLengthUsingSuppliedOperator()
- {
- var result = _parser.Parse("Len(\"abc\") + 2");
- Assert.AreEqual(5d, result);
- }
-
- [TestMethod]
- public void LowerShouldReturnALowerCaseString()
- {
- var result = _parser.Parse("Lower(\"ABC\")");
- Assert.AreEqual("abc", result);
- }
-
- [TestMethod]
- public void UpperShouldReturnAnUpperCaseString()
- {
- var result = _parser.Parse("Upper(\"abc\")");
- Assert.AreEqual("ABC", result);
- }
-
- [TestMethod]
- public void LeftShouldReturnSubstringFromLeft()
- {
- var result = _parser.Parse("Left(\"abacd\", 2)");
- Assert.AreEqual("ab", result);
- }
-
- [TestMethod]
- public void RightShouldReturnSubstringFromRight()
- {
- var result = _parser.Parse("RIGHT(\"abacd\", 2)");
- Assert.AreEqual("cd", result);
- }
-
- [TestMethod]
- public void MidShouldReturnSubstringAccordingToParams()
- {
- var result = _parser.Parse("Mid(\"abacd\", 2, 2)");
- Assert.AreEqual("ba", result);
- }
-
- [TestMethod]
- public void ReplaceShouldReturnSubstringAccordingToParams()
- {
- var result = _parser.Parse("Replace(\"testar\", 3, 3, \"hej\")");
- Assert.AreEqual("tehejr", result);
- }
-
- [TestMethod]
- public void SubstituteShouldReturnSubstringAccordingToParams()
- {
- var result = _parser.Parse("Substitute(\"testar testar\", \"es\", \"xx\")");
- Assert.AreEqual("txxtar txxtar", result);
- }
-
- [TestMethod]
- public void ConcatenateShouldReturnAccordingToParams()
- {
- var result = _parser.Parse("CONCATENATE(\"One\", \"Two\", \"Three\")");
- Assert.AreEqual("OneTwoThree", result);
- }
-
- [TestMethod]
- public void TShouldReturnText()
- {
- var result = _parser.Parse("T(\"One\")");
- Assert.AreEqual("One", result);
- }
-
- [TestMethod]
- public void ReptShouldConcatenate()
- {
- var result = _parser.Parse("REPT(\"*\",3)");
- Assert.AreEqual("***", result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/SubtotalTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/SubtotalTests.cs
deleted file mode 100644
index c6b8bc7..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/SubtotalTests.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml;
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class SubtotalTests : FormulaParserTestBase
- {
- private ExcelWorksheet _worksheet;
- private ExcelPackage _package;
-
- [TestInitialize]
- public void Setup()
- {
- _package = new ExcelPackage(new MemoryStream());
- _worksheet = _package.Workbook.Worksheets.Add("Test");
- _parser = _worksheet.Workbook.FormulaParser;
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Avg()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(1, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Count()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(2, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_CountA()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(3, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(1d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Max()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(4, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Min()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(5, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Product()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(6, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Stdev()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(7, A2:A4)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(7, A5:A6)";
- _worksheet.Cells["A3"].Value = 5d;
- _worksheet.Cells["A4"].Value = 4d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Cells["A6"].Value = 4d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- result = Math.Round((double)result, 9);
- Assert.AreEqual(0.707106781d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_StdevP()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(8, A2:A4)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(8, A5:A6)";
- _worksheet.Cells["A3"].Value = 5d;
- _worksheet.Cells["A4"].Value = 4d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Cells["A6"].Value = 4d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(0.5d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Sum()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(9, A2:A3)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(9, A5:A6)";
- _worksheet.Cells["A3"].Value = 2d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(2d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_Var()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(9, A2:A4)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(8, A5:A6)";
- _worksheet.Cells["A3"].Value = 5d;
- _worksheet.Cells["A4"].Value = 4d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Cells["A6"].Value = 4d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(9d, result);
- }
-
- [TestMethod]
- public void SubtotalShouldNotIncludeSubtotalChildren_VarP()
- {
- _worksheet.Cells["A1"].Formula = "SUBTOTAL(10, A2:A4)";
- _worksheet.Cells["A2"].Formula = "SUBTOTAL(8, A5:A6)";
- _worksheet.Cells["A3"].Value = 5d;
- _worksheet.Cells["A4"].Value = 4d;
- _worksheet.Cells["A5"].Value = 2d;
- _worksheet.Cells["A6"].Value = 4d;
- _worksheet.Calculate();
- var result = _worksheet.Cells["A1"].Value;
- Assert.AreEqual(0.5d, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/TextFunctionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/TextFunctionsTests.cs
deleted file mode 100644
index 9ce60fd..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/BuiltInFunctions/TextFunctionsTests.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.Logging;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.BuiltInFunctions
-{
- [TestClass]
- public class TextFunctionsTests
- {
- [TestMethod]
- public void HyperlinkShouldHandleReference()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "HYPERLINK(B1)";
- sheet.Cells["B1"].Value = "http://epplus.codeplex.com";
- sheet.Calculate();
- Assert.AreEqual("http://epplus.codeplex.com", sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void HyperlinkShouldHandleReference2()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "HYPERLINK(B1, B2)";
- sheet.Cells["B1"].Value = "http://epplus.codeplex.com";
- sheet.Cells["B2"].Value = "Epplus";
- sheet.Calculate();
- Assert.AreEqual("Epplus", sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void HyperlinkShouldHandleText()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "HYPERLINK(\"testing\")";
- sheet.Calculate();
- Assert.AreEqual("testing", sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void CharShouldReturnCharValOfNumber()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "Char(A2)";
- sheet.Cells["A2"].Value = 55;
- sheet.Calculate();
- Assert.AreEqual("7", sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void FixedShouldHaveCorrectDefaultValues()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "Fixed(A2)";
- sheet.Cells["A2"].Value = 1234.5678;
- sheet.Calculate();
- Assert.AreEqual(1234.5678.ToString("N2"), sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void FixedShouldSetCorrectNumberOfDecimals()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "Fixed(A2,4)";
- sheet.Cells["A2"].Value = 1234.56789;
- sheet.Calculate();
- Assert.AreEqual(1234.56789.ToString("N4"), sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void FixedShouldSetNoCommas()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "Fixed(A2,4,true)";
- sheet.Cells["A2"].Value = 1234.56789;
- sheet.Calculate();
- Assert.AreEqual(1234.56789.ToString("F4"), sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void FixedShouldHandleNegativeDecimals()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "Fixed(A2,-1,true)";
- sheet.Cells["A2"].Value = 1234.56789;
- sheet.Calculate();
- Assert.AreEqual(1230.ToString("F0"), sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod]
- public void ConcatenateShouldHandleRange()
- {
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("test");
- sheet.Cells["A1"].Formula = "Concatenate(1,A2)";
- sheet.Cells["A2"].Value = "hello";
- sheet.Calculate();
- Assert.AreEqual("1hello", sheet.Cells["A1"].Value);
- }
- }
-
- [TestMethod, Ignore]
- public void Logtest1()
- {
- var sw = new Stopwatch();
- sw.Start();
- using (var pck = new ExcelPackage(new FileInfo(@"c:\temp\denis.xlsx")))
- {
- var logger = LoggerFactory.CreateTextFileLogger(new FileInfo(@"c:\temp\log1.txt"));
- pck.Workbook.FormulaParser.Configure(x => x.AttachLogger(logger));
- pck.Workbook.Calculate();
- //
- }
- sw.Stop();
- var elapsed = sw.Elapsed;
- Console.WriteLine(string.Format("{0} seconds", elapsed.TotalSeconds));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/CalcExtensionsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/CalcExtensionsTests.cs
deleted file mode 100644
index 4b73451..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/CalcExtensionsTests.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.IO;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests
-{
- [TestClass]
- public class CalcExtensionsTests
- {
- [TestMethod]
- public void ShouldCalculateChainTest()
- {
- var package = new ExcelPackage(new FileInfo("c:\\temp\\chaintest.xlsx"));
- package.Workbook.Calculate();
- }
-
- [TestMethod]
- public void CalculateTest()
- {
- //var pck = new ExcelPackage();
- //var ws = pck.Workbook.Worksheets.Add("Calc1");
-
- //ws.SetValue("A1", (short)1);
- //var v = pck.Workbook.FormulaParserManager.Parse("2.5-Calc1!A1+abs(3.0)-SIN(3)");
- //Assert.AreEqual(4.358879992, Math.Round((double)v, 9));
-
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
-
- ws.SetValue("A1", (short)1);
- var v = pck.Workbook.FormulaParserManager.Parse("2.5-Calc1!A1+ABS(-3.0)-SIN(3)*abs(5)");
- Assert.AreEqual(3.79439996, Math.Round((double)v,9));
- }
-
- [TestMethod]
- public void CalculateTest2()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Calc1");
-
- ws.SetValue("A1", (short)1);
- var v = pck.Workbook.FormulaParserManager.Parse("3*(2+5.5*2)+2*0.5+3");
- Assert.AreEqual(43, Math.Round((double)v, 9));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/ErrorHandling/FormulaErrorHandlingTestBase.cs b/EPPlusTest/FormulaParsing/IntegrationTests/ErrorHandling/FormulaErrorHandlingTestBase.cs
deleted file mode 100644
index a379c58..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/ErrorHandling/FormulaErrorHandlingTestBase.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.IO;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests
-{
- [TestClass]
- public class FormulaErrorHandlingTestBase
- {
- protected ExcelPackage Package;
- protected ExcelWorksheet Worksheet;
-
- public void BaseInitialize()
- {
- var dir = AppDomain.CurrentDomain.BaseDirectory;
- var Package = new ExcelPackage(new FileInfo(Path.Combine(dir, "Workbooks", "FormulaTest.xlsx")));
- Worksheet = Package.Workbook.Worksheets["ValidateFormulas"];
- Package.Workbook.Calculate();
- }
-
- public void BaseCleanup()
- {
- Package.Dispose();
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/ErrorHandling/SumTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/ErrorHandling/SumTests.cs
deleted file mode 100644
index c83918a..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/ErrorHandling/SumTests.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.ErrorHandling
-{
- /// <summary>
- /// Summary description for SumTests
- /// </summary>
- [TestClass, Ignore]
- public class SumTests : FormulaErrorHandlingTestBase
- {
- [TestInitialize]
- public void ClassInitialize()
- {
- BaseInitialize();
- }
-
- [TestCleanup]
- public void ClassCleanup()
- {
- BaseCleanup();
- }
-
- private TestContext testContextInstance;
-
- /// <summary>
- ///Gets or sets the test context which provides
- ///information about and functionality for the current test run.
- ///</summary>
- public TestContext TestContext
- {
- get
- {
- return testContextInstance;
- }
- set
- {
- testContextInstance = value;
- }
- }
- [TestMethod]
- public void SingleCell()
- {
- Assert.AreEqual(3d, Worksheet.Cells["B9"].Value);
- }
-
- [TestMethod]
- public void MultiCell()
- {
- Assert.AreEqual(40d, Worksheet.Cells["C9"].Value);
- }
-
- [TestMethod]
- public void Name()
- {
- Assert.AreEqual(10d, Worksheet.Cells["E9"].Value);
- }
-
- [TestMethod]
- public void ReferenceError()
- {
- Assert.AreEqual("#REF!", Worksheet.Cells["H9"].Value.ToString());
- }
-
- [TestMethod]
- public void NameOnOtherSheet()
- {
- Assert.AreEqual(130d, Worksheet.Cells["I9"].Value);
- }
-
- [TestMethod]
- public void ArrayInclText()
- {
- Assert.AreEqual(7d, Worksheet.Cells["J9"].Value);
- }
-
- //[TestMethod]
- //public void NameError()
- //{
- // Assert.AreEqual("#NAME?", Worksheet.Cells["L9"].Value);
- //}
-
- //[TestMethod]
- //public void DivByZeroError()
- //{
- // Assert.AreEqual("#DIV/0!", Worksheet.Cells["M9"].Value);
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/ExcelDataProviderTests/ExcelDataProviderIntegrationTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/ExcelDataProviderTests/ExcelDataProviderIntegrationTests.cs
deleted file mode 100644
index e18a13c..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/ExcelDataProviderTests/ExcelDataProviderIntegrationTests.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests.ExcelDataProviderTests
-{
- [TestClass]
- public class ExcelDataProviderIntegrationTests
- {
- private ExcelCell CreateItem(object val, int row)
- {
- return new ExcelCell(val, null, 0, row);
- }
-
- //[TestMethod]
- //public void ShouldCallProviderInSumFunctionAndCalculateResult()
- //{
- // var expectedAddres = "A1:A2";
- // var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- // provider
- // .Stub(x => x.GetRangeValues(string.Empty, expectedAddres))
- // .Return(new object[] { 1, 2 });
- // var parser = new FormulaParser(provider);
- // var result = parser.Parse(string.Format("sum({0})", expectedAddres));
- // Assert.AreEqual(3d, result);
- //}
-
- //[TestMethod]
- //public void ShouldExecuteFormulaInRange()
- //{
- // var expectedAddres = "A1:A2";
- // var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- // provider
- // .Stub(x => x.GetRangeValues(expectedAddres))
- // .Return(new object[] { 1, new ExcelCell(null, "SUM(1,2)", 0, 1) });
- // var parser = new FormulaParser(provider);
- // var result = parser.Parse(string.Format("sum({0})", expectedAddres));
- // Assert.AreEqual(4d, result);
- //}
-
- //[TestMethod, ExpectedException(typeof(CircularReferenceException))]
- //public void ShouldHandleCircularReference2()
- //{
- // var expectedAddres = "A1:A2";
- // var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- // provider
- // .Stub(x => x.GetRangeValues(expectedAddres))
- // .Return(new ExcelCell[] { CreateItem(1, 0), new ExcelCell(null, "SUM(A1:A2)",0, 1) });
- // var parser = new FormulaParser(provider);
- // var result = parser.Parse(string.Format("sum({0})", expectedAddres));
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/FormulaParserTestBase.cs b/EPPlusTest/FormulaParsing/IntegrationTests/FormulaParserTestBase.cs
deleted file mode 100644
index 34b97c4..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/FormulaParserTestBase.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests
-{
- public abstract class FormulaParserTestBase
- {
- protected FormulaParser _parser;
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/OperatorsTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/OperatorsTests.cs
deleted file mode 100644
index b27e7a5..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/OperatorsTests.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests
-{
- [TestClass]
- public class OperatorsTests
- {
- private ExcelPackage _package;
- private ExcelWorksheet _ws;
- private readonly ExcelErrorValue DivByZero = ExcelErrorValue.Create(eErrorType.Div0);
-
- [TestInitialize]
- public void Initialize()
- {
- _package = new ExcelPackage();
- _ws = _package.Workbook.Worksheets.Add("test");
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- _package.Dispose();
- }
-
- [TestMethod]
- public void DivByZeroShouldReturnError()
- {
- var result = _ws.Calculate("10/0 + 3");
- Assert.AreEqual(DivByZero, result);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/IntegrationTests/PrecedenceTests.cs b/EPPlusTest/FormulaParsing/IntegrationTests/PrecedenceTests.cs
deleted file mode 100644
index c10fc17..0000000
--- a/EPPlusTest/FormulaParsing/IntegrationTests/PrecedenceTests.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-
-namespace EPPlusTest.FormulaParsing.IntegrationTests
-{
- [TestClass]
- public class PrecedenceTests : FormulaParserTestBase
- {
-
- [TestInitialize]
- public void Setup()
- {
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _parser = new FormulaParser(excelDataProvider);
- }
-
- [TestMethod]
- public void ShouldCaluclateUsingPrecedenceMultiplyBeforeAdd()
- {
- var result = _parser.Parse("4 + 6 * 2");
- Assert.AreEqual(16d, result);
- }
-
- [TestMethod]
- public void ShouldCaluclateUsingPrecedenceDivideBeforeAdd()
- {
- var result = _parser.Parse("4 + 6 / 2");
- Assert.AreEqual(7d, result);
- }
-
- [TestMethod]
- public void ShouldCalculateTwoGroupsUsingDivideAndMultiplyBeforeSubtract()
- {
- var result = _parser.Parse("4/2 + 3 * 3");
- Assert.AreEqual(11d, result);
- }
-
- [TestMethod]
- public void ShouldCalculateExpressionWithinParenthesisBeforeMultiply()
- {
- var result = _parser.Parse("(2+4) * 2");
- Assert.AreEqual(12d, result);
- }
-
- [TestMethod]
- public void ShouldConcatAfterAdd()
- {
- var result = _parser.Parse("2 + 4 & \"abc\"");
- Assert.AreEqual("6abc", result);
- }
-
- [TestMethod]
- public void Bugfixtest()
- {
- var result = _parser.Parse("(1+2)+3^2");
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/LexicalAnalysis/CharHandlerTests.cs b/EPPlusTest/FormulaParsing/LexicalAnalysis/CharHandlerTests.cs
deleted file mode 100644
index ba03377..0000000
--- a/EPPlusTest/FormulaParsing/LexicalAnalysis/CharHandlerTests.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace EPPlusTest.FormulaParsing.LexicalAnalysis
-{
- [TestClass]
- public class CharHandlerTests
- {
-
- }
-}
diff --git a/EPPlusTest/FormulaParsing/LexicalAnalysis/NegationTests.cs b/EPPlusTest/FormulaParsing/LexicalAnalysis/NegationTests.cs
deleted file mode 100644
index e1f9b0d..0000000
--- a/EPPlusTest/FormulaParsing/LexicalAnalysis/NegationTests.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing;
-
-
-namespace EPPlusTest.FormulaParsing.LexicalAnalysis
-{
- [TestClass]
- public class NegationTests
- {
- private SourceCodeTokenizer _tokenizer;
-
- [TestInitialize]
- public void Setup()
- {
- var context = ParsingContext.Create();
- _tokenizer = new SourceCodeTokenizer(context.Configuration.FunctionRepository, null);
- }
-
- [TestCleanup]
- public void Cleanup()
- {
-
- }
-
- [TestMethod]
- public void ShouldSetNegatorOnFirstTokenIfFirstCharIsMinus()
- {
- var input = "-1";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(2, tokens.Count());
- Assert.AreEqual(TokenType.Negator, tokens.First().TokenType);
- }
-
- [TestMethod]
- public void ShouldChangePlusToMinusIfNegatorIsPresent()
- {
- var input = "1 + -1";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(3, tokens.Count());
- Assert.AreEqual(TokenType.Operator, tokens.ElementAt(1).TokenType);
- Assert.AreEqual("-", tokens.ElementAt(1).Value);
- }
-
- [TestMethod]
- public void ShouldSetNegatorOnTokenInsideParenthethis()
- {
- var input = "1 + (-1 * 2)";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(8, tokens.Count());
- Assert.AreEqual(TokenType.Negator, tokens.ElementAt(3).TokenType);
- }
-
- [TestMethod]
- public void ShouldSetNegatorOnTokenInsideFunctionCall()
- {
- var input = "Ceiling(-1, -0.1)";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(8, tokens.Count());
- Assert.AreEqual(TokenType.Negator, tokens.ElementAt(2).TokenType);
- Assert.AreEqual(TokenType.Negator, tokens.ElementAt(5).TokenType, "Negator after comma was not identified");
- }
-
- [TestMethod]
- public void ShouldSetNegatorOnTokenInEnumerable()
- {
- var input = "{-1}";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(TokenType.Negator, tokens.ElementAt(1).TokenType);
- }
-
- [TestMethod]
- public void ShouldSetNegatorOnExcelAddress()
- {
- var input = "-A1";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(TokenType.Negator, tokens.ElementAt(0).TokenType);
- Assert.AreEqual(TokenType.ExcelAddress, tokens.ElementAt(1).TokenType);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/LexicalAnalysis/SourceCodeTokenizerTests.cs b/EPPlusTest/FormulaParsing/LexicalAnalysis/SourceCodeTokenizerTests.cs
deleted file mode 100644
index b3905be..0000000
--- a/EPPlusTest/FormulaParsing/LexicalAnalysis/SourceCodeTokenizerTests.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing.LexicalAnalysis
-{
- [TestClass]
- public class SourceCodeTokenizerTests
- {
- private SourceCodeTokenizer _tokenizer;
-
- [TestInitialize]
- public void Setup()
- {
- var context = ParsingContext.Create();
- _tokenizer = new SourceCodeTokenizer(context.Configuration.FunctionRepository, null);
- }
-
- [TestCleanup]
- public void Cleanup()
- {
- }
-
- [TestMethod]
- public void ShouldCreateTokensForStringCorrectly()
- {
- var input = "\"abc123\"";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(3, tokens.Count());
- Assert.AreEqual(TokenType.String, tokens.First().TokenType);
- Assert.AreEqual(TokenType.StringContent, tokens.ElementAt(1).TokenType);
- Assert.AreEqual(TokenType.String, tokens.Last().TokenType);
- }
-
- [TestMethod]
- public void ShouldTokenizeStringCorrectly()
- {
- var input = "'ab(c)d'";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(3, tokens.Count());
- }
-
- [TestMethod]
- public void ShouldCreateTokensForFunctionCorrectly()
- {
- var input = "Text(2)";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(4, tokens.Count());
- Assert.AreEqual(TokenType.Function, tokens.First().TokenType);
- Assert.AreEqual(TokenType.OpeningParenthesis, tokens.ElementAt(1).TokenType);
- Assert.AreEqual(TokenType.Integer, tokens.ElementAt(2).TokenType);
- Assert.AreEqual("2", tokens.ElementAt(2).Value);
- Assert.AreEqual(TokenType.ClosingParenthesis, tokens.Last().TokenType);
- }
-
- [TestMethod]
- public void ShouldHandleMultipleCharOperatorCorrectly()
- {
- var input = "1 <= 2";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(3, tokens.Count());
- Assert.AreEqual("<=", tokens.ElementAt(1).Value);
- Assert.AreEqual(TokenType.Operator, tokens.ElementAt(1).TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateTokensForEnumerableCorrectly()
- {
- var input = "Text({1;2})";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(8, tokens.Count());
- Assert.AreEqual(TokenType.OpeningEnumerable, tokens.ElementAt(2).TokenType);
- Assert.AreEqual(TokenType.ClosingEnumerable, tokens.ElementAt(6).TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateTokensForExcelAddressCorrectly()
- {
- var input = "Text(A1)";
- var tokens = _tokenizer.Tokenize(input);
-
- Assert.AreEqual(TokenType.ExcelAddress, tokens.ElementAt(2).TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateTokenForPercentAfterDecimal()
- {
- var input = "1,23%";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(TokenType.Percent, tokens.Last().TokenType);
- }
-
- [TestMethod]
- public void ShouldIgnoreTwoSubsequentStringIdentifyers()
- {
- var input = "\"hello\"\"world\"";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(3, tokens.Count());
- Assert.AreEqual("hello\"world", tokens.ElementAt(1).Value);
- }
-
- [TestMethod]
- public void ShouldIgnoreTwoSubsequentStringIdentifyers2()
- {
- //using (var pck = new ExcelPackage(new FileInfo("c:\\temp\\QuoteIssue2.xlsx")))
- //{
- // pck.Workbook.Worksheets.First().Calculate();
- //}
- var input = "\"\"\"\"\"\"";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(TokenType.StringContent, tokens.ElementAt(1).TokenType);
- }
-
- [TestMethod]
- public void TokenizerShouldIgnoreOperatorInString()
- {
- var input = "\"*\"";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(TokenType.StringContent, tokens.ElementAt(1).TokenType);
- }
-
- [TestMethod]
- public void TokenizerShouldHandleWorksheetNameWithMinus()
- {
- var input = "'A-B'!A1";
- var tokens = _tokenizer.Tokenize(input);
- Assert.AreEqual(1, tokens.Count());
- }
-
- [TestMethod]
- public void TestBug9_12_14()
- {
- //(( W60 -(- W63 )-( W29 + W30 + W31 ))/( W23 + W28 + W42 - W51 )* W4 )
- using (var pck = new ExcelPackage())
- {
- var ws1 = pck.Workbook.Worksheets.Add("test");
- for (var x = 1; x <= 10; x++)
- {
- ws1.Cells[x, 1].Value = x;
- }
-
- ws1.Cells["A11"].Formula = "(( A1 -(- A2 )-( A3 + A4 + A5 ))/( A6 + A7 + A8 - A9 )* A5 )";
- //ws1.Cells["A11"].Formula = "(-A2 + 1 )";
- ws1.Calculate();
- var result = ws1.Cells["A11"].Value;
- Assert.AreEqual(-3.75, result);
- }
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/LexicalAnalysis/SyntacticAnalyzerTests.cs b/EPPlusTest/FormulaParsing/LexicalAnalysis/SyntacticAnalyzerTests.cs
deleted file mode 100644
index 0a263c6..0000000
--- a/EPPlusTest/FormulaParsing/LexicalAnalysis/SyntacticAnalyzerTests.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing.Exceptions;
-
-namespace EPPlusTest.FormulaParsing.LexicalAnalysis
-{
- [TestClass]
- public class SyntacticAnalyzerTests
- {
- private ISyntacticAnalyzer _analyser;
-
- [TestInitialize]
- public void Setup()
- {
- _analyser = new SyntacticAnalyzer();
- }
-
- [TestMethod]
- public void ShouldPassIfParenthesisAreWellformed()
- {
- var input = new List<Token>
- {
- new Token("(", TokenType.OpeningParenthesis),
- new Token("1", TokenType.Integer),
- new Token("+", TokenType.Operator),
- new Token("2", TokenType.Integer),
- new Token(")", TokenType.ClosingParenthesis)
- };
- _analyser.Analyze(input);
- }
-
- [TestMethod, ExpectedException(typeof(FormatException))]
- public void ShouldThrowExceptionIfParenthesesAreNotWellformed()
- {
- var input = new List<Token>
- {
- new Token("(", TokenType.OpeningParenthesis),
- new Token("1", TokenType.Integer),
- new Token("+", TokenType.Operator),
- new Token("2", TokenType.Integer)
- };
- _analyser.Analyze(input);
- }
-
- [TestMethod]
- public void ShouldPassIfStringIsWellformed()
- {
- var input = new List<Token>
- {
- new Token("'", TokenType.String),
- new Token("abc123", TokenType.StringContent),
- new Token("'", TokenType.String)
- };
- _analyser.Analyze(input);
- }
-
- [TestMethod, ExpectedException(typeof(FormatException))]
- public void ShouldThrowExceptionIfStringHasNotClosing()
- {
- var input = new List<Token>
- {
- new Token("'", TokenType.String),
- new Token("abc123", TokenType.StringContent)
- };
- _analyser.Analyze(input);
- }
-
-
- [TestMethod, ExpectedException(typeof(UnrecognizedTokenException))]
- public void ShouldThrowExceptionIfThereIsAnUnrecognizedToken()
- {
- var input = new List<Token>
- {
- new Token("abc123", TokenType.Unrecognized)
- };
- _analyser.Analyze(input);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/LexicalAnalysis/TokenFactoryTests.cs b/EPPlusTest/FormulaParsing/LexicalAnalysis/TokenFactoryTests.cs
deleted file mode 100644
index 62d8385..0000000
--- a/EPPlusTest/FormulaParsing/LexicalAnalysis/TokenFactoryTests.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-namespace EPPlusTest.FormulaParsing.LexicalAnalysis
-{
- [TestClass]
- public class TokenFactoryTests
- {
- private ITokenFactory _tokenFactory;
- private INameValueProvider _nameValueProvider;
-
-
- [TestInitialize]
- public void Setup()
- {
- var context = ParsingContext.Create();
- var excelDataProvider = MockRepository.GenerateStub<ExcelDataProvider>();
- _nameValueProvider = MockRepository.GenerateStub<INameValueProvider>();
- _tokenFactory = new TokenFactory(context.Configuration.FunctionRepository, _nameValueProvider);
- }
-
- [TestCleanup]
- public void Cleanup()
- {
-
- }
-
- [TestMethod]
- public void ShouldCreateAStringToken()
- {
- var input = "\"";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("\"", token.Value);
- Assert.AreEqual(TokenType.String, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreatePlusAsOperatorToken()
- {
- var input = "+";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("+", token.Value);
- Assert.AreEqual(TokenType.Operator, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateMinusAsOperatorToken()
- {
- var input = "-";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("-", token.Value);
- Assert.AreEqual(TokenType.Operator, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateMultiplyAsOperatorToken()
- {
- var input = "*";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("*", token.Value);
- Assert.AreEqual(TokenType.Operator, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateDivideAsOperatorToken()
- {
- var input = "/";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("/", token.Value);
- Assert.AreEqual(TokenType.Operator, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateEqualsAsOperatorToken()
- {
- var input = "=";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("=", token.Value);
- Assert.AreEqual(TokenType.Operator, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateIntegerAsIntegerToken()
- {
- var input = "23";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("23", token.Value);
- Assert.AreEqual(TokenType.Integer, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateBooleanAsBooleanToken()
- {
- var input = "true";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("true", token.Value);
- Assert.AreEqual(TokenType.Boolean, token.TokenType);
- }
-
- [TestMethod]
- public void ShouldCreateDecimalAsDecimalToken()
- {
- var input = "23.3";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
-
- Assert.AreEqual("23.3", token.Value);
- Assert.AreEqual(TokenType.Decimal, token.TokenType);
- }
-
- [TestMethod]
- public void CreateShouldReadFunctionsFromFuncRepository()
- {
- var input = "Text";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
- Assert.AreEqual(TokenType.Function, token.TokenType);
- Assert.AreEqual("Text", token.Value);
- }
-
- [TestMethod]
- public void CreateShouldCreateExcelAddressAsExcelAddressToken()
- {
- var input = "A1";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
- Assert.AreEqual(TokenType.ExcelAddress, token.TokenType);
- Assert.AreEqual("A1", token.Value);
- }
-
- [TestMethod]
- public void CreateShouldCreateExcelRangeAsExcelAddressToken()
- {
- var input = "A1:B15";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
- Assert.AreEqual(TokenType.ExcelAddress, token.TokenType);
- Assert.AreEqual("A1:B15", token.Value);
- }
-
- [TestMethod]
- public void CreateShouldCreateExcelRangeOnOtherSheetAsExcelAddressToken()
- {
- var input = "ws!A1:B15";
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
- Assert.AreEqual(TokenType.ExcelAddress, token.TokenType);
- Assert.AreEqual("WS!A1:B15", token.Value);
- }
-
- [TestMethod]
- public void CreateShouldCreateNamedValueAsExcelAddressToken()
- {
- var input = "NamedValue";
- _nameValueProvider.Stub(x => x.IsNamedValue("NamedValue","")).Return(true);
- _nameValueProvider.Stub(x => x.IsNamedValue("NamedValue", null)).Return(true);
- var token = _tokenFactory.Create(Enumerable.Empty<Token>(), input);
- Assert.AreEqual(TokenType.NameValue, token.TokenType);
- Assert.AreEqual("NamedValue", token.Value);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/LexicalAnalysis/TokenHandlerTests.cs b/EPPlusTest/FormulaParsing/LexicalAnalysis/TokenHandlerTests.cs
deleted file mode 100644
index faa7910..0000000
--- a/EPPlusTest/FormulaParsing/LexicalAnalysis/TokenHandlerTests.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing.LexicalAnalysis
-{
- [TestClass]
- public class TokenHandlerTests
- {
- private TokenizerContext _tokenizerContext;
- private TokenHandler _handler;
-
- [TestInitialize]
- public void Init()
- {
- _tokenizerContext = new TokenizerContext("test");
- InitHandler(_tokenizerContext);
- }
-
- private void InitHandler(TokenizerContext context)
- {
- var parsingContext = ParsingContext.Create();
- var tokenFactory = new TokenFactory(parsingContext.Configuration.FunctionRepository, null);
- _handler = new TokenHandler(_tokenizerContext, tokenFactory, new TokenSeparatorProvider());
- }
-
- [TestMethod]
- public void HasMoreTokensShouldBeTrueWhenTokensExists()
- {
- Assert.IsTrue(_handler.HasMore());
- }
-
- [TestMethod]
- public void HasMoreTokensShouldBeFalseWhenAllAreHandled()
- {
- for (var x = 0; x < "test".Length; x++ )
- {
- _handler.Next();
- }
- Assert.IsFalse(_handler.HasMore());
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/NameValueProviderTests.cs b/EPPlusTest/FormulaParsing/NameValueProviderTests.cs
deleted file mode 100644
index 39ed21d..0000000
--- a/EPPlusTest/FormulaParsing/NameValueProviderTests.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-
-namespace EPPlusTest.FormulaParsing
-{
- [TestClass]
- public class NameValueProviderTests
- {
- //private ExcelDataProvider _excelDataProvider;
-
- //[TestInitialize]
- //public void Setup()
- //{
- // _excelDataProvider = MockRepository.GenerateMock<ExcelDataProvider>();
- //}
-
- //[TestMethod]
- //public void IsNamedValueShouldReturnTrueIfKeyIsANamedValue()
- //{
- // var dict = new Dictionary<string, object>();
- // dict.Add("A", "B");
- // _excelDataProvider.Stub(x => x.GetWorkbookNameValues())
- // .Return(dict);
- // var nameValueProvider = new EpplusNameValueProvider(_excelDataProvider);
-
- // var result = nameValueProvider.IsNamedValue("A");
- // Assert.IsTrue(result);
- //}
-
- //[TestMethod]
- //public void IsNamedValueShouldReturnFalseIfKeyIsNotANamedValue()
- //{
- // var dict = new Dictionary<string, object>();
- // dict.Add("A", "B");
- // _excelDataProvider.Stub(x => x.GetWorkbookNameValues())
- // .Return(dict);
- // var nameValueProvider = new EpplusNameValueProvider(_excelDataProvider);
-
- // var result = nameValueProvider.IsNamedValue("C");
- // Assert.IsFalse(result);
- //}
-
- //[TestMethod]
- //public void GetNamedValueShouldReturnCorrectValueIfKeyExists()
- //{
- // var dict = new Dictionary<string, object>();
- // dict.Add("A", "B");
- // _excelDataProvider.Stub(x => x.GetWorkbookNameValues())
- // .Return(dict);
- // var nameValueProvider = new EpplusNameValueProvider(_excelDataProvider);
-
- // var result = nameValueProvider.GetNamedValue("A");
- // Assert.AreEqual("B", result);
- //}
-
- //[TestMethod]
- //public void ReloadShouldReloadDataFromExcelDataProvider()
- //{
- // var dict = new Dictionary<string, object>();
- // dict.Add("A", "B");
- // _excelDataProvider.Stub(x => x.GetWorkbookNameValues())
- // .Return(dict);
- // var nameValueProvider = new EpplusNameValueProvider(_excelDataProvider);
-
- // var result = nameValueProvider.GetNamedValue("A");
- // Assert.AreEqual("B", result);
-
- // dict.Clear();
- // nameValueProvider.Reload();
- // Assert.IsFalse(nameValueProvider.IsNamedValue("A"));
- //}
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ParsingContextTests.cs b/EPPlusTest/FormulaParsing/ParsingContextTests.cs
deleted file mode 100644
index 2f3cbe7..0000000
--- a/EPPlusTest/FormulaParsing/ParsingContextTests.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing
-{
- [TestClass]
- public class ParsingContextTests
- {
- [TestMethod]
- public void ConfigurationShouldBeSetByFactoryMethod()
- {
- var context = ParsingContext.Create();
- Assert.IsNotNull(context.Configuration);
- }
-
- [TestMethod]
- public void ScopesShouldBeSetByFactoryMethod()
- {
- var context = ParsingContext.Create();
- Assert.IsNotNull(context.Scopes);
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ParsingScopeTests.cs b/EPPlusTest/FormulaParsing/ParsingScopeTests.cs
deleted file mode 100644
index 45d3235..0000000
--- a/EPPlusTest/FormulaParsing/ParsingScopeTests.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-using OfficeOpenXml.FormulaParsing;
-
-namespace EPPlusTest.FormulaParsing
-{
- [TestClass]
- public class ParsingScopeTests
- {
- private IParsingLifetimeEventHandler _lifeTimeEventHandler;
- private ParsingScopes _parsingScopes;
- private RangeAddressFactory _factory;
-
- [TestInitialize]
- public void Setup()
- {
- var provider = MockRepository.GenerateStub<ExcelDataProvider>();
- _factory = new RangeAddressFactory(provider);
- _lifeTimeEventHandler = MockRepository.GenerateStub<IParsingLifetimeEventHandler>();
- _parsingScopes = MockRepository.GenerateStub<ParsingScopes>(_lifeTimeEventHandler);
- }
-
- [TestMethod]
- public void ConstructorShouldSetAddress()
- {
- var expectedAddress = _factory.Create("A1");
- var scope = new ParsingScope(_parsingScopes, expectedAddress);
- Assert.AreEqual(expectedAddress, scope.Address);
- }
-
- [TestMethod]
- public void ConstructorShouldSetParent()
- {
- var parent = new ParsingScope(_parsingScopes, _factory.Create("A1"));
- var scope = new ParsingScope(_parsingScopes, parent, _factory.Create("A2"));
- Assert.AreEqual(parent, scope.Parent);
- }
-
- [TestMethod]
- public void ScopeShouldCallKillScopeOnDispose()
- {
- var scope = new ParsingScope(_parsingScopes, _factory.Create("A1"));
- ((IDisposable)scope).Dispose();
- _parsingScopes.AssertWasCalled(x => x.KillScope(scope));
- }
- }
-}
diff --git a/EPPlusTest/FormulaParsing/ParsingScopesTest.cs b/EPPlusTest/FormulaParsing/ParsingScopesTest.cs
deleted file mode 100644
index 2ff6ce6..0000000
--- a/EPPlusTest/FormulaParsing/ParsingScopesTest.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.FormulaParsing;
-using Rhino.Mocks;
-using OfficeOpenXml.FormulaParsing.ExcelUtilities;
-
-namespace EPPlusTest.FormulaParsing
-{
- [TestClass]
- public class ParsingScopesTest
- {
- private ParsingScopes _parsingScopes;
- private IParsingLifetimeEventHandler _lifeTimeEventHandler;
-
- [TestInitialize]
- public void Setup()
- {
- _lifeTimeEventHandler = MockRepository.GenerateStub<IParsingLifetimeEventHandler>();
- _parsingScopes = new ParsingScopes(_lifeTimeEventHandler);
- }
-
- [TestMethod]
- public void CreatedScopeShouldBeCurrentScope()
- {
- using (var scope = _parsingScopes.NewScope(RangeAddress.Empty))
- {
- Assert.AreEqual(_parsingScopes.Current, scope);
- }
- }
-
- [TestMethod]
- public void CurrentScopeShouldHandleNestedScopes()
- {
- using (var scope1 = _parsingScopes.NewScope(RangeAddress.Empty))
- {
- Assert.AreEqual(_parsingScopes.Current, scope1);
- using (var scope2 = _parsingScopes.NewScope(RangeAddress.Empty))
- {
- Assert.AreEqual(_parsingScopes.Current, scope2);
- }
- Assert.AreEqual(_parsingScopes.Current, scope1);
- }
- Assert.IsNull(_parsingScopes.Current);
- }
-
- [TestMethod]
- public void CurrentScopeShouldBeNullWhenScopeHasTerminated()
- {
- using (var scope = _parsingScopes.NewScope(RangeAddress.Empty))
- { }
- Assert.IsNull(_parsingScopes.Current);
- }
-
- [TestMethod]
- public void NewScopeShouldSetParentOnCreatedScopeIfParentScopeExisted()
- {
- using (var scope1 = _parsingScopes.NewScope(RangeAddress.Empty))
- {
- using (var scope2 = _parsingScopes.NewScope(RangeAddress.Empty))
- {
- Assert.AreEqual(scope1, scope2.Parent);
- }
- }
- }
-
- [TestMethod]
- public void LifetimeEventHandlerShouldBeCalled()
- {
- using (var scope = _parsingScopes.NewScope(RangeAddress.Empty))
- { }
- _lifeTimeEventHandler.AssertWasCalled(x => x.ParsingCompleted());
- }
- }
-}
\ No newline at end of file
diff --git a/EPPlusTest/FormulaParsing/TestHelpers/FunctionsHelper.cs b/EPPlusTest/FormulaParsing/TestHelpers/FunctionsHelper.cs
deleted file mode 100644
index 3011ceb..0000000
--- a/EPPlusTest/FormulaParsing/TestHelpers/FunctionsHelper.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using Rhino.Mocks;
-using Rhino.Mocks.Constraints;
-
-namespace EPPlusTest.FormulaParsing.TestHelpers
-{
- public static class FunctionsHelper
- {
- public static IEnumerable<FunctionArgument> CreateArgs(params object[] args)
- {
- var list = new List<FunctionArgument>();
- foreach (var arg in args)
- {
- list.Add(new FunctionArgument(arg));
- }
- return list;
- }
-
- public static IEnumerable<FunctionArgument> Empty()
- {
- return new List<FunctionArgument>() {new FunctionArgument(null)};
- }
- }
-}
diff --git a/EPPlusTest/Issues.cs b/EPPlusTest/Issues.cs
deleted file mode 100644
index 79cc513..0000000
--- a/EPPlusTest/Issues.cs
+++ /dev/null
@@ -1,995 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Linq;
-using System.Reflection;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.IO;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing.Logging;
-using OfficeOpenXml.Style;
-using System.Data;
-using OfficeOpenXml.Table;
-using Rhino.Mocks.Constraints;
-using System.Collections.Generic;
-using OfficeOpenXml.Table.PivotTable;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class Issues
- {
- [TestInitialize]
- public void Initialize()
- {
- if (!Directory.Exists(@"c:\Temp"))
- {
- Directory.CreateDirectory(@"c:\Temp");
- }
- if (!Directory.Exists(@"c:\Temp\bug"))
- {
- Directory.CreateDirectory(@"c:\Temp\bug");
- }
- }
- [TestMethod,Ignore]
- public void Issue15052()
- {
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("test");
- ws.Cells["A1:A4"].Value = 1;
- ws.Cells["B1:B4"].Value = 2;
-
- ws.Cells[1, 1, 4, 1]
- .Style.Numberformat.Format = "#,##0.00;[Red]-#,##0.00";
-
- ws.Cells[1, 2, 5, 2]
- .Style.Numberformat.Format = "#,##0;[Red]-#,##0";
-
- p.SaveAs(new FileInfo(@"c:\temp\style.xlsx"));
- }
- [TestMethod]
- public void Issue15041()
- {
- using (var package = new ExcelPackage())
- {
- var ws = package.Workbook.Worksheets.Add("Test");
- ws.Cells["A1"].Value = 202100083;
- ws.Cells["A1"].Style.Numberformat.Format = "00\\.00\\.00\\.000\\.0";
- Assert.AreEqual("02.02.10.008.3", ws.Cells["A1"].Text);
- ws.Dispose();
- }
- }
- [TestMethod]
- public void Issue15031()
- {
- var d = OfficeOpenXml.Utils.ConvertUtil.GetValueDouble(new TimeSpan(35, 59, 1));
- using (var package = new ExcelPackage())
- {
- var ws = package.Workbook.Worksheets.Add("Test");
- ws.Cells["A1"].Value = d;
- ws.Cells["A1"].Style.Numberformat.Format = "[t]:mm:ss";
- ws.Dispose();
- }
- }
- [TestMethod]
- public void Issue15022()
- {
- using (var package = new ExcelPackage())
- {
- var ws = package.Workbook.Worksheets.Add("Test");
- ws.Cells.AutoFitColumns();
- ws.Cells["A1"].Style.Numberformat.Format = "0";
- ws.Cells.AutoFitColumns();
- }
- }
- [TestMethod]
- public void Issue15056()
- {
- var path = @"C:\temp\output.xlsx";
- var file = new FileInfo(path);
- file.Delete();
- using (var ep = new ExcelPackage(file))
- {
- var s = ep.Workbook.Worksheets.Add("test");
- s.Cells["A1:A2"].Formula = ""; // or null, or non-empty whitespace, with same result
- ep.Save();
- }
-
- }
- [Ignore]
- [TestMethod]
- public void Issue15058()
- {
- System.IO.FileInfo newFile = new System.IO.FileInfo(@"C:\Temp\output.xlsx");
- ExcelPackage excelP = new ExcelPackage(newFile);
- ExcelWorksheet ws = excelP.Workbook.Worksheets[1];
- }
- [Ignore]
- [TestMethod]
- public void Issue15063()
- {
- System.IO.FileInfo newFile = new System.IO.FileInfo(@"C:\Temp\bug\TableFormula.xlsx");
- ExcelPackage excelP = new ExcelPackage(newFile);
- ExcelWorksheet ws = excelP.Workbook.Worksheets[1];
- ws.Calculate();
- }
- [Ignore]
- [TestMethod]
- public void Issue15112()
- {
- System.IO.FileInfo case1 = new System.IO.FileInfo(@"c:\temp\bug\src\src\DeleteRowIssue\Template.xlsx");
- var p = new ExcelPackage(case1);
- var first = p.Workbook.Worksheets[1];
- first.DeleteRow(5);
- p.SaveAs(new System.IO.FileInfo(@"c:\temp\bug\DeleteCol_case1.xlsx"));
-
- var case2 = new System.IO.FileInfo(@"c:\temp\bug\src2\DeleteRowIssue\Template.xlsx");
- p = new ExcelPackage(case2);
- first = p.Workbook.Worksheets[1];
- first.DeleteRow(5);
- p.SaveAs(new System.IO.FileInfo(@"c:\temp\bug\DeleteCol_case2.xlsx"));
- }
-
- [Ignore]
- [TestMethod]
- public void Issue15118()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\bugOutput.xlsx"), new FileInfo(@"c:\temp\bug\DeleteRowIssue\Template.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- var worksheet = workBook.Worksheets[1];
- worksheet.Cells[9, 6, 9, 7].Merge = true;
- worksheet.Cells[9, 8].Merge = false;
-
- worksheet.DeleteRow(5);
- worksheet.DeleteColumn(5);
- worksheet.DeleteColumn(5);
- worksheet.DeleteColumn(5);
- worksheet.DeleteColumn(5);
-
- package.Save();
- }
- }
- [Ignore]
- [TestMethod]
- public void Issue15109()
- {
- System.IO.FileInfo newFile = new System.IO.FileInfo(@"C:\Temp\bug\test01.xlsx");
- ExcelPackage excelP = new ExcelPackage(newFile);
- ExcelWorksheet ws = excelP.Workbook.Worksheets[1];
- Assert.AreEqual("A1:Z75",ws.Dimension.Address);
- excelP.Dispose();
-
- newFile = new System.IO.FileInfo(@"C:\Temp\bug\test02.xlsx");
- excelP = new ExcelPackage(newFile);
- ws = excelP.Workbook.Worksheets[1];
- Assert.AreEqual("A1:AF501", ws.Dimension.Address);
- excelP.Dispose();
-
- newFile = new System.IO.FileInfo(@"C:\Temp\bug\test03.xlsx");
- excelP = new ExcelPackage(newFile);
- ws = excelP.Workbook.Worksheets[1];
- Assert.AreEqual("A1:AD406", ws.Dimension.Address);
- excelP.Dispose();
- }
- [Ignore]
- [TestMethod]
- public void Issue15120()
- {
- var p=new ExcelPackage(new System.IO.FileInfo(@"C:\Temp\bug\pp.xlsx"));
- ExcelWorksheet ws = p.Workbook.Worksheets["tum_liste"];
- ExcelWorksheet wPvt = p.Workbook.Worksheets.Add("pvtSheet");
- var pvSh = wPvt.PivotTables.Add(wPvt.Cells["B5"], ws.Cells[ws.Dimension.Address.ToString()], "pvtS");
-
- //p.Save();
- }
- [TestMethod]
- public void Issue15113()
- {
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("t");
- ws.Cells["A1"].Value = " Performance Update";
- ws.Cells["A1:H1"].Merge = true;
- ws.Cells["A1:H1"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
- ws.Cells["A1:H1"].Style.Font.Size = 14;
- ws.Cells["A1:H1"].Style.Font.Color.SetColor(Color.Red);
- ws.Cells["A1:H1"].Style.Font.Bold = true;
- p.SaveAs(new FileInfo(@"c:\temp\merge.xlsx"));
- }
- [TestMethod]
- public void Issue15141()
- {
- using (ExcelPackage package = new ExcelPackage())
- using (ExcelWorksheet sheet = package.Workbook.Worksheets.Add("Test"))
- {
- sheet.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
- sheet.Cells.Style.Fill.BackgroundColor.SetColor(Color.White);
- sheet.Cells[1, 1, 1, 3].Style.Border.BorderAround(ExcelBorderStyle.Thin);
- sheet.Cells[1, 5, 2, 5].Style.Border.BorderAround(ExcelBorderStyle.Thin);
- ExcelColumn column = sheet.Column(3); // fails with exception
- }
- }
- [TestMethod, Ignore]
- public void Issue15145()
- {
- using (ExcelPackage p = new ExcelPackage(new System.IO.FileInfo(@"C:\Temp\bug\ColumnInsert.xlsx")))
- {
- ExcelWorksheet ws = p.Workbook.Worksheets[1];
- ws.InsertColumn(12,3);
- ws.InsertRow(30,3);
- ws.DeleteRow(31,1);
- ws.DeleteColumn(7,1);
- p.SaveAs(new System.IO.FileInfo(@"C:\Temp\bug\InsertCopyFail.xlsx"));
- }
- }
- [TestMethod, Ignore]
- public void Issue15150()
- {
- var template = new FileInfo(@"c:\temp\bug\ClearIssue.xlsx");
- const string output = @"c:\temp\bug\ClearIssueSave.xlsx";
-
- using (var pck = new ExcelPackage(template, false))
- {
- var ws = pck.Workbook.Worksheets[1];
- ws.Cells["A2:C3"].Value = "Test";
- var c = ws.Cells["B2:B3"];
- c.Clear();
-
- pck.SaveAs(new FileInfo(output));
- }
- }
-
- [TestMethod, Ignore]
- public void Issue15146()
- {
- var template = new FileInfo(@"c:\temp\bug\CopyFail.xlsx");
- const string output = @"c:\temp\bug\CopyFail-Save.xlsx";
-
- using (var pck = new ExcelPackage(template, false))
- {
- var ws = pck.Workbook.Worksheets[3];
-
- //ws.InsertColumn(3, 1);
- CustomColumnInsert(ws, 3, 1);
-
- pck.SaveAs(new FileInfo(output));
- }
- }
-
- private static void CustomColumnInsert(ExcelWorksheet ws, int column, int columns)
- {
- var source = ws.Cells[1, column, ws.Dimension.End.Row, ws.Dimension.End.Column];
- var dest = ws.Cells[1, column + columns, ws.Dimension.End.Row, ws.Dimension.End.Column + columns];
- source.Copy(dest);
- }
- [TestMethod]
- public void Issue15123()
- {
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("t");
- using (var dt = new DataTable())
- {
- dt.Columns.Add("String", typeof(string));
- dt.Columns.Add("Int", typeof(int));
- dt.Columns.Add("Bool", typeof(bool));
- dt.Columns.Add("Double", typeof(double));
- dt.Columns.Add("Date", typeof(DateTime));
-
- var dr = dt.NewRow();
- dr[0] = "Row1";
- dr[1] = 1;
- dr[2] = true;
- dr[3] = 1.5;
- dr[4] = new DateTime(2014, 12, 30);
- dt.Rows.Add(dr);
-
- dr = dt.NewRow();
- dr[0] = "Row2";
- dr[1] = 2;
- dr[2] = false;
- dr[3] = 2.25;
- dr[4] = new DateTime(2014, 12, 31);
- dt.Rows.Add(dr);
-
- ws.Cells["A1"].LoadFromDataTable(dt,true);
- ws.Cells["D2:D3"].Style.Numberformat.Format = "(* #,##0.00);_(* (#,##0.00);_(* \"-\"??_);(@)";
-
- ws.Cells["E2:E3"].Style.Numberformat.Format = "mm/dd/yyyy";
- ws.Cells.AutoFitColumns();
- Assert.AreNotEqual(ws.Cells[2, 5].Text,"");
- }
- }
-
- [TestMethod]
- public void Issue15128()
- {
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("t");
- ws.Cells["A1"].Value=1;
- ws.Cells["B1"].Value = 2;
- ws.Cells["B2"].Formula = "A1+$B$1";
- ws.Cells["C1"].Value = "Test";
- ws.Cells["A1:B2"].Copy(ws.Cells["C1"]);
- ws.Cells["B2"].Copy(ws.Cells["D1"]);
- p.SaveAs(new FileInfo(@"c:\temp\bug\copy.xlsx"));
- }
-
- [TestMethod]
- public void IssueMergedCells()
- {
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("t");
- ws.Cells["A1:A5,C1:C8"].Merge = true;
- ws.Cells["C1:C8"].Merge = false;
- ws.Cells["A1:A8"].Merge = false;
- p.Dispose();
- }
- [Ignore]
- [TestMethod]
- public void Issue15158()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\Output.xlsx"), new FileInfo(@"C:\temp\bug\DeleteColFormula\FormulasIssue\demo.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- ExcelWorksheet worksheet = workBook.Worksheets[1];
-
- //string column = ColumnIndexToColumnLetter(28);
- worksheet.DeleteColumn(28);
-
- if (worksheet.Cells["AA19"].Formula != "")
- {
- throw new Exception("this cell should not have formula");
- }
-
- package.Save();
- }
- }
-
- public class cls1
- {
- public int prop1 { get; set; }
- }
-
- public class cls2 : cls1
- {
- public string prop2 { get; set; }
- }
- [TestMethod]
- public void LoadFromColIssue()
- {
- var l = new List<cls1>();
-
- var c2 = new cls2() {prop1=1, prop2="test1"};
- l.Add(c2);
-
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("Test");
-
- ws.Cells["A1"].LoadFromCollection(l, true, TableStyles.Light16, BindingFlags.Instance | BindingFlags.Public,
- new MemberInfo[] {typeof(cls2).GetProperty("prop2")});
- }
-
- [TestMethod]
- public void Issue15168()
- {
- using (var p = new ExcelPackage())
- {
- var ws = p.Workbook.Worksheets.Add("Test");
- ws.Cells[1, 1].Value = "A1";
- ws.Cells[2, 1].Value = "A2";
-
- ws.Cells[2, 1].Value = ws.Cells[1, 1].Value;
- Assert.AreEqual("A1", ws.Cells[1, 1].Value);
- }
- }
- [Ignore]
- [TestMethod]
- public void Issue15159()
- {
- var fs = new FileStream(@"C:\temp\bug\DeleteColFormula\FormulasIssue\demo.xlsx", FileMode.OpenOrCreate);
- using (var package = new OfficeOpenXml.ExcelPackage(fs))
- {
- package.Save();
- }
- fs.Seek(0, SeekOrigin.Begin);
- var fs2 = fs;
- }
- [TestMethod]
- public void Issue15179()
- {
- using (var package = new OfficeOpenXml.ExcelPackage())
- {
- var ws = package.Workbook.Worksheets.Add("MergeDeleteBug");
- ws.Cells["E3:F3"].Merge = true;
- ws.Cells["E3:F3"].Merge = false;
- ws.DeleteRow(2, 6);
- ws.Cells["A1"].Value = 0;
- var s = ws.Cells["A1"].Value.ToString();
-
- }
- }
- [Ignore]
- [TestMethod]
- public void Issue15169()
- {
- FileInfo fileInfo = new FileInfo(@"C:\temp\bug\issue\input.xlsx");
-
- ExcelPackage excelPackage = new ExcelPackage(fileInfo);
- {
- string sheetName = "Labour Costs";
-
- ExcelWorksheet ws = excelPackage.Workbook.Worksheets[sheetName];
- excelPackage.Workbook.Worksheets.Delete(ws);
-
- ws = excelPackage.Workbook.Worksheets.Add(sheetName);
-
- excelPackage.SaveAs(new FileInfo(@"C:\temp\bug\issue\output2.xlsx"));
- }
- }
- [Ignore]
- [TestMethod]
- public void Issue15172()
- {
- FileInfo fileInfo = new FileInfo(@"C:\temp\bug\book2.xlsx");
-
- ExcelPackage excelPackage = new ExcelPackage(fileInfo);
- {
- ExcelWorksheet ws = excelPackage.Workbook.Worksheets[1];
-
- Assert.AreEqual("IF($R10>=X$2,1,0)", ws.Cells["X10"].Formula);
- ws.Calculate();
- Assert.AreEqual(0D,ws.Cells["X10"].Value);
- }
- }
- [Ignore]
- [TestMethod]
- public void Issue15174()
- {
- using (ExcelPackage package = new ExcelPackage(new FileInfo(@"C:\temp\bug\MyTemplate.xlsx")))
- {
- package.Workbook.Worksheets[1].Column(2).Style.Numberformat.Format = "dd/mm/yyyy";
-
- package.SaveAs(new FileInfo(@"C:\temp\bug\MyTemplate2.xlsx"));
- }
- }
- [Ignore]
- [TestMethod]
- public void PictureIssue()
- {
- var p = new ExcelPackage();
- var ws = p.Workbook.Worksheets.Add("t");
- ws.Drawings.AddPicture("Test", new FileInfo(@"c:\temp\bug\2152228.jpg"));
- p.SaveAs(new FileInfo(@"c:\temp\bug\pic.xlsx"));
- }
-
- [Ignore]
- [TestMethod]
- public void Issue14988()
- {
- var guid = Guid.NewGuid().ToString("N");
- using (var outputStream = new FileStream(@"C:\temp\" + guid + ".xlsx", FileMode.Create))
- {
- using (var inputStream = new FileStream(@"C:\temp\bug2.xlsx", FileMode.Open))
- {
- using (var package = new ExcelPackage(outputStream, inputStream, "Test"))
- {
- var ws = package.Workbook.Worksheets.Add("Test empty");
- ws.Cells["A1"].Value = "Test";
- package.Encryption.Password = "Test2";
- package.Save();
- //package.SaveAs(new FileInfo(@"c:\temp\test2.xlsx"));
- }
- }
- }
- }
-
- [TestMethod, Ignore]
- public void Issue15173_1()
- {
- using (var pck = new ExcelPackage(new FileInfo(@"c:\temp\EPPlusIssues\Excel01.xlsx")))
- {
- var sw = new Stopwatch();
- //pck.Workbook.FormulaParser.Configure(x => x.AttachLogger(LoggerFactory.CreateTextFileLogger(new FileInfo(@"c:\Temp\log1.txt"))));
- sw.Start();
- var ws = pck.Workbook.Worksheets.First();
- pck.Workbook.Calculate();
- Assert.AreEqual("20L2300", ws.Cells["F4"].Value);
- Assert.AreEqual("20K2E01", ws.Cells["F5"].Value);
- var f7Val = pck.Workbook.Worksheets["MODELLO-TIPO PANNELLO"].Cells["F7"].Value;
- Assert.AreEqual(13.445419, Math.Round((double) f7Val, 6));
- sw.Stop();
- Console.WriteLine(sw.Elapsed.TotalSeconds); // approx. 10 seconds
-
- }
- }
-
- [TestMethod, Ignore]
- public void Issue15173_2()
- {
- using (var pck = new ExcelPackage(new FileInfo(@"c:\temp\EPPlusIssues\Excel02.xlsx")))
- {
- var sw = new Stopwatch();
- pck.Workbook.FormulaParser.Configure(x => x.AttachLogger(LoggerFactory.CreateTextFileLogger(new FileInfo(@"c:\Temp\log1.txt"))));
- sw.Start();
- var ws = pck.Workbook.Worksheets.First();
- //ws.Calculate();
- pck.Workbook.Calculate();
- Assert.AreEqual("20L2300", ws.Cells["F4"].Value);
- Assert.AreEqual("20K2E01", ws.Cells["F5"].Value);
- sw.Stop();
- Console.WriteLine(sw.Elapsed.TotalSeconds); // approx. 10 seconds
-
- }
- }
- [Ignore]
- [TestMethod]
- public void Issue15154()
- {
- Directory.EnumerateFiles(@"c:\temp\bug\ConstructorInvokationNotThreadSafe\").AsParallel().ForAll(file =>
- {
- //lock (_lock)
- //{
- using (var package = new ExcelPackage(new FileStream(file, FileMode.Open)))
- {
- package.Workbook.Worksheets[1].Cells[1, 1].Value = file;
- package.SaveAs(new FileInfo(@"c:\temp\bug\ConstructorInvokationNotThreadSafe\new\"+new FileInfo(file).Name));
- }
- //}
- });
-
- }
- [Ignore]
- [TestMethod]
- public void Issue15188()
- {
- using (var package = new ExcelPackage())
- {
- var worksheet = package.Workbook.Worksheets.Add("test");
- worksheet.Column(6).Style.Numberformat.Format = "mm/dd/yyyy";
- worksheet.Column(7).Style.Numberformat.Format = "mm/dd/yyyy";
- worksheet.Column(8).Style.Numberformat.Format = "mm/dd/yyyy";
- worksheet.Column(10).Style.Numberformat.Format = "mm/dd/yyyy";
-
- worksheet.Cells[2, 6].Value = DateTime.Today;
- string a = worksheet.Cells[2,6].Text;
- Assert.AreEqual(DateTime.Today.ToString("MM/dd/yyyy"), a);
- }
- }
- [TestMethod, Ignore]
- public void Issue15194()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\bug\i15194-Save.xlsx"), new FileInfo(@"c:\temp\bug\I15194.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- var worksheet = workBook.Worksheets[1];
-
- worksheet.Cells["E3:F3"].Merge = false;
-
- worksheet.DeleteRow(2, 6);
-
- package.Save();
- }
- }
- [TestMethod, Ignore]
- public void Issue15195()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\bug\i15195_Save.xlsx"), new FileInfo(@"c:\temp\bug\i15195.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- var worksheet = workBook.Worksheets[1];
-
- worksheet.InsertColumn(8, 2);
-
- package.Save();
- }
- }
- [TestMethod,Ignore]
- public void Issue14788()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\bug\i15195_Save.xlsx"), new FileInfo(@"c:\temp\bug\GetWorkSheetXmlBad.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- var worksheet = workBook.Worksheets[1];
-
- worksheet.InsertColumn(8, 2);
-
- package.Save();
- }
- }
- [TestMethod, Ignore]
- public void Issue15167()
- {
- FileInfo fileInfo = new FileInfo(@"c:\temp\bug\Draw\input.xlsx");
-
- ExcelPackage excelPackage = new ExcelPackage(fileInfo);
- {
- string sheetName = "Board pack";
-
- ExcelWorksheet ws = excelPackage.Workbook.Worksheets[sheetName];
- excelPackage.Workbook.Worksheets.Delete(ws);
-
- ws = excelPackage.Workbook.Worksheets.Add(sheetName);
-
- excelPackage.SaveAs(new FileInfo(@"c:\temp\bug\output.xlsx"));
- }
- }
- [TestMethod, Ignore]
- public void Issue15198()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\bug\Output.xlsx"), new FileInfo(@"c:\temp\bug\demo.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- var worksheet = workBook.Worksheets[1];
-
- worksheet.DeleteRow(12);
-
- package.Save();
- }
- }
- [TestMethod,Ignore]
- public void Issue13492()
- {
- using (var package = new OfficeOpenXml.ExcelPackage(new FileInfo(@"c:\temp\bug\Bug13492.xlsx")))
- {
- ExcelWorkbook workBook = package.Workbook;
- var worksheet = workBook.Worksheets[1];
-
- var rt = worksheet.Cells["K31"].RichText.Text;
-
- package.Save();
- }
- }
- [TestMethod,Ignore]
- public void Issue14966()
- {
- using (var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\ssis\FileFromReportingServer2012.xlsx")))
- package.SaveAs(new FileInfo(@"c:\temp\bug\ssis\Corrupted.xlsx"));
- }
- [TestMethod, Ignore]
- public void Issue15200()
- {
- File.Copy(@"C:\temp\bug\EPPlusRangeCopyTest\EPPlusRangeCopyTest\input.xlsx", @"C:\temp\bug\EPPlusRangeCopyTest\EPPlusRangeCopyTest\output.xlsx", true);
-
- using (var p = new ExcelPackage(new FileInfo(@"C:\temp\bug\EPPlusRangeCopyTest\EPPlusRangeCopyTest\output.xlsx")))
- {
- var sheet = p.Workbook.Worksheets.First();
-
- var sourceRange = sheet.Cells[1, 1, 1, 2];
- var resultRange = sheet.Cells[3, 1, 3, 2];
- sourceRange.Copy(resultRange);
-
- sourceRange = sheet.Cells[1, 1, 1, 7];
- resultRange = sheet.Cells[5, 1, 5, 7];
- sourceRange.Copy(resultRange); // This throws System.ArgumentException: Can't merge and already merged range
-
- sourceRange = sheet.Cells[1, 1, 1, 7];
- resultRange = sheet.Cells[7, 3, 7, 7];
- sourceRange.Copy(resultRange); // This throws System.ArgumentException: Can't merge and already merged range
-
- p.Save();
- }
- }
- [TestMethod]
- public void Issue15212()
- {
- var s="_(\"R$ \"* #,##0.00_);_(\"R$ \"* (#,##0.00);_(\"R$ \"* \"-\"??_);_(@_) )";
- using (var p = new ExcelPackage())
- {
- var ws = p.Workbook.Worksheets.Add("StyleBug");
- ws.Cells["A1"].Value = 5698633.64;
- ws.Cells["A1"].Style.Numberformat.Format = s;
- var t = ws.Cells["A1"].Text;
- }
- }
- [TestMethod, Ignore]
- public void Issue15213()
- {
- using (var p = new ExcelPackage(new FileInfo(@"c:\temp\bug\ExcelClearDemo\exceltestfile.xlsx")))
- {
- foreach (var ws in p.Workbook.Worksheets)
- {
- ws.Cells[1023, 1, ws.Dimension.End.Row-2,ws.Dimension.End.Column].Clear();
- Assert.AreNotEqual(ws.Dimension, null);
- }
- foreach (var cell in p.Workbook.Worksheets[2].Cells)
- {
- Console.WriteLine(cell);
- }
- p.SaveAs(new FileInfo(@"c:\temp\bug\ExcelClearDemo\exceltestfile-save.xlsx"));
- }
- }
-
- [TestMethod, Ignore]
- public void Issuer15217()
- {
-
- using (var p = new ExcelPackage(new FileInfo(@"c:\temp\bug\FormatRowCol.xlsx")))
- {
- var ws = p.Workbook.Worksheets.Add("fmt");
- ws.Row(1).Style.Fill.PatternType = ExcelFillStyle.Solid;
- ws.Row(1).Style.Fill.BackgroundColor.SetColor(Color.LightGray);
- ws.Cells["A1:B2"].Value = 1;
- ws.Column(1).Style.Numberformat.Format = "yyyy-mm-dd hh:mm";
- ws.Column(2).Style.Numberformat.Format = "#,##0";
- p.Save();
- }
- }
- [TestMethod, Ignore]
- public void Issuer15228()
- {
- using (var p = new ExcelPackage())
- {
- var ws = p.Workbook.Worksheets.Add("colBug");
-
- var col = ws.Column(7);
- col.ColumnMax = 8;
- col.Hidden = true;
-
- var col8 = ws.Column(8);
- Assert.AreEqual(true, col8.Hidden);
- }
- }
-
- [TestMethod, Ignore]
- public void Issue15234()
- {
- using (var p = new ExcelPackage(new FileInfo(@"c:\temp\bug\merge2\input.xlsx")))
- {
- var sheet = p.Workbook.Worksheets.First();
-
- var sourceRange = sheet.Cells["1:4"];
-
- sheet.InsertRow(5, 4);
-
- var resultRange = sheet.Cells["5:8"];
- sourceRange.Copy(resultRange);
-
- p.Save();
- }
- }
- [TestMethod]
- /**** Pivottable issue ****/
- public void Issue()
- {
- DirectoryInfo outputDir = new DirectoryInfo(@"c:\ExcelPivotTest");
- FileInfo MyFile = new FileInfo(@"c:\temp\bug\pivottable.xlsx");
- LoadData(MyFile);
- BuildPivotTable1(MyFile);
- BuildPivotTable2(MyFile);
- }
-
- private void LoadData(FileInfo MyFile)
- {
- if (MyFile.Exists)
- {
- MyFile.Delete(); // ensures we create a new workbook
- }
-
- using (ExcelPackage EP = new ExcelPackage(MyFile))
- {
- // add a new worksheet to the empty workbook
- ExcelWorksheet wsData = EP.Workbook.Worksheets.Add("Data");
- //Add the headers
- wsData.Cells[1, 1].Value = "INVOICE_DATE";
- wsData.Cells[1, 2].Value = "TOTAL_INVOICE_PRICE";
- wsData.Cells[1, 3].Value = "EXTENDED_PRICE_VARIANCE";
- wsData.Cells[1, 4].Value = "AUDIT_LINE_STATUS";
- wsData.Cells[1, 5].Value = "RESOLUTION_STATUS";
- wsData.Cells[1, 6].Value = "COUNT";
-
- //Add some items...
- wsData.Cells["A2"].Value = Convert.ToDateTime("04/2/2012");
- wsData.Cells["B2"].Value = 33.63;
- wsData.Cells["C2"].Value = (-.87);
- wsData.Cells["D2"].Value = "Unfavorable Price Variance";
- wsData.Cells["E2"].Value = "Pending";
- wsData.Cells["F2"].Value = 1;
-
- wsData.Cells["A3"].Value = Convert.ToDateTime("04/2/2012");
- wsData.Cells["B3"].Value = 43.14;
- wsData.Cells["C3"].Value = (-1.29);
- wsData.Cells["D3"].Value = "Unfavorable Price Variance";
- wsData.Cells["E3"].Value = "Pending";
- wsData.Cells["F3"].Value = 1;
-
- wsData.Cells["A4"].Value = Convert.ToDateTime("11/8/2011");
- wsData.Cells["B4"].Value = 55;
- wsData.Cells["C4"].Value = (-2.87);
- wsData.Cells["D4"].Value = "Unfavorable Price Variance";
- wsData.Cells["E4"].Value = "Pending";
- wsData.Cells["F4"].Value = 1;
-
- wsData.Cells["A5"].Value = Convert.ToDateTime("11/8/2011");
- wsData.Cells["B5"].Value = 38.72;
- wsData.Cells["C5"].Value = (-5.00);
- wsData.Cells["D5"].Value = "Unfavorable Price Variance";
- wsData.Cells["E5"].Value = "Pending";
- wsData.Cells["F5"].Value = 1;
-
- wsData.Cells["A6"].Value = Convert.ToDateTime("3/4/2011");
- wsData.Cells["B6"].Value = 77.44;
- wsData.Cells["C6"].Value = (-1.55);
- wsData.Cells["D6"].Value = "Unfavorable Price Variance";
- wsData.Cells["E6"].Value = "Pending";
- wsData.Cells["F6"].Value = 1;
-
- wsData.Cells["A7"].Value = Convert.ToDateTime("3/4/2011");
- wsData.Cells["B7"].Value = 127.55;
- wsData.Cells["C7"].Value = (-10.50);
- wsData.Cells["D7"].Value = "Unfavorable Price Variance";
- wsData.Cells["E7"].Value = "Pending";
- wsData.Cells["F7"].Value = 1;
-
- using (var range = wsData.Cells[2, 1, 7, 1])
- {
- range.Style.Numberformat.Format = "mm-dd-yy";
- }
-
- wsData.Cells.AutoFitColumns(0);
- EP.Save();
- }
- }
- private void BuildPivotTable1(FileInfo MyFile)
- {
- using (ExcelPackage ep = new ExcelPackage(MyFile))
- {
-
- var wsData = ep.Workbook.Worksheets["Data"];
- var totalRows = wsData.Dimension.Address;
- ExcelRange data = wsData.Cells[totalRows];
-
- var wsAuditPivot = ep.Workbook.Worksheets.Add("Pivot1");
-
- var pivotTable1 = wsAuditPivot.PivotTables.Add(wsAuditPivot.Cells["A7:C30"], data, "PivotAudit1");
- pivotTable1.ColumGrandTotals = true;
- var rowField = pivotTable1.RowFields.Add(pivotTable1.Fields["INVOICE_DATE"]);
-
-
- rowField.AddDateGrouping(eDateGroupBy.Years);
- var yearField = pivotTable1.Fields.GetDateGroupField(eDateGroupBy.Years);
- yearField.Name = "Year";
-
- var rowField2 = pivotTable1.RowFields.Add(pivotTable1.Fields["AUDIT_LINE_STATUS"]);
-
- var TotalSpend = pivotTable1.DataFields.Add(pivotTable1.Fields["TOTAL_INVOICE_PRICE"]);
- TotalSpend.Name = "Total Spend";
- TotalSpend.Format = "$##,##0";
-
-
- var CountInvoicePrice = pivotTable1.DataFields.Add(pivotTable1.Fields["COUNT"]);
- CountInvoicePrice.Name = "Total Lines";
- CountInvoicePrice.Format = "##,##0";
-
- pivotTable1.DataOnRows = false;
- ep.Save();
- ep.Dispose();
-
- }
-
- }
-
- private void BuildPivotTable2(FileInfo MyFile)
- {
- using (ExcelPackage ep = new ExcelPackage(MyFile))
- {
-
- var wsData = ep.Workbook.Worksheets["Data"];
- var totalRows = wsData.Dimension.Address;
- ExcelRange data = wsData.Cells[totalRows];
-
- var wsAuditPivot = ep.Workbook.Worksheets.Add("Pivot2");
-
- var pivotTable1 = wsAuditPivot.PivotTables.Add(wsAuditPivot.Cells["A7:C30"], data, "PivotAudit2");
- pivotTable1.ColumGrandTotals = true;
- var rowField = pivotTable1.RowFields.Add(pivotTable1.Fields["INVOICE_DATE"]);
-
-
- rowField.AddDateGrouping(eDateGroupBy.Years);
- var yearField = pivotTable1.Fields.GetDateGroupField(eDateGroupBy.Years);
- yearField.Name = "Year";
-
- var rowField2 = pivotTable1.RowFields.Add(pivotTable1.Fields["AUDIT_LINE_STATUS"]);
-
- var TotalSpend = pivotTable1.DataFields.Add(pivotTable1.Fields["TOTAL_INVOICE_PRICE"]);
- TotalSpend.Name = "Total Spend";
- TotalSpend.Format = "$##,##0";
-
-
- var CountInvoicePrice = pivotTable1.DataFields.Add(pivotTable1.Fields["COUNT"]);
- CountInvoicePrice.Name = "Total Lines";
- CountInvoicePrice.Format = "##,##0";
-
- pivotTable1.DataOnRows = false;
- ep.Save();
- ep.Dispose();
-
- }
-
- }
- [TestMethod, Ignore]
- public string Issue15247(DirectoryInfo outputDir)
- {
- FileInfo templateFile = new FileInfo(outputDir.FullName + @"\diagonal.xlsx");
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sampleDiagonal.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sampleDiagonal.xlsx");
- }
- using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
- {
- //Open worksheet 1
- ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
-
- Debug.WriteLine(worksheet.Cells["A1"].Style.Border.DiagonalUp);
- Debug.WriteLine(worksheet.Cells["A1"].Style.Border.DiagonalDown);
-
-
- //worksheet.Cells["A1"].Style.Border.DiagonalUp = true;
- //worksheet.Cells["A1"].Style.Border.DiagonalDown = true;
-
- // save our new workbook and we are done!
- package.Save();
- }
-
- return newFile.FullName;
- }
- [TestMethod, Ignore]
- public void issue15249()
- {
- using(var exfile=new ExcelPackage(new FileInfo(@"c:\temp\bug\Boldtextcopy.xlsx")))
- {
- exfile.Workbook.Worksheets.Copy("sheet1","copiedSheet");
- exfile.SaveAs(new FileInfo(@"c:\temp\bug\Boldtextcopy2.xlsx"));
- }
- }
- [TestMethod, Ignore]
- public void issue15300()
- {
- using (var exfile = new ExcelPackage(new FileInfo(@"c:\temp\bug\headfootpic.xlsx")))
- {
- exfile.Workbook.Worksheets.Copy("sheet1","copiedSheet");
- exfile.SaveAs(new FileInfo(@"c:\temp\bug\headfootpic_save.xlsx"));
- }
-
- }
- [TestMethod, Ignore]
- public void issue15295()
- {
- using (var exfile = new ExcelPackage(new FileInfo(@"C:\temp\bug\pivot issue\input.xlsx")))
- {
- exfile.SaveAs(new FileInfo(@"C:\temp\bug\pivot issue\pivotcoldup.xlsx"));
- }
-
- }
- [TestMethod, Ignore]
- public void issue15282()
- {
- using (var exfile = new ExcelPackage(new FileInfo(@"C:\temp\bug\pivottable-table.xlsx")))
- {
- exfile.SaveAs(new FileInfo(@"C:\temp\bug\pivot issue\pivottab-tab-save.xlsx"));
- }
-
- }
-
- [TestMethod, Ignore]
- public void Issues14699()
- {
- FileInfo newFile = new FileInfo(string.Format("c:\\temp\\bug\\EPPlus_Issue14699.xlsx", System.IO.Directory.GetCurrentDirectory()));
- OfficeOpenXml.ExcelPackage pkg = new ExcelPackage(newFile);
- ExcelWorksheet wksheet = pkg.Workbook.Worksheets.Add("Issue14699");
- // Initialize a small range
- for (int row = 1; row < 11; row++)
- {
- for (int col = 1; col < 11; col++)
- {
- wksheet.Cells[row, col].Value = string.Format("{0}{1}", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[col - 1], row);
- }
- }
- wksheet.View.FreezePanes(3, 3);
- pkg.Save();
-
- }
- }
-}
diff --git a/EPPlusTest/LoadFromCollectionTests.cs b/EPPlusTest/LoadFromCollectionTests.cs
deleted file mode 100644
index 322f265..0000000
--- a/EPPlusTest/LoadFromCollectionTests.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using OfficeOpenXml.Table;
-using Rhino.Mocks;
-using Rhino.Mocks.Constraints;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class LoadFromCollectionTests
- {
- internal abstract class BaseClass
- {
- public string Id { get; set; }
- public string Name { get; set; }
- }
-
- internal class Implementation : BaseClass
- {
- public int Number { get; set; }
- }
-
- internal class Aclass
- {
- public string Id { get; set; }
- public string Name { get; set; }
- public int Number { get; set; }
- }
-
- [TestMethod]
- public void ShouldUseAclassProperties()
- {
- var items = new List<Aclass>()
- {
- new Aclass(){ Id = "123", Name = "Item 1", Number = 3}
- };
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("sheet");
- sheet.Cells["C1"].LoadFromCollection(items, true, TableStyles.Dark1);
-
- Assert.AreEqual("Id", sheet.Cells["C1"].Value);
- }
- }
-
- [TestMethod]
- public void ShouldUseBaseClassProperties()
- {
- var items = new List<BaseClass>()
- {
- new Implementation(){ Id = "123", Name = "Item 1", Number = 3}
- };
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("sheet");
- sheet.Cells["C1"].LoadFromCollection(items, true, TableStyles.Dark1);
-
- Assert.AreEqual("Id", sheet.Cells["C1"].Value);
- }
- }
-
- [TestMethod]
- public void ShouldUseAnonymousProperties()
- {
- var objs = new List<BaseClass>()
- {
- new Implementation(){ Id = "123", Name = "Item 1", Number = 3}
- };
- var items = objs.Select(x => new {Id = x.Id, Name = x.Name}).ToList();
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("sheet");
- sheet.Cells["C1"].LoadFromCollection(items, true, TableStyles.Dark1);
-
- Assert.AreEqual("Id", sheet.Cells["C1"].Value);
- }
- }
- [TestMethod]
- [ExpectedException(typeof(InvalidCastException))]
- public void ShouldThrowInvalidCastExceptionIf()
- {
- var objs = new List<BaseClass>()
- {
- new Implementation(){ Id = "123", Name = "Item 1", Number = 3}
- };
- var items = objs.Select(x => new { Id = x.Id, Name = x.Name }).ToList();
- using (var pck = new ExcelPackage(new MemoryStream()))
- {
- var sheet = pck.Workbook.Worksheets.Add("sheet");
- sheet.Cells["C1"].LoadFromCollection(items, true, TableStyles.Dark1, BindingFlags.Public | BindingFlags.Instance, typeof(string).GetMembers());
-
- Assert.AreEqual("Id", sheet.Cells["C1"].Value);
- }
- }
- }
-}
diff --git a/EPPlusTest/Properties/AssemblyInfo.cs b/EPPlusTest/Properties/AssemblyInfo.cs
deleted file mode 100644
index cf12585..0000000
--- a/EPPlusTest/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-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("ExcelPackageTest")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("EPPlus Test")]
-[assembly: AssemblyCopyright("Copyright © Jan Källman")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM componenets. 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("917977d2-5b20-48e7-b01c-f5dbd9e76b99")]
-
-// 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 Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/EPPlusTest/Properties/Resources.Designer.cs b/EPPlusTest/Properties/Resources.Designer.cs
deleted file mode 100644
index d1cdd7b..0000000
--- a/EPPlusTest/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace EPPlusTest.Properties {
- using System;
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EPPlusTest.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- /// <summary>
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- /// </summary>
- internal static System.Drawing.Bitmap Test1 {
- get {
- object obj = ResourceManager.GetObject("Test1", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
- }
-}
diff --git a/EPPlusTest/Properties/Resources.resx b/EPPlusTest/Properties/Resources.resx
deleted file mode 100644
index fb13295..0000000
--- a/EPPlusTest/Properties/Resources.resx
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
- <data name="Test1" type="System.Resources.ResXFileRef, System.Windows.Forms">
- <value>..\Resources\Test1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
- </data>
-</root>
\ No newline at end of file
diff --git a/EPPlusTest/ReadTemplate.cs b/EPPlusTest/ReadTemplate.cs
deleted file mode 100644
index a9f0612..0000000
--- a/EPPlusTest/ReadTemplate.cs
+++ /dev/null
@@ -1,578 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.IO;
-using OfficeOpenXml.Drawing.Chart;
-using OfficeOpenXml.Style;
-using OfficeOpenXml.Drawing;
-using OfficeOpenXml.ConditionalFormatting;
-using System.Threading;
-using System.Drawing;
-namespace EPPlusTest
-{
- [TestClass]
- public class ReadTemplate //: TestBase
- {
- //[ClassInitialize()]
- //public static void ClassInit(TestContext testContext)
- //{
- // //InitBase();
- //}
- //[ClassCleanup()]
- //public static void ClassCleanup()
- //{
- // //SaveWorksheet("Worksheet.xlsx");
- //}
- [TestMethod]
- public void ReadBlankStream()
- {
- MemoryStream stream = new MemoryStream();
- using (ExcelPackage pck = new ExcelPackage(stream))
- {
- var ws = pck.Workbook.Worksheets.Add("Perf");
- pck.SaveAs(stream);
- }
- stream.Close();
- }
- [Ignore]
- [TestMethod]
- public void ReadBug()
- {
- var file = new FileInfo(@"c:\temp\Adenoviridae Protocol.xlsx");
- using (ExcelPackage pck = new ExcelPackage(file))
- {
- pck.Workbook.Worksheets[1].Cells["G4"].Value=12;
- pck.SaveAs(new FileInfo(@"c:\temp\Adenoviridae Protocol2.xlsx"));
- }
- }
- [Ignore]
- [TestMethod]
- public void ReadBug3()
- {
- ExcelPackage xlsPack = new ExcelPackage(new FileInfo(@"c:\temp\billing_template.xlsx"));
- ExcelWorkbook xlsWb = xlsPack.Workbook;
- ExcelWorksheet xlsSheet = xlsWb.Worksheets["Billing"];
- }
- [Ignore]
- [TestMethod]
- public void ReadBug2()
- {
- var file = new FileInfo(@"c:\temp\book2.xlsx");
- using (ExcelPackage pck = new ExcelPackage(file))
- {
- Assert.AreEqual("Good", pck.Workbook.Worksheets[1].Cells["A1"].StyleName);
- Assert.AreEqual("Good 2", pck.Workbook.Worksheets[1].Cells["C1"].StyleName);
- Assert.AreEqual("Note", pck.Workbook.Worksheets[1].Cells["G11"].StyleName);
- pck.SaveAs(new FileInfo(@"c:\temp\Adenoviridae Protocol2.xlsx"));
- }
- }
- [Ignore]
- [TestMethod]
- public void CondFormatDataValBug()
- {
- var file = new FileInfo(@"c:\temp\condi.xlsx");
- using (ExcelPackage pck = new ExcelPackage(file))
- {
- var dv = pck.Workbook.Worksheets[1].Cells["A1"].DataValidation.AddIntegerDataValidation();
- dv.Formula.Value = 1;
- dv.Formula2.Value = 4;
- dv.Operator = OfficeOpenXml.DataValidation.ExcelDataValidationOperator.equal;
- pck.SaveAs(new FileInfo(@"c:\temp\condi2.xlsx"));
- }
- }
- [Ignore]
- [TestMethod]
- public void InternalZip()
- {
- //var file = @"c:\temp\condi.xlsx";
- //using (ExcelPackage pck = new ExcelPackage(file))
- //{
- //}
- }
- [Ignore]
- [TestMethod]
- public void ReadBug4()
- {
- var lines = new List<string>();
- var package = new ExcelPackage(new FileInfo(@"c:\temp\test.xlsx"));
-
- ExcelWorkbook workBook = package.Workbook;
- if (workBook != null)
- {
- if (workBook.Worksheets.Count > 0) //fails on this line
- {
- // Get the first worksheet
- ExcelWorksheet currentWorksheet = workBook.Worksheets.First();
-
- var rowCount = 1;
- var lastRow = currentWorksheet.Dimension.End.Row;
- var lastColumn = currentWorksheet.Dimension.End.Column;
- while (rowCount <= lastRow)
- {
- var columnCount = 1;
- var line = "";
- while (columnCount <= lastColumn)
- {
- line += currentWorksheet.Cells[rowCount, columnCount].Value + "|";
- columnCount++;
- }
- lines.Add(line);
- rowCount++;
- }
- }
- }
- }
- [Ignore]
- [TestMethod]
- public void ReadBug5()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\2.9 bugs\protect.xlsx"));
-
- package.Workbook.Worksheets[1].Protection.AllowInsertColumns = true;
- package.Workbook.Worksheets[1].Protection.SetPassword("test");
- package.SaveAs(new FileInfo(@"c:\temp\2.9 bugs\protectnew.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug6()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\2.9 bugs\outofrange\error.xlsx"));
-
- package.Workbook.Worksheets[1].Protection.AllowInsertColumns = true;
- package.Workbook.Worksheets[1].Protection.SetPassword("test");
- package.SaveAs(new FileInfo(@"c:\temp\2.9 bugs\error.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug7()
- {
- var package = new ExcelPackage();
- var ws = package.Workbook.Worksheets.Add("test");
- using (var rng = ws.Cells["A1"])
- {
- var rt1 = rng.RichText.Add("TEXT1\r\n");
- rt1.Bold = true;
- rng.Style.WrapText = true;
- var rt2=rng.RichText.Add("TEXT2");
- rt2.Bold = false;
- }
-
- package.SaveAs(new FileInfo(@"c:\temp\2.9 bugs\error.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug8()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\2.9 bugs\bug\Genband SO CrossRef Phoenix.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- using (var rng = ws.Cells["A1"])
- {
- var rt1 = rng.RichText.Add("TEXT1\r\n");
- rt1.Bold = true;
- rng.Style.WrapText = true;
- var rt2 = rng.RichText.Add("TEXT2");
- rt2.Bold = false;
- }
-
- package.SaveAs(new FileInfo(@"c:\temp\2.9 bugs\billing_template.xlsx.error"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug9()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\CovenantsCheckReportTemplate.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- package.SaveAs(new FileInfo(@"c:\temp\2.9 bugs\new_t.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug10()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\Model_graphes_MBW.xlsm"));
-
- var ws = package.Workbook.Worksheets["HTTP_data"];
- Assert.IsNotNull(ws.Cells["B4"].Style.Fill.BackgroundColor.Indexed);
- Assert.IsNotNull(ws.Cells["B5"].Style.Fill.BackgroundColor.Indexed);
- }
- [Ignore]
- [TestMethod]
- public void ReadBug11()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\sample.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- var pck2 = new ExcelPackage();
- pck2.Workbook.Worksheets.Add("Test", ws);
- pck2.SaveAs(new FileInfo(@"c:\temp\SampleNew.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadConditionalFormatting()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\cf2.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- ws.Cells["A1"].Value = 1;
- Assert.AreEqual(ws.ConditionalFormatting[6].Type, eExcelConditionalFormattingRuleType.Equal);
- package.SaveAs(new FileInfo(@"c:\temp\condFormTest.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadStyleBug()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\acquisitions-1993-2.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- ws.Cells["A1"].Value = 1;
- package.SaveAs(new FileInfo(@"c:\temp\condFormTest.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadURL()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\url.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- ws.Cells["A1"].Value = 1;
- package.SaveAs(new FileInfo(@"c:\temp\condFormTest.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadNameError()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\names2.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- ws.Cells["A1"].Value = 1;
- package.SaveAs(new FileInfo(@"c:\temp\TestTableSave.xlsx"));
- }
- [TestMethod, Ignore]
- public void ReadBug12()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\test4.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- ws.Cells["A1"].Value = 1;
- //ws.Column(0).Style.Font.Bold = true;
- package.SaveAs(new FileInfo(@"c:\temp\bug2.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug13()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\original.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- package.Workbook.Calculate(new OfficeOpenXml.FormulaParsing.ExcelCalculationOption() { AllowCirculareReferences = true });
- package.SaveAs(new FileInfo(@"c:\temp\bug2.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug14()
- {
- var package = new ExcelPackage();
- var ws = package.Workbook.Worksheets.Add("Comment");
- ws.Cells["A1"].AddComment("Test av kommentar", "J");
- ws.Comments.RemoveAt(0);
- package.SaveAs(new FileInfo(@"c:\temp\bug\CommentTest.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug15()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\ColumnMaxError.xlsx"));
- var ws = package.Workbook.Worksheets[1];
- var col = ws.Column(1);
- col.Style.Fill.PatternType = ExcelFillStyle.Solid;
- col.Style.Fill.BackgroundColor.SetColor(Color.Red);
- package.SaveAs(new FileInfo(@"c:\temp\bug2.xlsx"));
- }
- #region "Threading Cellstore Test"
- public int _threadCount=0;
- ExcelPackage _pckThread;
- [TestMethod, Ignore]
- public void ThreadingTest()
- {
- _pckThread = new ExcelPackage();
- var ws = _pckThread.Workbook.Worksheets.Add("Threading");
-
- for (int t = 0; t < 20; t++)
- {
- var ts=new ThreadState(Finnished)
- {
- ws=ws,
- StartRow=1+(t*1000),
- Rows=1000,
- };
- var tstart=new ThreadStart(ts.StartLoad);
- var thread = new Thread(tstart);
- _threadCount++;
- thread.Start();
- }
- while (1 == 1)
- {
- if (_threadCount == 0)
- {
- _pckThread.SaveAs(new FileInfo("c:\\temp\\thread.xlsx"));
- break;
- }
- Thread.Sleep(1000);
- }
- }
- public void Finnished()
- {
- _threadCount--;
- }
- private class ThreadState
- {
- public ThreadState(cbFinished cb)
- {
- _cb = cb;
- }
- public ExcelWorksheet ws { get; set; }
- public int StartRow { get; set; }
- public int Rows { get; set; }
- public delegate void cbFinished();
- public cbFinished _cb;
- public void StartLoad()
- {
- for(int row=StartRow;row<StartRow+Rows;row++)
- {
- for (int col = 1; col < 100; col++)
- {
- ws.SetValue(row,col,string.Format("row {0} col {1}", row,col));
- }
- }
- _cb();
- }
- }
- #endregion
- [Ignore]
- [TestMethod]
- public void TestInvalidVBA()
- {
- const string infile=@"C:\temp\bug\Infile.xlsm";
- const string outfile=@"C:\temp\bug\Outfile.xlsm";
- ExcelPackage ep;
-
- using (FileStream fs = File.OpenRead(infile))
- {
- ep = new ExcelPackage(fs);
- }
-
- using (FileStream fs = File.OpenWrite(outfile))
- {
- ep.SaveAs(fs);
- }
-
- using (FileStream fs = File.OpenRead(outfile))
- {
- ep = new ExcelPackage(fs);
- }
-
- using (FileStream fs = File.OpenWrite(outfile))
- {
- ep.SaveAs(fs);
- }
- }
- [Ignore]
- [TestMethod]
- public void StreamTest()
- {
- using (var templateStream = File.OpenRead(@"c:\temp\thread.xlsx"))
- {
-
- using (var outStream = File.Open(@"c:\temp\streamOut.xlsx", FileMode.Create, FileAccess.ReadWrite, FileShare.None))
- {
- using (var package = new ExcelPackage(outStream, templateStream))
- {
- package.Workbook.Worksheets[1].Cells["A1"].Value = 1;
- // Create more content
- package.Save();
- }
- }
- }
- }
- [TestMethod, Ignore]
- public void test()
- {
- CreateXlsxSheet(@"C:\temp\bug\test4.xlsx", 4, 4);
- CreateXlsxSheet(@"C:\temp\bug\test25.xlsx", 25, 25);
- }
- [Ignore]
- [TestMethod]
- public void I15038()
- {
- using(var p = new ExcelPackage(new FileInfo(@"c:\temp\bug\15038.xlsx")))
- {
- var ws=p.Workbook.Worksheets[1];
-
- }
- }
- [Ignore]
- [TestMethod]
- public void I15039()
- {
- using (var p = new ExcelPackage(new FileInfo(@"c:\temp\bug\15039.xlsm")))
- {
- var ws = p.Workbook.Worksheets[1];
-
- p.SaveAs(new FileInfo(@"c:\temp\bug\15039-saved.xlsm"));
- }
- }
- [Ignore]
- [TestMethod]
- public void I15030()
- {
- using (var newPack = new ExcelPackage(new FileInfo(@"c:\temp\bug\I15030.xlsx")))
- {
- var wkBk = newPack.Workbook.Worksheets[1];
- var cell = wkBk.Cells["A1"];
- if (cell.Comment != null)
- {
- cell.Comment.Text = "Hello edited comments";
- }
- newPack.SaveAs(new FileInfo(@"c:\temp\bug\15030-save.xlsx"));
- }
- }
- [Ignore]
- [TestMethod]
- public void I15014()
- {
- using (var p = new ExcelPackage(new FileInfo(@"c:\temp\bug\ClassicWineCompany.xlsx")))
- {
- var ws = p.Workbook.Worksheets[1];
- Assert.AreEqual("SFFSectionHeading00", ws.Cells[5, 2].StyleName);
- }
- }
- [Ignore]
- [TestMethod]
- public void I15043()
- {
- using (var p = new ExcelPackage(new FileInfo(@"C:\temp\bug\EPPlusTest\EPPlusTest\EPPlusTest\example.xlsx")))
- {
- var ws = p.Workbook.Worksheets[1];
- p.Workbook.Worksheets.Copy(ws.Name, "Copy");
- }
- }
- [TestMethod, Ignore]
- public void whitespace()
- {
- using (var p = new ExcelPackage(new FileInfo(@"C:\temp\bug\GridToExcel_05-12-2014.xlsx")))
- {
- var ws = p.Workbook.Worksheets[1];
- foreach (var cell in ws.Cells[1,84,3,86])
- {
- Console.WriteLine(cell.Address);
- }
- }
- }
- [TestMethod, Ignore]
- public void SaveCorruption()
- {
- using (var p = new ExcelPackage(new FileInfo(@"C:\temp\bug\tables.xlsx")))
- {
- var ws = p.Workbook.Worksheets[1];
- p.SaveAs(new FileInfo(@"c:\temp\bug\corr.xlsx"));
- }
- }
- [TestMethod]
- public void VBAerror()
- {
- ExcelWorksheet ws;
- using (var p = new ExcelPackage())
- {
- p.Workbook.CreateVBAProject();
- ws = p.Workbook.Worksheets.Add("Градуировка");
- using (var p2 = new ExcelPackage())
- {
- p2.Workbook.CreateVBAProject();
- var ws2 = p2.Workbook.Worksheets.Add("Градуировка2", ws);
- }
- }
- }
-
- [TestMethod, Ignore]
- public void CopyIssue()
- {
- using (var pkg = new ExcelPackage())
- {
- var templateFile = ReadTemplateFile(@"C:\temp\bug\StackOverflow\EPPlusTest\20141120_01_3.各股累計收結表 (其他案件).xlsx");
- using (var ms = new System.IO.MemoryStream(templateFile))
- {
- using (var tempPkg = new ExcelPackage(ms))
- {
- pkg.Workbook.Worksheets.Add("20141120_01_3.各股累計收結表 (其他案件)", tempPkg.Workbook.Worksheets.First());
- }
- }
- }
- }
- [TestMethod, Ignore]
- public void FileStreamSave()
- {
- var fs = File.Create(@"c:\temp\fs.xlsx");
- using (var pkg = new ExcelPackage(fs))
- {
- var ws=pkg.Workbook.Worksheets.Add("test");
- ws.Cells["A1"].Value = 1;
- var col=ws.Column(1);
- col.OutlineLevel = 1;
- col.ColumnMax = ExcelPackage.MaxColumns;
- col.ColumnMax = 1;
- pkg.Save();
- }
- }
- public static byte[] ReadTemplateFile(string templateName)
- {
- byte[] templateFIle;
- using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
- {
- using (var sw = new System.IO.FileStream(templateName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
- {
- byte[] buffer = new byte[2048];
- int bytesRead;
- while ((bytesRead = sw.Read(buffer, 0, buffer.Length)) > 0)
- {
- ms.Write(buffer, 0, bytesRead);
- }
- }
- ms.Position = 0;
- templateFIle = ms.ToArray();
- }
- return templateFIle;
- }
-
- private static void CreateXlsxSheet(string pFileName, int pRows, int pColumns)
- {
- if (File.Exists(pFileName)) File.Delete(pFileName);
-
- using (ExcelPackage excelPackage = new ExcelPackage(new FileInfo(pFileName)))
- {
- ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets.Add("Testsheet");
-
- // Fill with data
- for (int row = 1; row <= pRows; row++)
- {
- for (int column = 1; column <= pColumns; column++)
- {
- if (column > 1 && row > 2)
- {
- using (ExcelRange range = excelWorksheet.Cells[row, column])
- {
- range.Style.Numberformat.Format = "0";
- range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
- range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
- }
- excelWorksheet.Cells[row, column].Value = row * column;
- }
- }
- }
-
- // Try to style the first column, begining with row 3 which has no content yet...
- using (ExcelRange range = excelWorksheet.Cells[ExcelCellBase.GetAddress(3, 1, pRows, 1)])
- {
- ExcelStyle style = range.Style;
- }
-
- // now I would add data to the first column (left out here)...
- excelPackage.Save();
- }
- }
- }
-}
diff --git a/EPPlusTest/Resources/BitmapImage.gif b/EPPlusTest/Resources/BitmapImage.gif
deleted file mode 100644
index a6f341f..0000000
--- a/EPPlusTest/Resources/BitmapImage.gif
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/Resources/Test1.jpg b/EPPlusTest/Resources/Test1.jpg
deleted file mode 100644
index 4c5feff..0000000
--- a/EPPlusTest/Resources/Test1.jpg
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/Resources/Vector Drawing.wmf b/EPPlusTest/Resources/Vector Drawing.wmf
deleted file mode 100644
index 5825aeb..0000000
--- a/EPPlusTest/Resources/Vector Drawing.wmf
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/Resources/Vector Drawing2.wmf b/EPPlusTest/Resources/Vector Drawing2.wmf
deleted file mode 100644
index cbdeefa..0000000
--- a/EPPlusTest/Resources/Vector Drawing2.wmf
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/StyleTest.cs b/EPPlusTest/StyleTest.cs
deleted file mode 100644
index f473180..0000000
--- a/EPPlusTest/StyleTest.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.Style;
-using OfficeOpenXml.Style.XmlAccess;
-using System.Globalization;
-using OfficeOpenXml;
-using System.IO;
-using System.Diagnostics;
-
-namespace ExcelPackageTest
-{
- [TestClass]
- public class StyleTest
- {
- [TestMethod]
- public void GetStyles()
- {
- ExcelPackage pck = new ExcelPackage(new FileInfo("c:\\temp\\formats.xlsx"));
-
- foreach (var cell in pck.Workbook.Worksheets[1].Cells["A:X"])
- {
- Debug.WriteLine(cell.Text);
- }
- }
- [TestMethod]
- public void TestFraction()
- {
- //string f = ExcelNumberFormatXml.FormatFraction(0.25, 2);
-
- //f = ExcelNumberFormatXml.FormatFraction(0.333, 2);
- //f = ExcelNumberFormatXml.FormatFraction(-0.888, 2);
- //f = ExcelNumberFormatXml.FormatFraction(-0.272471, 3);
- //f = ExcelNumberFormatXml.FormatFraction(0.666666, 4);
- //f = ExcelNumberFormatXml.FormatFraction(0.21, 4);
- //f = ExcelNumberFormatXml.FormatFraction(0.09999, 3);
- //f = ExcelNumberFormatXml.FormatFraction(0, 3);
-
- }
-
- }
-}
diff --git a/EPPlusTest/TestBase.cs b/EPPlusTest/TestBase.cs
deleted file mode 100644
index ebae210..0000000
--- a/EPPlusTest/TestBase.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.IO;
-using System.Reflection;
-
-namespace EPPlusTest
-{
- [TestClass]
- public abstract class TestBase
- {
- protected ExcelPackage _pck;
- protected string _clipartPath="";
- protected string _worksheetPath="";
- public TestContext TestContext { get; set; }
-
- [TestInitialize]
- public void InitBase()
- {
-
- _clipartPath = Path.Combine(Path.GetTempPath(), @"EPPlus clipart");
- if (!Directory.Exists(_clipartPath))
- {
- Directory.CreateDirectory(_clipartPath);
- }
- var asm = Assembly.GetExecutingAssembly();
- var validExtensions = new[]
- {
- ".gif", ".wmf"
- };
- foreach (var name in asm.GetManifestResourceNames())
- {
- foreach (var ext in validExtensions)
- {
- if (name.EndsWith(ext, StringComparison.InvariantCultureIgnoreCase))
- {
- string fileName = name.Replace("EPPlusTest.Resources.", "");
- using (var stream = asm.GetManifestResourceStream(name))
- using (var file = File.Create(Path.Combine(_clipartPath, fileName)))
- {
- stream.CopyTo(file);
- }
- break;
- }
- }
- }
- _worksheetPath = Path.Combine(Path.GetTempPath(), @"EPPlus worksheets");
- if (!Directory.Exists(_worksheetPath))
- {
- Directory.CreateDirectory(_worksheetPath);
- }
- var di=new DirectoryInfo(_worksheetPath);
- _worksheetPath = di.FullName + "\\";
-
- _pck = new ExcelPackage();
- }
-
- protected void OpenPackage(string name)
- {
- var fi = new FileInfo(_worksheetPath + name);
- _pck = new ExcelPackage(fi);
- }
-
- protected void SaveWorksheet(string name)
- {
- if (_pck.Workbook.Worksheets.Count == 0) return;
- var fi = new FileInfo(_worksheetPath + name);
- if (fi.Exists)
- {
- fi.Delete();
- }
- _pck.SaveAs(fi);
- }
- }
-}
diff --git a/EPPlusTest/TestDTO.cs b/EPPlusTest/TestDTO.cs
deleted file mode 100644
index 0b8c608..0000000
--- a/EPPlusTest/TestDTO.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-
-namespace EPPlusTest
-{
- public class TestDTO
- {
- public string NameVar;
-
- public int Id { get; set; }
- [DisplayName("Name from DisplayNameAttribute")]
- public string Name { get; set; }
- public TestDTO dto { get; set; }
- public DateTime Date { get; set; }
- public bool Boolean { get; set; }
-
- public string GetNameID()
- {
- return Id + "," + Name;
- }
- }
-}
diff --git a/EPPlusTest/TestStart.orderedtest b/EPPlusTest/TestStart.orderedtest
deleted file mode 100644
index 5dd2ff3..0000000
--- a/EPPlusTest/TestStart.orderedtest
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<OrderedTest name="TestStart" storage="c:\devexternal\epplus\epplustest\teststart.orderedtest" id="e7599e2e-436a-46b2-af22-96fff26346d3" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
- <Execution timeOut="2147483647" id="d30919a1-3c12-43fd-bc5c-90d934ef0c15" />
- <TestLinks>
- <TestLink id="ec8c7cb6-bb68-0b2d-336e-e7ad6498dfbc" name="BarChart" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="a33567b0-0f74-3c22-6057-3ac9404b4afe" name="Column" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="64f8deed-8a5d-3c26-0d6c-c8a852755f52" name="Cone" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="a3230386-4e1b-0dc0-8f28-492865627a9d" name="Dougnut" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="e604a447-5d31-c6d1-944d-68f8d3e36b7d" name="Drawings" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="e9c8d19a-f0f2-6eaa-fbce-803a8e32285b" name="Line" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="5b2f832b-2e6d-d8fe-fe8b-6300244e9c53" name="LineMarker" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="c3c4daa7-f5c5-0aa7-0852-1396552ef478" name="Picture" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="2d591a92-b4bc-a5f8-aec1-83528ca9915e" name="PieChart" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="884cc48b-b7b1-6b1a-5735-eb99caedbfb8" name="PieChart3D" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="6edd6a26-ed80-d0ae-626e-36eefe6eef76" name="Pyramid" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="cf236ce0-637d-eaec-285b-57a4c47c1507" name="Scatter" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="84891996-d4dd-d531-652c-f4362479038e" name="Bubble" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="b404ec6e-92d3-0235-c6c1-7d7992945dff" name="Radar" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="fb781454-a2f0-2aa9-aebf-05622e75874f" name="Surface" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="5c8ae3d5-ff0e-6c9a-be31-2b8a8a68485c" name="Line2Test" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="9015e369-6656-4d77-7f5c-803fe25b6927" name="MultiChartSeries" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="0c0a324c-112c-69d6-8eac-2347ac825b2f" name="DrawingSizingAndPositioning" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="2afc147e-d938-8893-8126-86267bf8f258" name="DrawingWorksheetCopy" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="2f14774c-49ee-bed7-12a8-86dd3092d74f" name="DeleteDrawing" storage="bin\release\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="d267979a-22ac-f737-d9a2-ef208a49ece4" name="ReadDocument" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="dc04a693-576c-fb42-70f0-9145c5509b88" name="InsertDeleteTest" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="b89e13a0-b193-90b5-e27e-c0383ea48090" name="LoadData" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="00b10a5f-8a6b-fc5a-9369-a134d40c69a0" name="StyleFill" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="3388392f-cb18-638e-ec3d-0e4e4bcb0f00" name="Performance" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="1fc0c972-dd82-b3ca-74da-f4b72b90a42d" name="RichTextCells" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="a7e864f6-c6d2-d636-2160-4cfd54acd24b" name="TestComments" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="d5bfe553-e74e-f9b3-737f-4a6c03fd1a01" name="Hyperlink" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="49e2c4cc-ce16-5277-7f3d-b87fb0539009" name="PictureURL" storage="bin\release\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="7fbf50ba-cc00-616f-46ef-3b85477a0a64" name="CopyOverwrite" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="6dce9d28-9c05-b525-20f6-920af5a19f20" name="HideTest" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="fbb3bb6d-f72c-0d02-9382-9c581d7cd4d0" name="VeryHideTest" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="287b35d5-2bab-49ba-3533-ca426c6ad34f" name="PrinterSettings" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="c2d0fb47-e112-79f9-90ef-dd482009ca9c" name="Address" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="b888edc6-5858-7e71-c6cc-68eb526becda" name="Merge" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="55cc15c8-cff8-9d91-22b2-ed8f4db67a11" name="Encoding" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="fa633908-8985-41d8-e3cb-1806d035b17f" name="LoadText" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="7281a0f7-4d4a-87f9-f76e-9c20c09a102f" name="LoadDataTable" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="a97e820f-e604-8bc8-3030-24422e6f199f" name="WorksheetCopy" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="7c0d8f0e-bb6f-acef-3b93-780c45337117" name="DefaultColWidth" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="5deac1c9-49ef-1292-b2c5-53592270c24d" name="CopyTable" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="bc823602-605d-2701-c455-7f410b8e2d17" name="AutoFitColumns" storage="bin\release\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="8d7eb3e1-bd21-c466-c058-04e9db4b992d" name="CopyRange" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="30005b5f-84fd-7875-4bc7-184dbac4bbfa" name="CopyMergedRange" storage="bin\release\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="6b043069-4785-93ec-210f-209027b795ce" name="ValueError" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="7ccff273-a98f-ba5f-2165-442cb79806f3" name="DefColWidthBug" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="df923349-6b30-107d-6d38-0709efbceace" name="FormulaOverwrite" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="9e449a60-30bd-600b-df4b-1e8c4eb4cf06" name="FormulaError" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="ed7c33f0-ed95-b189-f7be-58894dae6cd5" name="StyleNameTest" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="7a5ebbe9-5446-24da-1de4-5b40268331ad" name="NamedStyles" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="a07b4b8b-a2a1-77ae-e017-d17783671819" name="TableTest" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="3e7ca5c7-6075-09e7-7659-6c32ec482e67" name="LoadArray" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="684c147e-50b0-c9c5-2f87-f4ba26894d83" name="DefinedName" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="dd3dd09e-5a44-4a34-5adf-32a6606c0843" name="CreatePivotTable" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="31983008-437f-706b-6c24-7f6125d45932" name="SetBackground" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="b5ebf51b-88b0-71d5-6aaa-3a815ea41055" name="CopyPivotTable" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="191a41ec-226a-e241-361a-c8b9e87d5e71" name="LoadFromCollectionTest" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="ee8713a1-eac2-f669-7402-ace06164fefa" name="SetHeaderFooterImage" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="0669b111-1520-8edd-d19a-ad943e4a7784" name="ReadStreamSaveAsStream" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="0ec9eb96-c3f9-9233-e302-1a770c1f93cc" name="ReadWorkSheet" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="41afaad2-75a1-a0c2-0711-2027bdce01cc" name="ReadDrawing" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="4365de8b-a0bb-05ab-1b9c-e25e8d9f68da" name="ReadWriteEncrypt" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="bc71bc5a-9346-4b7f-8c08-95dabba08390" name="ReadStreamWithTemplateWorkSheet" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="30769c2e-3028-60cd-c8bf-1191cdc4d744" name="ShouldBeAbleToDeleteAndThenAdd" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="d16f1750-e957-c5a1-146c-5a99bca7d58c" name="TwoBackColor" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="84a8ad78-922e-3d78-6b4c-ee576541ee98" name="TwoColorScale" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="341db1b7-a273-78d3-03b9-f1040a96556d" name="IconSet" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="034c5b13-0742-c66f-06d0-e031ec63bd26" name="Databar" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="bd483e75-6ada-9dae-662e-0920965226b1" name="DeleteByNameWhereWorkSheetExists" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="dda92b4a-de73-0629-9946-251f1e488278" name="DeleteByNameWhereWorkSheetDoesNotExist" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="60305f96-acc5-ca54-ffe0-836449c7cabc" name="MoveBeforeByNameWhereWorkSheetExists" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="c72be5f6-34f8-d825-898e-52c5e0d36620" name="MoveAfterByNameWhereWorkSheetExists" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <TestLink id="dc48ec47-15c1-323b-3509-010d4350ae45" name="MoveBeforeByPositionWhereWorkSheetExists" storage="bin\debug\epplustest.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- </TestLinks>
-</OrderedTest>
\ No newline at end of file
diff --git a/EPPlusTest/Utils/AddressUtilityTests.cs b/EPPlusTest/Utils/AddressUtilityTests.cs
deleted file mode 100644
index da639e6..0000000
--- a/EPPlusTest/Utils/AddressUtilityTests.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.Utils;
-using OfficeOpenXml;
-
-namespace EPPlusTest.Utils
-{
- [TestClass]
- public class AddressUtilityTests
- {
- [TestMethod]
- public void ParseForEntireColumnSelections_ShouldAddMaxRows()
- {
- // Arrange
- var address = "A:A";
-
- // Act
- var result = AddressUtility.ParseEntireColumnSelections(address);
-
- // Assert
- Assert.AreEqual("A1:A" + ExcelPackage.MaxRows, result);
- }
-
- [TestMethod]
- public void ParseForEntireColumnSelections_ShouldAddMaxRowsOnColumnsWithMultipleLetters()
- {
- // Arrange
- var address = "AB:AC";
-
- // Act
- var result = AddressUtility.ParseEntireColumnSelections(address);
-
- // Assert
- Assert.AreEqual("AB1:AC" + ExcelPackage.MaxRows, result);
- }
-
- [TestMethod]
- public void ParseForEntireColumnSelections_ShouldHandleMultipleRanges()
- {
- // Arrange
- var address = "A:A B:B";
- var expected = string.Format("A1:A{0} B1:B{0}", ExcelPackage.MaxRows);
-
- // Act
- var result = AddressUtility.ParseEntireColumnSelections(address);
-
- // Assert
- Assert.AreEqual(expected, result);
- }
- }
-}
diff --git a/EPPlusTest/Utils/ConvertUtilTest.cs b/EPPlusTest/Utils/ConvertUtilTest.cs
deleted file mode 100644
index b83e9c3..0000000
--- a/EPPlusTest/Utils/ConvertUtilTest.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Globalization;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.Utils;
-
-namespace EPPlusTest.Utils
-{
- [TestClass]
- public class ConvertUtilTest
- {
- [TestMethod]
- public void TryParseNumericString()
- {
- double result;
- object numericString = null;
- double expected = 0;
- Assert.IsFalse(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- expected = 1442.0;
- numericString = expected.ToString("e", CultureInfo.CurrentCulture); // 1.442E+003
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- numericString = expected.ToString("f0", CultureInfo.CurrentCulture); // 1442
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- numericString = expected.ToString("f2", CultureInfo.CurrentCulture); // 1442.00
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- numericString = expected.ToString("n", CultureInfo.CurrentCulture); // 1,442.0
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- expected = -0.00526;
- numericString = expected.ToString("e", CultureInfo.CurrentCulture); // -5.26E-003
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- numericString = expected.ToString("f0", CultureInfo.CurrentCulture); // -0
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(0.0, result);
- numericString = expected.ToString("f3", CultureInfo.CurrentCulture); // -0.005
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(-0.005, result);
- numericString = expected.ToString("n6", CultureInfo.CurrentCulture); // -0.005260
- Assert.IsTrue(ConvertUtil.TryParseNumericString(numericString, out result));
- Assert.AreEqual(expected, result);
- }
-
- [TestMethod]
- public void TryParseDateString()
- {
- DateTime result;
- object dateString = null;
- DateTime expected = DateTime.MinValue;
- Assert.IsFalse(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(expected, result);
- expected = new DateTime(2013, 1, 15);
- dateString = expected.ToString("d", CultureInfo.CurrentCulture); // 1/15/2013
- Assert.IsTrue(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(expected, result);
- dateString = expected.ToString("D", CultureInfo.CurrentCulture); // Tuesday, January 15, 2013
- Assert.IsTrue(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(expected, result);
- dateString = expected.ToString("F", CultureInfo.CurrentCulture); // Tuesday, January 15, 2013 12:00:00 AM
- Assert.IsTrue(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(expected, result);
- dateString = expected.ToString("g", CultureInfo.CurrentCulture); // 1/15/2013 12:00 AM
- Assert.IsTrue(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(expected, result);
- expected = new DateTime(2013, 1, 15, 15, 26, 32);
- dateString = expected.ToString("F", CultureInfo.CurrentCulture); // Tuesday, January 15, 2013 3:26:32 PM
- Assert.IsTrue(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(expected, result);
- dateString = expected.ToString("g", CultureInfo.CurrentCulture); // 1/15/2013 3:26 PM
- Assert.IsTrue(ConvertUtil.TryParseDateString(dateString, out result));
- Assert.AreEqual(new DateTime(2013, 1, 15, 15, 26, 0), result);
- }
- }
-}
diff --git a/EPPlusTest/Utils/GuardingTests.cs b/EPPlusTest/Utils/GuardingTests.cs
deleted file mode 100644
index a967f99..0000000
--- a/EPPlusTest/Utils/GuardingTests.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.Utils;
-
-namespace EPPlusTest.Utils
-{
- [TestClass]
- public class GuardingTests
- {
- private class TestClass
- {
-
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void Require_IsNotNull_ShouldThrowIfArgumentIsNull()
- {
- TestClass obj = null;
- Require.Argument(obj).IsNotNull("test");
- }
-
- [TestMethod]
- public void Require_IsNotNull_ShouldNotThrowIfArgumentIsAnInstance()
- {
- var obj = new TestClass();
- Require.Argument(obj).IsNotNull("test");
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void Require_IsNotNullOrEmpty_ShouldThrowIfStringIsNull()
- {
- string arg = null;
- Require.Argument(arg).IsNotNullOrEmpty("test");
- }
-
- [TestMethod]
- public void Require_IsNotNullOrEmpty_ShouldNotThrowIfStringIsNotNullOrEmpty()
- {
- string arg = "test";
- Require.Argument(arg).IsNotNullOrEmpty("test");
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void Require_IsInRange_ShouldThrowIfArgumentIsOutOfRange()
- {
- int arg = 3;
- Require.Argument(arg).IsInRange(5, 7, "test");
- }
-
- [TestMethod]
- public void Require_IsInRange_ShouldNotThrowIfArgumentIsInRange()
- {
- int arg = 6;
- Require.Argument(arg).IsInRange(5, 7, "test");
- }
- }
-}
diff --git a/EPPlusTest/Utils/SqRefUtilityTests.cs b/EPPlusTest/Utils/SqRefUtilityTests.cs
deleted file mode 100644
index 052f98e..0000000
--- a/EPPlusTest/Utils/SqRefUtilityTests.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.Utils;
-
-namespace EPPlusTest.Utils
-{
- [TestClass]
- public class SqRefUtilityTests
- {
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void SqRefUtility_ToSqRefAddress_ShouldThrowIfAddressIsNullOrEmpty()
- {
- SqRefUtility.ToSqRefAddress(null);
- }
-
- [TestMethod]
- public void SqRefUtility_ToSqRefAddress_ShouldRemoveCommas()
- {
- // Arrange
- var address = "A1, A2:A3";
-
- // Act
- var result = SqRefUtility.ToSqRefAddress(address);
-
- // Assert
- Assert.AreEqual("A1 A2:A3", result);
- }
-
-
- [TestMethod]
- public void SqRefUtility_ToSqRefAddress_ShouldRemoveCommasAndInsertSpaceIfNecesary()
- {
- // Arrange
- var address = "A1,A2:A3";
-
- // Act
- var result = SqRefUtility.ToSqRefAddress(address);
-
- // Assert
- Assert.AreEqual("A1 A2:A3", result);
- }
-
- [TestMethod]
- public void SqRefUtility_ToSqRefAddress_ShouldRemoveMultipleSpaces()
- {
- // Arrange
- var address = "A1, A2:A3";
-
- // Act
- var result = SqRefUtility.ToSqRefAddress(address);
-
- // Assert
- Assert.AreEqual("A1 A2:A3", result);
- }
-
- [TestMethod]
- public void SqRefUtility_FromSqRefAddress_ShouldReplaceSpaceWithComma()
- {
- // Arrange
- var address = "A1 A2";
-
- // Act
- var result = SqRefUtility.FromSqRefAddress(address);
-
- // Assert
- Assert.AreEqual("A1,A2", result);
- }
- }
-}
diff --git a/EPPlusTest/VBA.cs b/EPPlusTest/VBA.cs
deleted file mode 100644
index ca71265..0000000
--- a/EPPlusTest/VBA.cs
+++ /dev/null
@@ -1,220 +0,0 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml.Utils;
-using OfficeOpenXml;
-using System.Security.Cryptography.X509Certificates;
-using System.IO;
-using System.Security.Cryptography;
-using OfficeOpenXml.VBA;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class VBA
- {
-#if !MONO
- [TestMethod]
- public void Compression()
- {
- //Compression/Decompression
- string value = "#aaabcdefaaaaghijaaaaaklaaamnopqaaaaaaaaaaaarstuvwxyzaaa";
-
- byte[] compValue = CompoundDocument.CompressPart(Encoding.GetEncoding(1252).GetBytes(value));
- string decompValue = Encoding.GetEncoding(1252).GetString(CompoundDocument.DecompressPart(compValue));
- Assert.AreEqual(value, decompValue);
-
- value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
-
- compValue = CompoundDocument.CompressPart(Encoding.GetEncoding(1252).GetBytes(value));
- decompValue = Encoding.GetEncoding(1252).GetString(CompoundDocument.DecompressPart(compValue));
- Assert.AreEqual(value, decompValue);
- }
-#endif
- [Ignore]
- [TestMethod]
- public void ReadVBA()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\report.xlsm"));
- File.WriteAllText(@"c:\temp\vba\modules\dir.txt", package.Workbook.VbaProject.CodePage + "," + package.Workbook.VbaProject.Constants + "," + package.Workbook.VbaProject.Description + "," + package.Workbook.VbaProject.HelpContextID.ToString() + "," + package.Workbook.VbaProject.HelpFile1 + "," + package.Workbook.VbaProject.HelpFile2 + "," + package.Workbook.VbaProject.Lcid.ToString() + "," + package.Workbook.VbaProject.LcidInvoke.ToString() + "," + package.Workbook.VbaProject.LibFlags.ToString() + "," + package.Workbook.VbaProject.MajorVersion.ToString() + "," + package.Workbook.VbaProject.MinorVersion.ToString() + "," + package.Workbook.VbaProject.Name + "," + package.Workbook.VbaProject.ProjectID + "," + package.Workbook.VbaProject.SystemKind.ToString() + "," + package.Workbook.VbaProject.Protection.HostProtected.ToString() + "," + package.Workbook.VbaProject.Protection.UserProtected.ToString() + "," + package.Workbook.VbaProject.Protection.VbeProtected.ToString() + "," + package.Workbook.VbaProject.Protection.VisibilityState.ToString());
- foreach (var module in package.Workbook.VbaProject.Modules)
- {
- File.WriteAllText(string.Format(@"c:\temp\vba\modules\{0}.txt", module.Name), module.Code);
- }
- foreach (var r in package.Workbook.VbaProject.References)
- {
- File.WriteAllText(string.Format(@"c:\temp\vba\modules\{0}.txt", r.Name), r.Libid + " " + r.ReferenceRecordID.ToString());
- }
-
- List<X509Certificate2> ret = new List<X509Certificate2>();
- X509Store store = new X509Store(StoreLocation.CurrentUser);
- store.Open(OpenFlags.ReadOnly);
- package.Workbook.VbaProject.Signature.Certificate = store.Certificates[19];
- //package.Workbook.VbaProject.Protection.SetPassword("");
- package.SaveAs(new FileInfo(@"c:\temp\vbaSaved.xlsm"));
- }
- [Ignore]
- [TestMethod]
- public void WriteVBA()
- {
- var package = new ExcelPackage();
- package.Workbook.Worksheets.Add("Sheet1");
- package.Workbook.CreateVBAProject();
- package.Workbook.VbaProject.Modules["Sheet1"].Code += "\r\nPrivate Sub Worksheet_SelectionChange(ByVal Target As Range)\r\nMsgBox(\"Test of the VBA Feature!\")\r\nEnd Sub\r\n";
- package.Workbook.VbaProject.Modules["Sheet1"].Name = "Blad1";
- package.Workbook.CodeModule.Name = "DenHärArbetsboken";
- package.Workbook.Worksheets[1].Name = "FirstSheet";
- package.Workbook.CodeModule.Code += "\r\nPrivate Sub Workbook_Open()\r\nBlad1.Cells(1,1).Value = \"VBA test\"\r\nMsgBox \"VBA is running!\"\r\nEnd Sub";
- //X509Store store = new X509Store(StoreLocation.CurrentUser);
- //store.Open(OpenFlags.ReadOnly);
- //package.Workbook.VbaProject.Signature.Certificate = store.Certificates[11];
-
- var m = package.Workbook.VbaProject.Modules.AddModule("Module1");
- m.Code += "Public Sub Test(param1 as string)\r\n\r\nEnd sub\r\nPublic Function functest() As String\r\n\r\nEnd Function\r\n";
- var c = package.Workbook.VbaProject.Modules.AddClass("Class1", false);
- c.Code += "Private Sub Class_Initialize()\r\n\r\nEnd Sub\r\nPrivate Sub Class_Terminate()\r\n\r\nEnd Sub";
- var c2 = package.Workbook.VbaProject.Modules.AddClass("Class2", true);
- c2.Code += "Private Sub Class_Initialize()\r\n\r\nEnd Sub\r\nPrivate Sub Class_Terminate()\r\n\r\nEnd Sub";
-
- package.Workbook.VbaProject.Protection.SetPassword("EPPlus");
- package.SaveAs(new FileInfo(@"c:\temp\vbaWrite.xlsm"));
-
- }
- [Ignore]
- [TestMethod]
- public void Resign()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\vbaWrite.xlsm"));
- //package.Workbook.VbaProject.Signature.Certificate = store.Certificates[11];
- package.SaveAs(new FileInfo(@"c:\temp\vbaWrite2.xlsm"));
- }
- [Ignore]
- [TestMethod]
- public void WriteLongVBAModule()
- {
- var package = new ExcelPackage();
- package.Workbook.Worksheets.Add("VBASetData");
- package.Workbook.CreateVBAProject();
- package.Workbook.CodeModule.Code = "Private Sub Workbook_Open()\r\nCreateData\r\nEnd Sub";
- var module = package.Workbook.VbaProject.Modules.AddModule("Code");
-
- StringBuilder code = new StringBuilder("Public Sub CreateData()\r\n");
- for (int row = 1; row < 30; row++)
- {
- for (int col = 1; col < 30; col++)
- {
- code.AppendLine(string.Format("VBASetData.Cells({0},{1}).Value=\"Cell {2}\"", row, col, new ExcelAddressBase(row, col, row, col).Address));
- }
- }
- code.AppendLine("End Sub");
- module.Code = code.ToString();
-
- //X509Store store = new X509Store(StoreLocation.CurrentUser);
- //store.Open(OpenFlags.ReadOnly);
- //package.Workbook.VbaProject.Signature.Certificate = store.Certificates[19];
-
- package.SaveAs(new FileInfo(@"c:\temp\vbaLong.xlsm"));
- }
- [Ignore]
- [TestMethod]
- public void VbaError()
- {
- DirectoryInfo workingDir = new DirectoryInfo(@"C:\epplusExample\folder");
- if (!workingDir.Exists) workingDir.Create();
- FileInfo f = new FileInfo(workingDir.FullName + "//" + "temp.xlsx");
- if (f.Exists) f.Delete();
- ExcelPackage myPackage = new ExcelPackage(f);
- myPackage.Workbook.CreateVBAProject();
- ExcelWorksheet excelWorksheet = myPackage.Workbook.Worksheets.Add("Sheet1");
- ExcelWorksheet excelWorksheet2 = myPackage.Workbook.Worksheets.Add("Sheet2");
- ExcelWorksheet excelWorksheet3 = myPackage.Workbook.Worksheets.Add("Sheet3");
- FileInfo f2 = new FileInfo(workingDir.FullName + "//" + "newfile.xlsm");
- ExcelVBAModule excelVbaModule = myPackage.Workbook.VbaProject.Modules.AddModule("Module1");
- StringBuilder mybuilder = new StringBuilder(); mybuilder.AppendLine("Sub Jiminy()");
- mybuilder.AppendLine("Range(\"D6\").Select");
- mybuilder.AppendLine("ActiveCell.FormulaR1C1 = \"Jiminy\"");
- mybuilder.AppendLine("End Sub");
- excelVbaModule.Code = mybuilder.ToString();
- myPackage.SaveAs(f2);
- myPackage.Dispose();
- }
- [Ignore]
- [TestMethod]
- public void ReadVBAUnicodeWsName()
- {
- var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\VbaUnicodeWS.xlsm"));
- File.WriteAllText(@"c:\temp\vba\modules\dir.txt", package.Workbook.VbaProject.CodePage + "," + package.Workbook.VbaProject.Constants + "," + package.Workbook.VbaProject.Description + "," + package.Workbook.VbaProject.HelpContextID.ToString() + "," + package.Workbook.VbaProject.HelpFile1 + "," + package.Workbook.VbaProject.HelpFile2 + "," + package.Workbook.VbaProject.Lcid.ToString() + "," + package.Workbook.VbaProject.LcidInvoke.ToString() + "," + package.Workbook.VbaProject.LibFlags.ToString() + "," + package.Workbook.VbaProject.MajorVersion.ToString() + "," + package.Workbook.VbaProject.MinorVersion.ToString() + "," + package.Workbook.VbaProject.Name + "," + package.Workbook.VbaProject.ProjectID + "," + package.Workbook.VbaProject.SystemKind.ToString() + "," + package.Workbook.VbaProject.Protection.HostProtected.ToString() + "," + package.Workbook.VbaProject.Protection.UserProtected.ToString() + "," + package.Workbook.VbaProject.Protection.VbeProtected.ToString() + "," + package.Workbook.VbaProject.Protection.VisibilityState.ToString());
- foreach (var module in package.Workbook.VbaProject.Modules)
- {
- File.WriteAllText(string.Format(@"c:\temp\vba\modules\{0}.txt", module.Name), module.Code);
- }
- foreach (var r in package.Workbook.VbaProject.References)
- {
- File.WriteAllText(string.Format(@"c:\temp\vba\modules\{0}.txt", r.Name), r.Libid + " " + r.ReferenceRecordID.ToString());
- }
-
- List<X509Certificate2> ret = new List<X509Certificate2>();
- X509Store store = new X509Store(StoreLocation.CurrentUser);
- store.Open(OpenFlags.ReadOnly);
- package.Workbook.VbaProject.Signature.Certificate = store.Certificates[19];
- //package.Workbook.VbaProject.Protection.SetPassword("");
- package.SaveAs(new FileInfo(@"c:\temp\vbaSaved.xlsm"));
- }
- [TestMethod]
- public void CreateUnicodeWsName()
- {
- using (var package = new ExcelPackage())
- {
- //ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Test");
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("测试");
-
- package.Workbook.CreateVBAProject();
- var sb = new StringBuilder();
- sb.AppendLine("Sub GetData()");
- sb.AppendLine("MsgBox (\"Hello,World\")");
- sb.AppendLine("End Sub");
-
- ExcelWorksheet worksheet2 = package.Workbook.Worksheets.Add("Sheet1");
- var stringBuilder = new StringBuilder();
- stringBuilder.AppendLine("Private Sub Worksheet_Change(ByVal Target As Range)");
- stringBuilder.AppendLine("GetData");
- stringBuilder.AppendLine("End Sub");
- worksheet.CodeModule.Code = stringBuilder.ToString();
-
- package.SaveAs(new FileInfo(@"c:\temp\invvba.xlsm"));
- }
- }
- //Issue with chunk overwriting 4096 bytes
- [Ignore]
- [TestMethod]
- public void VbaBug()
- {
- using ( var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\outfile.xlsm")))
- {
- Console.WriteLine(package.Workbook.CodeModule.Code.Length);
- package.Workbook.Worksheets[1].CodeModule.Code = "Private Sub Worksheet_SelectionChange(ByVal Target As Range)\r\n\r\nEnd Sub";
- package.Workbook.Worksheets.Add("TestCopy",package.Workbook.Worksheets[1]);
- package.SaveAs(new FileInfo(@"c:\temp\bug\outfile2.xlsm"));
- }
- }
- [TestMethod]
- public void DecompressionChunkGreaterThan4k()
- {
- // This is a test for Issue 15026: VBA decompression encounters index out of range
- // on the decompression buffer.
- var workbookDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\workbooks");
- var path = Path.Combine(workbookDir, "VBADecompressBug.xlsm");
- var f = new FileInfo(path);
- if (f.Exists)
- {
- using (var package = new ExcelPackage(f))
- {
- // Reading the Workbook.CodeModule.Code will cause an IndexOutOfRange if the problem hasn't been fixed.
- Assert.IsTrue(package.Workbook.CodeModule.Code.Length > 0);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/EPPlusTest/WorkSheet.cs b/EPPlusTest/WorkSheet.cs
deleted file mode 100644
index 9955c84..0000000
--- a/EPPlusTest/WorkSheet.cs
+++ /dev/null
@@ -1,2284 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.IO;
-using OfficeOpenXml.Drawing;
-using System.Drawing;
-using OfficeOpenXml.Drawing.Chart;
-using OfficeOpenXml.Drawing.Vml;
-using OfficeOpenXml.Style;
-using System.Data;
-using OfficeOpenXml.Table.PivotTable;
-using System.Reflection;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class WorkSheetTest : TestBase
- {
- [TestMethod]
- public void RunWorksheetTests()
- {
- InsertDeleteTestRows();
- InsertDeleteTestColumns();
- LoadData();
- StyleFill();
- Performance();
- RichTextCells();
- TestComments();
- Hyperlink();
- PictureURL();
- CopyOverwrite();
- HideTest();
- VeryHideTest();
- PrinterSettings();
- Address();
- Merge();
- Encoding();
- LoadText();
- LoadDataReader();
- LoadDataTable();
- LoadFromCollectionTest();
- LoadFromEmptyCollectionTest();
- LoadArray();
- WorksheetCopy();
- DefaultColWidth();
- CopyTable();
- AutoFitColumns();
- CopyRange();
- CopyMergedRange();
- ValueError();
- FormulaOverwrite();
- FormulaError();
- StyleNameTest();
- NamedStyles();
- TableTest();
- DefinedName();
- CreatePivotTable();
- AddChartSheet();
- SetHeaderFooterImage();
-
- SaveWorksheet("Worksheet.xlsx");
-
- ReadWorkSheet();
- ReadStreamSaveAsStream();
- }
-
- private void AddChartSheet()
- {
- var chart = _pck.Workbook.Worksheets.AddChart("ChartSheet", eChartType.ColumnClustered);
- foreach (var _n in _pck.Workbook.Names)
- {
-
- }
- //Iterate all collection and make sure no exception is thrown.
- foreach (var worksheet in _pck.Workbook.Worksheets)
- {
- if (!(worksheet is ExcelChartsheet))
- {
- foreach (var d in worksheet.Drawings)
- {
-
- }
- foreach (var d in worksheet.Tables)
- {
-
- }
- foreach (var d in worksheet.PivotTables)
- {
-
- }
- foreach (var d in worksheet.Names)
- {
-
- }
- foreach (var d in worksheet.Comments)
- {
-
- }
- foreach (var d in worksheet.ConditionalFormatting)
- {
-
- }
- }
- }
- }
- //[Ignore]
- //[TestMethod]
- public void ReadWorkSheet()
- {
- FileStream instream = new FileStream(_worksheetPath + @"Worksheet.xlsx", FileMode.Open, FileAccess.ReadWrite);
- using (ExcelPackage pck = new ExcelPackage(instream))
- {
- var ws = pck.Workbook.Worksheets["Perf"];
- Assert.AreEqual(ws.Cells["H6"].Formula, "B5+B6");
-
- ws = pck.Workbook.Worksheets["Comment"];
- var comment = ws.Cells["B2"].Comment;
-
- Assert.AreNotEqual(comment, null);
- Assert.AreEqual(comment.Author, "Jan Källman");
- ws = pck.Workbook.Worksheets["Hidden"];
- Assert.AreEqual<eWorkSheetHidden>(ws.Hidden, eWorkSheetHidden.Hidden);
-
- ws = pck.Workbook.Worksheets["VeryHidden"];
- Assert.AreEqual<eWorkSheetHidden>(ws.Hidden, eWorkSheetHidden.VeryHidden);
-
- ws = pck.Workbook.Worksheets["RichText"];
- Assert.AreEqual("Room 02 & 03", ws.Cells["G1"].RichText.Text);
-
- ws = pck.Workbook.Worksheets["HeaderImage"];
- //Assert.AreEqual(ws.HeaderFooter.Pictures.Count, 3);
-
- ws = pck.Workbook.Worksheets["newsheet"];
- Assert.AreEqual(ws.Cells["F2"].Style.Font.UnderLine, true);
- Assert.AreEqual(ws.Cells["F2"].Style.Font.UnderLineType, ExcelUnderLineType.Double);
- Assert.AreEqual(ws.Cells["F3"].Style.Font.UnderLineType, ExcelUnderLineType.SingleAccounting);
- Assert.AreEqual(ws.Cells["F5"].Style.Font.UnderLineType, ExcelUnderLineType.None);
- Assert.AreEqual(ws.Cells["F5"].Style.Font.UnderLine, false);
- }
- instream.Close();
- }
- [Ignore]
- [TestMethod]
- public void ReadStreamWithTemplateWorkSheet()
- {
- FileStream instream = new FileStream(_worksheetPath + @"\Worksheet.xlsx", FileMode.Open, FileAccess.Read);
- MemoryStream stream = new MemoryStream();
- using (ExcelPackage pck = new ExcelPackage(stream, instream))
- {
- var ws = pck.Workbook.Worksheets["Perf"];
- Assert.AreEqual(ws.Cells["H6"].Formula, "B5+B6");
-
- ws = pck.Workbook.Worksheets["newsheet"];
- Assert.AreEqual(ws.GetValue<DateTime>(20, 21), new DateTime(2010, 1, 1));
-
- ws = pck.Workbook.Worksheets["Loaded DataTable"];
- Assert.AreEqual(ws.GetValue<string>(2, 1), "Row1");
- Assert.AreEqual(ws.GetValue<int>(2, 2), 1);
- Assert.AreEqual(ws.GetValue<bool>(2, 3), true);
- Assert.AreEqual(ws.GetValue<double>(2, 4), 1.5);
-
- ws = pck.Workbook.Worksheets["RichText"];
-
- var r1 = ws.Cells["A1"].RichText[0];
- Assert.AreEqual(r1.Text, "Test");
- Assert.AreEqual(r1.Bold, true);
-
- ws = pck.Workbook.Worksheets["Pic URL"];
- Assert.AreEqual(((ExcelPicture)ws.Drawings["Pic URI"]).Hyperlink, "http://epplus.codeplex.com");
-
- Assert.AreEqual(pck.Workbook.Worksheets["Address"].GetValue<string>(40, 1), "\b\t");
-
- pck.SaveAs(new FileInfo(@"Test\Worksheet2.xlsx"));
- }
- instream.Close();
- }
- //[Ignore]
- //[TestMethod]
- public void ReadStreamSaveAsStream()
- {
- if (!File.Exists(_worksheetPath + @"Worksheet.xlsx"))
- {
- Assert.Inconclusive("Worksheet.xlsx does not exists");
- }
- FileStream instream = new FileStream(_worksheetPath + @"Worksheet.xlsx", FileMode.Open, FileAccess.ReadWrite);
- MemoryStream stream = new MemoryStream();
- using (ExcelPackage pck = new ExcelPackage(instream))
- {
- var ws = pck.Workbook.Worksheets["Names"];
- Assert.AreEqual(ws.Names["FullCol"].Start.Row, 1);
- Assert.AreEqual(ws.Names["FullCol"].End.Row, ExcelPackage.MaxRows);
- pck.SaveAs(stream);
- }
- instream.Close();
- }
- //
- // You can use the following additional attributes as you write your tests:
- //
- // Use ClassInitialize to run code before running the first test in the class
- // Use ClassCleanup to run code after all tests in a class have run
- //[Ignore]
- //[TestMethod]
- public void LoadData()
- {
- ExcelWorksheet ws = _pck.Workbook.Worksheets.Add("newsheet");
- ws.Cells["U19"].Value = new DateTime(2009, 12, 31);
- ws.Cells["U20"].Value = new DateTime(2010, 1, 1);
- ws.Cells["U21"].Value = new DateTime(2010, 1, 2);
- ws.Cells["U22"].Value = new DateTime(2010, 1, 3);
- ws.Cells["U23"].Value = new DateTime(2010, 1, 4);
- ws.Cells["U24"].Value = new DateTime(2010, 1, 5);
- ws.Cells["U19:U24"].Style.Numberformat.Format = "yyyy-mm-dd";
-
- ws.Cells["V19"].Value = 100;
- ws.Cells["V20"].Value = 102;
- ws.Cells["V21"].Value = 101;
- ws.Cells["V22"].Value = 103;
- ws.Cells["V23"].Value = 105;
- ws.Cells["V24"].Value = 104;
- ws.Cells["v19:v24"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
- ws.Cells["v19:v24"].Style.Numberformat.Format = @"$#,##0.00_);($#,##0.00)";
-
- ws.Cells["X19"].Value = 210;
- ws.Cells["X20"].Value = 212;
- ws.Cells["X21"].Value = 221;
- ws.Cells["X22"].Value = 123;
- ws.Cells["X23"].Value = 135;
- ws.Cells["X24"].Value = 134;
-
- // add autofilter
- ws.Cells["U19:X24"].AutoFilter = true;
- ExcelPicture pic = ws.Drawings.AddPicture("Pic1", Properties.Resources.Test1);
- pic.SetPosition(150, 140);
-
- ws.Cells["A30"].Value = "Text orientation 45";
- ws.Cells["A30"].Style.TextRotation = 45;
- ws.Cells["B30"].Value = "Text orientation 90";
- ws.Cells["B30"].Style.TextRotation = 90;
- ws.Cells["C30"].Value = "Text orientation 180";
- ws.Cells["C30"].Style.TextRotation = 180;
- ws.Cells["D30"].Value = "Text orientation 38";
- ws.Cells["D30"].Style.TextRotation = 38;
- ws.Cells["D30"].Style.Font.Bold = true;
- ws.Cells["D30"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
-
- ws.Workbook.Names.Add("TestName", ws.Cells["B30:E30"]);
- ws.Workbook.Names["TestName"].Style.Font.Color.SetColor(Color.Red);
-
-
- ws.Workbook.Names["TestName"].Offset(1, 0).Value = "Offset test 1";
- ws.Workbook.Names["TestName"].Offset(2, -1, 2, 2).Value = "Offset test 2";
-
- //Test vertical align
- ws.Cells["E19"].Value = "Subscript";
- ws.Cells["E19"].Style.Font.VerticalAlign = ExcelVerticalAlignmentFont.Subscript;
- ws.Cells["E20"].Value = "Subscript";
- ws.Cells["E20"].Style.Font.VerticalAlign = ExcelVerticalAlignmentFont.Superscript;
- ws.Cells["E21"].Value = "Superscript";
- ws.Cells["E21"].Style.Font.VerticalAlign = ExcelVerticalAlignmentFont.Superscript;
- ws.Cells["E21"].Style.Font.VerticalAlign = ExcelVerticalAlignmentFont.None;
-
-
- ws.Cells["E22"].Value = "Indent 2";
- ws.Cells["E22"].Style.Indent = 2;
- ws.Cells["E23"].Value = "Shrink to fit";
- ws.Cells["E23"].Style.ShrinkToFit = true;
-
- ws.Cells["e24"].Value = "ReadingOrder LeftToRight";
- ws.Cells["e24"].Style.ReadingOrder = ExcelReadingOrder.LeftToRight;
- ws.Cells["e25"].Value = "ReadingOrder RightToLeft";
- ws.Cells["e25"].Style.ReadingOrder = ExcelReadingOrder.RightToLeft;
- ws.Cells["e26"].Value = "ReadingOrder Context";
- ws.Cells["e26"].Style.ReadingOrder = ExcelReadingOrder.ContextDependent;
- ws.Cells["e27"].Value = "Default Readingorder";
-
- //Underline
-
- ws.Cells["F1:F7"].Value = "Underlined";
- ws.Cells["F1"].Style.Font.UnderLineType = ExcelUnderLineType.Single;
- ws.Cells["F2"].Style.Font.UnderLineType = ExcelUnderLineType.Double;
- ws.Cells["F3"].Style.Font.UnderLineType = ExcelUnderLineType.SingleAccounting;
- ws.Cells["F4"].Style.Font.UnderLineType = ExcelUnderLineType.DoubleAccounting;
- ws.Cells["F5"].Style.Font.UnderLineType = ExcelUnderLineType.None;
- ws.Cells["F6:F7"].Style.Font.UnderLine = true;
- ws.Cells["F7"].Style.Font.UnderLine = false;
-
- ws.Cells["E24"].Value = 0;
- Assert.AreEqual(ws.Cells["E24"].Text, "0");
- ws.Cells["F7"].Style.Font.UnderLine = false;
- ws.Names.Add("SheetName", ws.Cells["A1:A2"]);
- ws.View.FreezePanes(3, 5);
-
- foreach (ExcelRangeBase cell in ws.Cells["A1"])
- {
- Assert.Fail("A1 is not set");
- }
-
- foreach (ExcelRangeBase cell in ws.Cells[ws.Dimension.Address])
- {
- System.Diagnostics.Debug.WriteLine(cell.Address);
- }
-
- ////Linq test
- var res = from c in ws.Cells[ws.Dimension.Address] where c.Value != null && c.Value.ToString() == "Offset test 1" select c;
-
- foreach (ExcelRangeBase cell in res)
- {
- System.Diagnostics.Debug.WriteLine(cell.Address);
- }
-
- _pck.Workbook.Properties.Author = "Jan Källman";
- _pck.Workbook.Properties.Category = "Category";
- _pck.Workbook.Properties.Comments = "Comments";
- _pck.Workbook.Properties.Company = "Adventure works";
- _pck.Workbook.Properties.Keywords = "Keywords";
- _pck.Workbook.Properties.Title = "Title";
- _pck.Workbook.Properties.Subject = "Subject";
- _pck.Workbook.Properties.Status = "Status";
- _pck.Workbook.Properties.HyperlinkBase = new Uri("http://serversideexcel.com", UriKind.Absolute);
- _pck.Workbook.Properties.Manager = "Manager";
-
- _pck.Workbook.Properties.SetCustomPropertyValue("DateTest", new DateTime(2008, 12, 31));
- TestContext.WriteLine(_pck.Workbook.Properties.GetCustomPropertyValue("DateTest").ToString());
- _pck.Workbook.Properties.SetCustomPropertyValue("Author", "Jan Källman");
- _pck.Workbook.Properties.SetCustomPropertyValue("Count", 1);
- _pck.Workbook.Properties.SetCustomPropertyValue("IsTested", false);
- _pck.Workbook.Properties.SetCustomPropertyValue("LargeNo", 123456789123);
- _pck.Workbook.Properties.SetCustomPropertyValue("Author", 3);
- }
- const int PERF_ROWS = 5000;
- //[Ignore]
- //[TestMethod]
- public void Performance()
- {
- ExcelWorksheet ws = _pck.Workbook.Worksheets.Add("Perf");
- TestContext.WriteLine("StartTime {0}", DateTime.Now);
-
- Random r = new Random();
- for (int i = 1; i <= PERF_ROWS; i++)
- {
- ws.Cells[i, 1].Value = string.Format("Row {0}\n.Test new row\"' öäåü", i);
- ws.Cells[i, 2].Value = i;
- ws.Cells[i, 2].Style.WrapText = true;
- ws.Cells[i, 3].Value = DateTime.Now;
- ws.Cells[i, 4].Value = r.NextDouble() * 100000;
- }
- ws.Cells[1, 2, PERF_ROWS, 2].Style.Numberformat.Format = "#,##0";
- ws.Cells[1, 3, PERF_ROWS, 3].Style.Numberformat.Format = "yyyy-MM-dd HH:mm:ss";
- ws.Cells[1, 4, PERF_ROWS, 4].Style.Numberformat.Format = "#,##0.00";
- ws.Cells[PERF_ROWS + 1, 2].Formula = "SUM(B1:B" + PERF_ROWS.ToString() + ")";
- ws.Column(1).Width = 12;
- ws.Column(2).Width = 8;
- ws.Column(3).Width = 20;
- ws.Column(4).Width = 14;
-
- ws.Cells["A1:C1"].Merge = true;
- ws.Cells["A2:A5"].Merge = true;
- ws.DeleteRow(1, 1);
- ws.InsertRow(1, 1);
- ws.InsertRow(3, 1);
-
- ws.DeleteRow(1000, 3, true);
- ws.DeleteRow(2000, 1, true);
-
- ws.InsertRow(2001, 4);
-
- ws.InsertRow(2010, 1, 2010);
-
- ws.InsertRow(20000, 2);
-
- ws.DeleteRow(20005, 4, false);
-
- //Single formula
- ws.Cells["H3"].Formula = "B2+B3";
- ws.DeleteRow(2, 1, true);
-
- //Shared formula
- ws.Cells["H5:H30"].Formula = "B4+B5";
- ws.Cells["H5:H30"].Style.Numberformat.Format = "_(\"$\"* # ##0.00_);_(\"$\"* (# ##0.00);_(\"$\"* \"-\"??_);_(@_)";
- ws.InsertRow(7, 3);
- ws.InsertRow(2, 1);
- ws.DeleteRow(30, 3, true);
-
- ws.DeleteRow(15, 2, true);
- ws.Cells["a1:B100"].Style.Locked = false;
- ws.Cells["a1:B12"].Style.Hidden = true;
- TestContext.WriteLine("EndTime {0}", DateTime.Now);
- }
- //[Ignore]
- //[TestMethod]
- public void InsertDeleteTestRows()
- {
- ExcelWorksheet ws = _pck.Workbook.Worksheets.Add("InsertDelete");
- //ws.Cells.Value = 0;
- ws.Cells["A1:C5"].Value = 1;
- Assert.AreEqual(((object[,])ws.Cells["A1:C5"].Value)[1, 1], 1);
- ws.Cells["A1:B3"].Merge = true;
- ws.Cells["D3"].Formula = "A2+C5";
- ws.InsertRow(2, 1);
-
- ws.Cells["A10:C15"].Value = 1;
- ws.Cells["A11:B13"].Merge = true;
- ws.DeleteRow(12, 1, true);
-
- ws.Cells["a1:B100"].Style.Locked = false;
- ws.Cells["a1:B12"].Style.Hidden = true;
- ws.Protection.IsProtected = true;
- ws.Protection.SetPassword("Password");
-
-
- var range = ws.Cells["B2:D100"];
-
- ws.PrinterSettings.PrintArea = null;
- ws.PrinterSettings.PrintArea = ws.Cells["B2:D99"];
- ws.PrinterSettings.PrintArea = null;
- ws.Row(15).PageBreak = true;
- ws.Column(3).PageBreak = true;
- ws.View.ShowHeaders = false;
- ws.View.PageBreakView = true;
-
- ws.Row(200).Height = 50;
- ws.Workbook.CalcMode = ExcelCalcMode.Automatic;
-
- Assert.AreEqual(range.Start.Column, 2);
- Assert.AreEqual(range.Start.Row, 2);
- Assert.AreEqual(range.Start.Address, "B2");
-
- Assert.AreEqual(range.End.Column, 4);
- Assert.AreEqual(range.End.Row, 100);
- Assert.AreEqual(range.End.Address, "D100");
-
- ExcelAddress addr = new ExcelAddress("B1:D3");
-
- Assert.AreEqual(addr.Start.Column, 2);
- Assert.AreEqual(addr.Start.Row, 1);
- Assert.AreEqual(addr.End.Column, 4);
- Assert.AreEqual(addr.End.Row, 3);
- }
- //[Ignore]
- //[TestMethod]
- public void InsertDeleteTestColumns()
- {
- ExcelWorksheet ws = _pck.Workbook.Worksheets.Add("InsertDeleteColumns");
- //ws.Cells.Value = 0;
- ws.Cells["A1:C5"].Value = 1;
- Assert.AreEqual(((object[,])ws.Cells["A1:C5"].Value)[1, 1], 1);
- ws.Cells["A1:B3"].Merge = true;
- ws.Cells["D3"].Formula = "A2+C5";
- ws.InsertColumn(1, 1);
-
- ws.Cells["K10:M15"].Value = 1;
- ws.Cells["K11:L13"].Merge = true;
- ws.DeleteColumn(12, 1);
-
- ws.Cells["X1:Y100"].Style.Locked = false;
- ws.Cells["C1:Y12"].Style.Hidden = true;
- ws.Protection.IsProtected = true;
- ws.Protection.SetPassword("Password");
-
-
- var range = ws.Cells["X2:Z100"];
-
- ws.PrinterSettings.PrintArea = null;
- ws.PrinterSettings.PrintArea = ws.Cells["X2:Z99"];
- ws.PrinterSettings.PrintArea = null;
- ws.Row(15).PageBreak = true;
- ws.Column(3).PageBreak = true;
- ws.View.ShowHeaders = false;
- ws.View.PageBreakView = true;
-
- ws.Row(200).Height = 50;
- ws.Workbook.CalcMode = ExcelCalcMode.Automatic;
-
- //Assert.AreEqual(range.Start.Column, 2);
- //Assert.AreEqual(range.Start.Row, 2);
- //Assert.AreEqual(range.Start.Address, "B2");
-
- //Assert.AreEqual(range.End.Column, 4);
- //Assert.AreEqual(range.End.Row, 100);
- //Assert.AreEqual(range.End.Address, "D100");
-
- //ExcelAddress addr = new ExcelAddress("B1:D3");
-
- //Assert.AreEqual(addr.Start.Column, 2);
- //Assert.AreEqual(addr.Start.Row, 1);
- //Assert.AreEqual(addr.End.Column, 4);
- //Assert.AreEqual(addr.End.Row, 3);
- }
- //[Ignore]
- //[TestMethod]
- public void RichTextCells()
- {
- ExcelWorksheet ws = _pck.Workbook.Worksheets.Add("RichText");
- var rs = ws.Cells["A1"].RichText;
-
- var r1 = rs.Add("Test");
- r1.Bold = true;
- r1.Color = Color.Pink;
-
- var r2 = rs.Add(" of");
- r2.Size = 14;
- r2.Italic = true;
-
- var r3 = rs.Add(" rich");
- r3.FontName = "Arial";
- r3.Size = 18;
- r3.Italic = true;
-
- var r4 = rs.Add("text.");
- r4.Size = 8.25f;
- r4.Italic = true;
- r4.UnderLine = true;
-
- rs = ws.Cells["A3:A4"].RichText;
-
- var r5 = rs.Add("Double");
- r5.Color = Color.PeachPuff;
- r5.FontName = "times new roman";
- r5.Size = 16;
-
- var r6 = rs.Add(" cells");
- r6.Color = Color.Red;
- r6.UnderLine = true;
-
-
- rs = ws.Cells["C8"].RichText;
- r1 = rs.Add("Blue ");
- r1.Color = Color.Blue;
-
- r2 = rs.Add("Red");
- r2.Color = Color.Red;
-
- ws.Cells["G1"].RichText.Add("Room 02 & 03");
- ws.Cells["G2"].RichText.Text = "Room 02 & 03";
-
- ws = ws = _pck.Workbook.Worksheets.Add("RichText2");
- ws.Cells["A1"].RichText.Text = "Room 02 & 03";
- ws.TabColor = Color.PowderBlue;
-
- r1 = ws.Cells["G3"].RichText.Add("Test");
- r1.Bold = true;
- ws.Cells["G3"].RichText.Add(" a new t");
- ws.Cells["G3"].RichText[1].Bold = false; ;
- }
- //[Ignore]
- //[TestMethod]
- public void TestComments()
- {
- var ws = _pck.Workbook.Worksheets.Add("Comment");
- var comment = ws.Comments.Add(ws.Cells["C3"], "Jan Källman\r\nAuthor\r\n", "JK");
- comment.RichText[0].Bold = true;
- comment.RichText[0].PreserveSpace = true;
- var rt = comment.RichText.Add("Test comment");
- comment.VerticalAlignment = eTextAlignVerticalVml.Center;
- comment = ws.Comments.Add(ws.Cells["A2"], "Jan Källman\r\nAuthor\r\n1", "JK");
-
- comment = ws.Comments.Add(ws.Cells["A1"], "Jan Källman\r\nAuthor\r\n2", "JK");
- comment.AlternativeText = "Test of AlternetiveText2";
- comment = ws.Comments.Add(ws.Cells["C2"], "Jan Källman\r\nAuthor\r\n3", "JK");
- comment = ws.Comments.Add(ws.Cells["C1"], "Jan Källman\r\nAuthor\r\n5", "JK");
- comment = ws.Comments.Add(ws.Cells["B1"], "Jan Källman\r\nAuthor\r\n7", "JK");
-
- ws.Comments.Remove(ws.Cells["A2"].Comment);
- //comment.HorizontalAlignment = eTextAlignHorizontalVml.Center;
- //comment.Visible = true;
- //comment.BackgroundColor = Color.Green;
- //comment.To.Row += 4;
- //comment.To.Column += 2;
- //comment.LineStyle = eLineStyleVml.LongDash;
- //comment.LineColor = Color.Red;
- //comment.LineWidth = (Single)2.5;
- //rt.Color = Color.Red;
-
- var rt2 = ws.Cells["B2"].AddComment("Range Added Comment test test test test test test test test test test testtesttesttesttesttesttesttesttesttesttest", "Jan Källman");
- ws.Cells["c3"].Comment.AutoFit = true;
-
- }
- //[Ignore]
- //[TestMethod]
- public void Address()
- {
- var ws = _pck.Workbook.Worksheets.Add("Address");
- ws.Cells["A1:A4,B5:B7"].Value = "AddressTest";
- ws.Cells["A1:A4,B5:B7"].Style.Font.Color.SetColor(Color.Red);
- ws.Cells["A2:A3,B4:B8"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.LightUp;
- ws.Cells["A2:A3,B4:B8"].Style.Fill.BackgroundColor.SetColor(Color.LightGreen);
- ws.Cells["2:2"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
- ws.Cells["2:2"].Style.Fill.BackgroundColor.SetColor(Color.LightGreen);
- ws.Cells["B:B"].Style.Font.Name = "Times New Roman";
-
- ws.Cells["C4:G4,H8:H30,B15"].FormulaR1C1 = "RC[-1]+R1C[-1]";
- ws.Cells["C4:G4,H8:H30,B15"].Style.Numberformat.Format = "#,##0.000";
- ws.Cells["G1,G3"].Hyperlink = new ExcelHyperLink("Comment!$A$1", "Comment");
- ws.Cells["G1,G3"].Style.Font.Color.SetColor(Color.Blue);
- ws.Cells["G1,G3"].Style.Font.UnderLine = true;
-
- ws.Cells["A1:G5"].Copy(ws.Cells["A50"]);
-
- var ws2 = _pck.Workbook.Worksheets.Add("Copy Cells");
- ws.Cells["1:4"].Copy(ws2.Cells["1:1"]);
-
- ws.Cells["H1:J5"].Merge = true;
- ws.Cells["2:3"].Copy(ws.Cells["50:51"]);
-
- ws.Cells["A40"].Value = new string(new char[] { (char)8, (char)9 });
-
- ExcelRange styleRng = ws.Cells["A1"];
- ExcelStyle tempStyle = styleRng.Style;
- var namedStyle = _pck.Workbook.Styles.CreateNamedStyle("HyperLink", tempStyle);
- namedStyle.Style.Font.UnderLineType = ExcelUnderLineType.Single;
- namedStyle.Style.Font.Color.SetColor(Color.Blue);
- }
- //[Ignore]
- //[TestMethod]
- public void Encoding()
- {
- var ws = _pck.Workbook.Worksheets.Add("Encoding");
- ws.Cells["A1"].Value = "_x0099_";
- ws.Cells["A2"].Value = " Test \b" + (char)1 + " end\"";
- ws.Cells["A3"].Value = "_x0097_ test_x001D_1234";
- ws.Cells["A4"].Value = "test" + (char)31; //Bug issue 14689 //Fixed
- }
- //[Ignore]
- //[TestMethod]
- public void WorksheetCopy()
- {
- var ws = _pck.Workbook.Worksheets.Add("Copied Address", _pck.Workbook.Worksheets["Address"]);
- var wsCopy = _pck.Workbook.Worksheets.Add("Copied Comment", _pck.Workbook.Worksheets["Comment"]);
-
- ExcelPackage pck2 = new ExcelPackage();
- pck2.Workbook.Worksheets.Add("Copy From other pck", _pck.Workbook.Worksheets["Address"]);
- pck2.SaveAs(new FileInfo(_worksheetPath + "copy.xlsx"));
- pck2 = null;
- Assert.AreEqual(6, wsCopy.Comments.Count);
- }
- [Ignore]
- [TestMethod]
- public void TestDelete()
- {
- string file = _worksheetPath + "test.xlsx";
-
- if (File.Exists(file))
- File.Delete(file);
-
- Create(file);
-
- ExcelPackage pack = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w = pack.Workbook.Worksheets["delete"];
- w.DeleteRow(1, 2);
-
- pack.Save();
- }
- //[Ignore]
- //[TestMethod]
- public void LoadFromCollectionTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("LoadFromCollection");
- List<TestDTO> list = new List<TestDTO>();
- list.Add(new TestDTO() { Id = 1, Name = "Item1", Boolean = false, Date = new DateTime(2011, 1, 1), dto = null, NameVar = "Field 1" });
- list.Add(new TestDTO() { Id = 2, Name = "Item2", Boolean = true, Date = new DateTime(2011, 1, 15), dto = new TestDTO(), NameVar = "Field 2" });
- list.Add(new TestDTO() { Id = 3, Name = "Item3", Boolean = false, Date = new DateTime(2011, 2, 1), dto = null, NameVar = "Field 3" });
- list.Add(new TestDTO() { Id = 4, Name = "Item4", Boolean = true, Date = new DateTime(2011, 4, 19), dto = list[1], NameVar = "Field 4" });
- list.Add(new TestDTO() { Id = 5, Name = "Item5", Boolean = false, Date = new DateTime(2011, 5, 8), dto = null, NameVar = "Field 5" });
- list.Add(new TestDTO() { Id = 6, Name = "Item6", Boolean = true, Date = new DateTime(2010, 3, 27), dto = null, NameVar = "Field 6" });
- list.Add(new TestDTO() { Id = 7, Name = "Item7", Boolean = false, Date = new DateTime(2009, 1, 5), dto = list[3], NameVar = "Field 7" });
- list.Add(new TestDTO() { Id = 8, Name = "Item8", Boolean = true, Date = new DateTime(2018, 12, 31), dto = null, NameVar = "Field 8" });
- list.Add(new TestDTO() { Id = 9, Name = "Item9", Boolean = false, Date = new DateTime(2010, 2, 1), dto = null, NameVar = "Field 9" });
-
- ws.Cells["A1"].LoadFromCollection(list, true);
- ws.Cells["A30"].LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Medium9, BindingFlags.Instance | BindingFlags.Instance, typeof(TestDTO).GetFields());
-
- ws.Cells["A45"].LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light1, BindingFlags.Instance | BindingFlags.Instance, new MemberInfo[] { typeof(TestDTO).GetMethod("GetNameID"), typeof(TestDTO).GetField("NameVar") });
- ws.Cells["J1"].LoadFromCollection(from l in list where l.Boolean orderby l.Date select new { Name = l.Name, Id = l.Id, Date = l.Date, NameVariable = l.NameVar }, true, OfficeOpenXml.Table.TableStyles.Dark4);
-
- var ints = new int[] { 1, 3, 4, 76, 2, 5 };
- ws.Cells["A15"].Value = ints;
- }
- //[TestMethod]
- public void LoadFromEmptyCollectionTest()
- {
- if (_pck == null) _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("LoadFromEmpyCollection");
- List<TestDTO> listDTO = new List<TestDTO>(0);
- //List<int> list = new List<int>(0);
-
- ws.Cells["A1"].LoadFromCollection(listDTO, true);
- ws.Cells["A5"].LoadFromCollection(listDTO, true, OfficeOpenXml.Table.TableStyles.Medium9, BindingFlags.Instance | BindingFlags.Instance, typeof(TestDTO).GetFields());
-
- ws.Cells["A10"].LoadFromCollection(listDTO, true, OfficeOpenXml.Table.TableStyles.Light1, BindingFlags.Instance | BindingFlags.Instance, new MemberInfo[] { typeof(TestDTO).GetMethod("GetNameID"), typeof(TestDTO).GetField("NameVar") });
- ws.Cells["A15"].LoadFromCollection(from l in listDTO where l.Boolean orderby l.Date select new { Name = l.Name, Id = l.Id, Date = l.Date, NameVariable = l.NameVar }, true, OfficeOpenXml.Table.TableStyles.Dark4);
-
- ws.Cells["A20"].LoadFromCollection(listDTO, false);
- }
- [TestMethod]
- public void LoadFromOneCollectionTest()
- {
- if (_pck == null) _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("LoadFromEmpyCollection");
- List<TestDTO> listDTO = new List<TestDTO>(0) { new TestDTO() { Name = "Single" } };
- //List<int> list = new List<int>(0);
-
- var r = ws.Cells["A1"].LoadFromCollection(listDTO, true);
- Assert.AreEqual(2, r.Rows);
- var r2 = ws.Cells["A5"].LoadFromCollection(listDTO, false);
- Assert.AreEqual(1, r2.Rows);
- }
- static void Create(string file)
- {
- ExcelPackage pack = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w = pack.Workbook.Worksheets.Add("delete");
- w.Cells[1, 1].Value = "test";
- w.Cells[1, 2].Value = "test";
- w.Cells[2, 1].Value = "to delete";
- w.Cells[2, 2].Value = "to delete";
- w.Cells[3, 1].Value = "3Left";
- w.Cells[3, 2].Value = "3Left";
- w.Cells[4, 1].Formula = "B3+C3";
- w.Cells[4, 2].Value = "C3+D3";
- pack.Save();
- }
- [Ignore]
- [TestMethod]
- public void RowStyle()
- {
- FileInfo newFile = new FileInfo(_worksheetPath + @"sample8.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- //newFile = new FileInfo(dir + @"sample8.xlsx");
- }
-
- ExcelPackage package = new ExcelPackage();
- //Load the sheet with one string column, one date column and a few random numbers.
- var ws = package.Workbook.Worksheets.Add("First line test");
-
- ws.Cells[1, 1].Value = "1; 1";
- ws.Cells[2, 1].Value = "2; 1";
- ws.Cells[1, 2].Value = "1; 2";
- ws.Cells[2, 2].Value = "2; 2";
-
- ws.Row(1).Style.Font.Bold = true;
- ws.Column(1).Style.Font.Bold = true;
- package.SaveAs(newFile);
-
- }
- //[Ignore]
- //[TestMethod]
- public void HideTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("Hidden");
- ws.Cells["A1"].Value = "This workbook is hidden";
- ws.Hidden = eWorkSheetHidden.Hidden;
- }
- //[Ignore]
- //[TestMethod]
- public void Hyperlink()
- {
- var ws = _pck.Workbook.Worksheets.Add("HyperLinks");
- var hl = new ExcelHyperLink("G1", "Till G1");
- hl.ToolTip = "Link to cell G1";
- ws.Cells["A1"].Hyperlink = hl;
- //ws.Cells["A2"].Hyperlink = new ExcelHyperLink("mailto:ecsomany@google:huszar", UriKind.Absolute); //Invalid URL will throw an Exception
- }
- //[Ignore]
- //[TestMethod]
- public void VeryHideTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("VeryHidden");
- ws.Cells["a1"].Value = "This workbook is hidden";
- ws.Hidden = eWorkSheetHidden.VeryHidden;
- }
- //[Ignore]
- //[TestMethod]
- public void PrinterSettings()
- {
- var ws = _pck.Workbook.Worksheets.Add("Sod/Hydroseed");
-
- ws.Cells[1, 1].Value = "1; 1";
- ws.Cells[2, 1].Value = "2; 1";
- ws.Cells[1, 2].Value = "1; 2";
- ws.Cells[2, 2].Value = "2; 2";
- ws.Cells[1, 1, 1, 2].AutoFilter = true;
- ws.PrinterSettings.BlackAndWhite = true;
- ws.PrinterSettings.ShowGridLines = true;
- ws.PrinterSettings.ShowHeaders = true;
- ws.PrinterSettings.PaperSize = ePaperSize.A4;
-
- ws.PrinterSettings.RepeatRows = new ExcelAddress("1:1");
- ws.PrinterSettings.RepeatColumns = new ExcelAddress("A:A");
-
- ws.PrinterSettings.Draft = true;
- var r = ws.Cells["A26"];
- r.Value = "X";
- r.Worksheet.Row(26).PageBreak = true;
- ws.PrinterSettings.PrintArea = ws.Cells["A1:B2"];
- ws.PrinterSettings.HorizontalCentered = true;
- ws.PrinterSettings.VerticalCentered = true;
-
- ws.Select(new ExcelAddress("3:4,E5:F6"));
-
- ws = _pck.Workbook.Worksheets["RichText"];
- ws.PrinterSettings.RepeatColumns = ws.Cells["A:B"];
- ws.PrinterSettings.RepeatRows = ws.Cells["1:11"];
- ws.PrinterSettings.TopMargin = 1M;
- ws.PrinterSettings.LeftMargin = 1M;
- ws.PrinterSettings.BottomMargin = 1M;
- ws.PrinterSettings.RightMargin = 1M;
- ws.PrinterSettings.Orientation = eOrientation.Landscape;
- ws.PrinterSettings.PaperSize = ePaperSize.A4;
- }
- //[Ignore]
- //[TestMethod]
- public void StyleNameTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("StyleNameTest");
-
- ws.Cells[1, 1].Value = "R1 C1";
- ws.Cells[1, 2].Value = "R1 C2";
- ws.Cells[1, 3].Value = "R1 C3";
- ws.Cells[2, 1].Value = "R2 C1";
- ws.Cells[2, 2].Value = "R2 C2";
- ws.Cells[2, 3].Value = "R2 C3";
- ws.Cells[3, 1].Value = double.PositiveInfinity;
- ws.Cells[3, 2].Value = double.NegativeInfinity;
- ws.Cells[4, 1].CreateArrayFormula("A1+B1");
- var ns = _pck.Workbook.Styles.CreateNamedStyle("TestStyle");
- ns.Style.Font.Bold = true;
-
- ws.Cells.Style.Locked = true;
- ws.Cells["A1:C1"].StyleName = "TestStyle";
- ws.DefaultRowHeight = 35;
- ws.Cells["A1:C4"].Style.Locked = false;
- ws.Protection.IsProtected = true;
- }
- //[Ignore]
- //[TestMethod]
- public void ValueError()
- {
- var ws = _pck.Workbook.Worksheets.Add("ValueError");
-
- ws.Cells[1, 1].Value = "Domestic Violence and the Professional";
- var rt = ws.Cells[1, 2].RichText.Add("Domestic Violence and the Professional 2");
- TestContext.WriteLine(rt.Bold.ToString());
- rt.Bold = true;
- TestContext.WriteLine(rt.Bold.ToString());
- }
- //[Ignore]
- //[TestMethod]
- public void FormulaError()
- {
- var ws = _pck.Workbook.Worksheets.Add("FormulaError");
-
- ws.Cells["D5"].Formula = "COUNTIF(A1:A100,\"Miss\")";
- ws.Cells["A1:K3"].Formula = "A3+A4";
- ws.Cells["A4"].FormulaR1C1 = "+ROUNDUP(RC[1]/10,0)*10";
-
- ws = _pck.Workbook.Worksheets.Add("Sheet-RC1");
- ws.Cells["A4"].FormulaR1C1 = "+ROUNDUP('Sheet-RC1'!RC[1]/10,0)*10";
-
- //ws.Cells["B2:I2"].Formula = ""; //Error
- }
- [TestMethod, Ignore]
- public void FormulaArray()
- {
- _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("FormulaError");
-
- ws.Cells["E2:E5"].CreateArrayFormula("FREQUENCY(B2:B18,C2:C5)");
- _pck.SaveAs(new FileInfo("c:\\temp\\arrayformula.xlsx"));
- }
- //[Ignore]
- //[TestMethod]
- public void PictureURL()
- {
- var ws = _pck.Workbook.Worksheets.Add("Pic URL");
-
- ExcelHyperLink hl = new ExcelHyperLink("http://epplus.codeplex.com");
- hl.ToolTip = "Screen Tip";
-
- ws.Drawings.AddPicture("Pic URI", Properties.Resources.Test1, hl);
- }
-
-
- [TestMethod]
- public void PivotTableTest()
- {
- _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("PivotTable");
- ws.Cells["A1"].LoadFromArrays(new object[][] { new[] { "A", "B", "C", "D" } });
- ws.Cells["A2"].LoadFromArrays(new object[][]
- {
- new object [] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
- new object [] { 9, 8, 7 ,6, 5, 4, 3, 2, 1, 0 },
- new object [] { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
- });
- var table = ws.Tables.Add(ws.Cells["A1:D4"], "PivotData");
- ws.PivotTables.Add(ws.Cells["G1"], ws.Cells["A1:D4"], "PivotTable");
- Assert.AreEqual("PivotStyleMedium9", ws.PivotTables["PivotTable"].StyleName);
- }
-
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentException))]
- public void TestTableNameCanNotStartsWithNumber()
- {
- var ws = _pck.Workbook.Worksheets.Add("Table");
- var tbl = ws.Tables.Add(ws.Cells["A1"], "5TestTable");
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentException))]
- public void TestTableNameCanNotContainWhiteSpaces()
- {
- var ws = _pck.Workbook.Worksheets.Add("Table");
- var tbl = ws.Tables.Add(ws.Cells["A1"], "Test Table");
- }
-
- [TestMethod]
- public void TestTableNameCanStartsWithBackSlash()
- {
- var ws = _pck.Workbook.Worksheets.Add("Table");
- var tbl = ws.Tables.Add(ws.Cells["A1"], "\\TestTable");
- }
-
- [TestMethod]
- public void TestTableNameCanStartsWithUnderscore()
- {
- var ws = _pck.Workbook.Worksheets.Add("Table");
- var tbl = ws.Tables.Add(ws.Cells["A1"], "_TestTable");
- }
-
- //[Ignore]
- //[TestMethod]
- public void TableTest()
- {
- var ws = _pck.Workbook.Worksheets.Add("Table");
- ws.Cells["B1"].Value = 123;
- var tbl = ws.Tables.Add(ws.Cells["B1:P12"], "TestTable");
- tbl.TableStyle = OfficeOpenXml.Table.TableStyles.Custom;
-
- tbl.ShowFirstColumn = true;
- tbl.ShowTotal = true;
- tbl.ShowHeader = true;
- tbl.ShowLastColumn = true;
- tbl.ShowFilter = false;
- Assert.AreEqual(tbl.ShowFilter, false);
- ws.Cells["K2"].Value = 5;
- ws.Cells["J3"].Value = 4;
-
- tbl.Columns[8].TotalsRowFunction = OfficeOpenXml.Table.RowFunctions.Sum;
- tbl.Columns[9].TotalsRowFormula = string.Format("SUM([{0}])", tbl.Columns[9].Name);
- tbl.Columns[14].CalculatedColumnFormula = "TestTable[[#This Row],[123]]+TestTable[[#This Row],[Column2]]";
- ws.Cells["B2"].Value = 1;
- ws.Cells["B3"].Value = 2;
- ws.Cells["B4"].Value = 3;
- ws.Cells["B5"].Value = 4;
- ws.Cells["B6"].Value = 5;
- ws.Cells["B7"].Value = 6;
- ws.Cells["B8"].Value = 7;
- ws.Cells["B9"].Value = 8;
- ws.Cells["B10"].Value = 9;
- ws.Cells["B11"].Value = 10;
- ws.Cells["B12"].Value = 11;
- ws.Cells["C7"].Value = "Table test";
- ws.Cells["C8"].Style.Fill.PatternType = ExcelFillStyle.Solid;
- ws.Cells["C8"].Style.Fill.BackgroundColor.SetColor(Color.Red);
-
- tbl = ws.Tables.Add(ws.Cells["a12:a13"], "");
-
- tbl = ws.Tables.Add(ws.Cells["C16:Y35"], "");
- tbl.TableStyle = OfficeOpenXml.Table.TableStyles.Medium14;
- tbl.ShowFirstColumn = true;
- tbl.ShowLastColumn = true;
- tbl.ShowColumnStripes = true;
- Assert.AreEqual(tbl.ShowFilter, true);
- tbl.Columns[2].Name = "Test Column Name";
-
- ws.Cells["G50"].Value = "Timespan";
- ws.Cells["G51"].Value = new DateTime(new TimeSpan(1, 1, 10).Ticks); //new DateTime(1899, 12, 30, 1, 1, 10);
- ws.Cells["G52"].Value = new DateTime(1899, 12, 30, 2, 3, 10);
- ws.Cells["G53"].Value = new DateTime(1899, 12, 30, 3, 4, 10);
- ws.Cells["G54"].Value = new DateTime(1899, 12, 30, 4, 5, 10);
-
- ws.Cells["G51:G55"].Style.Numberformat.Format = "HH:MM:SS";
- tbl = ws.Tables.Add(ws.Cells["G50:G54"], "");
- tbl.ShowTotal = true;
- tbl.ShowFilter = false;
- tbl.Columns[0].TotalsRowFunction = OfficeOpenXml.Table.RowFunctions.Sum;
- }
-
- [TestMethod]
- public void TableDeleteTest()
- {
- using (var pkg = new ExcelPackage())
- {
- var wb = pkg.Workbook;
- var sheets = new[]
- {
- wb.Worksheets.Add("WorkSheet A"),
- wb.Worksheets.Add("WorkSheet B")
- };
- for (int i = 1; i <= 4; i++)
- {
- var cell = sheets[0].Cells[1, i];
- cell.Value = cell.Address + "_";
- cell = sheets[1].Cells[1, i];
- cell.Value = cell.Address + "_";
- }
-
- for (int i = 6; i <= 11; i++)
- {
- var cell = sheets[0].Cells[3, i];
- cell.Value = cell.Address + "_";
- cell = sheets[1].Cells[3, i];
- cell.Value = cell.Address + "_";
- }
- var tables = new[]
- {
- sheets[1].Tables.Add(sheets[1].Cells["A1:D73"], "Tablea"),
- sheets[0].Tables.Add(sheets[0].Cells["A1:D73"], "Table2"),
- sheets[1].Tables.Add(sheets[1].Cells["F3:K10"], "Tableb"),
- sheets[0].Tables.Add(sheets[0].Cells["F3:K10"], "Table3"),
- };
- Assert.AreEqual(5, wb._nextTableID);
- Assert.AreEqual(1, tables[0].Id);
- Assert.AreEqual(2, tables[1].Id);
- try
- {
- sheets[0].Tables.Delete("Tablea");
- Assert.Fail("ArgumentException should have been thrown.");
- }
- catch (ArgumentOutOfRangeException) { }
- sheets[1].Tables.Delete("Tablea");
- Assert.AreEqual(1, tables[1].Id);
- Assert.AreEqual(2, tables[2].Id);
-
- try
- {
- sheets[1].Tables.Delete(4);
- Assert.Fail("ArgumentException should have been thrown.");
- }
- catch (ArgumentOutOfRangeException) { }
- var range = sheets[0].Cells[sheets[0].Tables[1].Address.Address];
- sheets[0].Tables.Delete(1, true);
- foreach (var cell in range)
- {
- Assert.IsNull(cell.Value);
- }
- }
- }
-
- //[Ignore]
- //[TestMethod]
- public void CopyTable()
- {
- _pck.Workbook.Worksheets.Copy("File4", "Copied table");
- }
- //[Ignore]
- //[TestMethod]
- public void CopyRange()
- {
- var ws = _pck.Workbook.Worksheets.Add("CopyTest");
-
- ws.Cells["A1"].Value = "Single Cell";
- ws.Cells["A2"].Value = "Merged Cells";
- ws.Cells["A2:D30"].Merge = true;
- ws.Cells["A1"].Style.Font.Bold = true;
- ws.Cells["G4:H5"].Merge = true;
- ws.Cells["B3:C5"].Copy(ws.Cells["G4"]);
- }
- //[Ignore]
- //[TestMethod]
- public void CopyMergedRange()
- {
- var ws = _pck.Workbook.Worksheets.Add("CopyMergedRangeTest");
-
- ws.Cells["A11:C11"].Merge = true;
- ws.Cells["A12:C12"].Merge = true;
-
- var source = ws.Cells["A11:C12"];
- var target = ws.Cells["A21"];
-
- source.Copy(target);
-
- var a21 = ws.Cells[21, 1];
- var a22 = ws.Cells[22, 1];
-
- Assert.IsTrue(a21.Merge);
- Assert.IsTrue(a22.Merge);
-
- //Assert.AreNotEqual(a21.MergeId, a22.MergeId);
- }
- [Ignore]
- [TestMethod]
- public void CopyPivotTable()
- {
- _pck.Workbook.Worksheets.Copy("Pivot-Group Date", "Copied Pivottable 1");
- _pck.Workbook.Worksheets.Copy("Pivot-Group Number", "Copied Pivottable 2");
- }
- [Ignore]
- [TestMethod]
- public void Stylebug()
- {
- ExcelPackage p = new ExcelPackage(new FileInfo(@"c:\temp\FullProjecte.xlsx"));
-
- var ws = p.Workbook.Worksheets.First();
- ws.Cells[12, 1].Value = 0;
- ws.Cells[12, 2].Value = new DateTime(2010, 9, 14);
- ws.Cells[12, 3].Value = "Federico Lois";
- ws.Cells[12, 4].Value = "Nakami";
- ws.Cells[12, 5].Value = "Hores";
- ws.Cells[12, 7].Value = 120;
- ws.Cells[12, 8].Value = "A definir";
- ws.Cells[12, 9].Value = new DateTime(2010, 9, 14);
- ws.Cells[12, 10].Value = new DateTime(2010, 9, 14);
- ws.Cells[12, 11].Value = "Transferència";
-
- ws.InsertRow(13, 1, 12);
- ws.Cells[13, 1].Value = 0;
- ws.Cells[13, 2].Value = new DateTime(2010, 9, 14);
- ws.Cells[13, 3].Value = "Federico Lois";
- ws.Cells[13, 4].Value = "Nakami";
- ws.Cells[13, 5].Value = "Hores";
- ws.Cells[13, 7].Value = 120;
- ws.Cells[13, 8].Value = "A definir";
- ws.Cells[13, 9].Value = new DateTime(2010, 9, 14);
- ws.Cells[13, 10].Value = new DateTime(2010, 9, 14);
- ws.Cells[13, 11].Value = "Transferència";
-
- ws.InsertRow(14, 1, 13);
-
- ws.InsertRow(19, 1, 19);
- ws.InsertRow(26, 1, 26);
- ws.InsertRow(33, 1, 33);
- p.SaveAs(new FileInfo(@"c:\temp\FullProjecte_new.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ReadBug()
- {
- using (var package = new ExcelPackage(new FileInfo(@"c:\temp\error.xlsx")))
- {
- var fulla = package.Workbook.Worksheets.FirstOrDefault();
- var r = fulla == null ? null : fulla.Cells["a:a"]
- .Where(t => !string.IsNullOrWhiteSpace(t.Text)).Select(cell => cell.Value.ToString())
- .ToList();
- }
- }
- //[Ignore]
- //[TestMethod]
- public void FormulaOverwrite()
- {
- var ws = _pck.Workbook.Worksheets.Add("FormulaOverwrite");
- //Inside
- ws.Cells["A1:G12"].Formula = "B1+C1";
- ws.Cells["B2:C3"].Formula = "G2+E1";
-
-
- //Top bottom overwrite
- ws.Cells["A14:G26"].Formula = "B1+C1+D1";
- ws.Cells["B13:C28"].Formula = "G2+E1";
-
- //Top bottom overwrite
- ws.Cells["B30:E42"].Formula = "B1+C1+$D$1";
- ws.Cells["A32:H33"].Formula = "G2+E1";
-
- ws.Cells["A50:A59"].CreateArrayFormula("C50+D50");
- ws.Cells["A1"].Value = "test";
- ws.Cells["A15"].Value = "Värde";
- ws.Cells["C12"].AddComment("Test", "JJOD");
- ws.Cells["D12:I12"].Merge = true;
- ws.Cells["D12:I12"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
- ws.Cells["D12:I12"].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
- ws.Cells["D12:I12"].Style.WrapText = true;
-
- ws.Cells["F1:F3"].Formula = "F2+F3";
- ws.Cells["J1:J3"].Formula = "F2+F3";
- ws.Cells["F1:F3"].Formula = "F5+F6"; //Overwrite same range
- }
- //[Ignore]
- //[TestMethod]
- public void DefinedName()
- {
- var ws = _pck.Workbook.Worksheets.Add("Names");
- ws.Names.Add("RefError", ws.Cells["#REF!"]);
-
- ws.Cells["A1"].Value = "Test";
- ws.Cells["A1"].Style.Font.Size = 8.5F;
-
- ws.Names.Add("Address", ws.Cells["A2:A3"]);
- ws.Cells["Address"].Value = 1;
- ws.Names.AddValue("Value", 5);
- ws.Names.Add("FullRow", ws.Cells["2:2"]);
- ws.Names.Add("FullCol", ws.Cells["A:A"]);
- //ws.Names["Value"].Style.Border.Bottom.Color.SetColor(Color.Black);
- ws.Names.AddFormula("Formula", "Names!A2+Names!A3+Names!Value");
- }
- [Ignore]
- [TestMethod]
- public void URL()
- {
- var p = new ExcelPackage(new FileInfo(@"c:\temp\url.xlsx"));
- foreach (var ws in p.Workbook.Worksheets)
- {
-
- }
- p.SaveAs(new FileInfo(@"c:\temp\urlsaved.xlsx"));
- }
- //[TestMethod]
- public void LoadDataReader()
- {
- if (_pck == null) _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("Loaded DataReader");
- ExcelRangeBase range;
- using (var dt = new DataTable())
- {
- dt.Columns.Add("String", typeof(string));
- dt.Columns.Add("Int", typeof(int));
- dt.Columns.Add("Bool", typeof(bool));
- dt.Columns.Add("Double", typeof(double));
-
- var dr = dt.NewRow();
- dr[0] = "Row1";
- dr[1] = 1;
- dr[2] = true;
- dr[3] = 1.5;
- dt.Rows.Add(dr);
-
- dr = dt.NewRow();
- dr[0] = "Row2";
- dr[1] = 2;
- dr[2] = false;
- dr[3] = 2.25;
- dt.Rows.Add(dr);
-
- //dr = dt.NewRow();
- //dr[0] = "Row3";
- //dr[1] = 3;
- //dr[2] = true;
- //dr[3] = 3.125;
- //dt.Rows.Add(dr);
-
- using (var reader = dt.CreateDataReader())
- {
- range = ws.Cells["A1"].LoadFromDataReader(reader, true, "My_Table",
- OfficeOpenXml.Table.TableStyles.Medium5);
- }
- Assert.AreEqual(1, range.Start.Column);
- Assert.AreEqual(4, range.End.Column);
- Assert.AreEqual(1, range.Start.Row);
- Assert.AreEqual(3, range.End.Row);
-
- using (var reader = dt.CreateDataReader())
- {
- range = ws.Cells["A5"].LoadFromDataReader(reader, false, "My_Table2",
- OfficeOpenXml.Table.TableStyles.Medium5);
- }
- Assert.AreEqual(1, range.Start.Column);
- Assert.AreEqual(4, range.End.Column);
- Assert.AreEqual(5, range.Start.Row);
- Assert.AreEqual(6, range.End.Row);
- }
- }
-
-
- //[TestMethod, Ignore]
- public void LoadDataTable()
- {
- if (_pck == null) _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("Loaded DataTable");
-
- var dt = new DataTable();
- dt.Columns.Add("String", typeof(string));
- dt.Columns.Add("Int", typeof(int));
- dt.Columns.Add("Bool", typeof(bool));
- dt.Columns.Add("Double", typeof(double));
-
-
- var dr = dt.NewRow();
- dr[0] = "Row1";
- dr[1] = 1;
- dr[2] = true;
- dr[3] = 1.5;
- dt.Rows.Add(dr);
-
- dr = dt.NewRow();
- dr[0] = "Row2";
- dr[1] = 2;
- dr[2] = false;
- dr[3] = 2.25;
- dt.Rows.Add(dr);
-
- dr = dt.NewRow();
- dr[0] = "Row3";
- dr[1] = 3;
- dr[2] = true;
- dr[3] = 3.125;
- dt.Rows.Add(dr);
-
- ws.Cells["A1"].LoadFromDataTable(dt, true, OfficeOpenXml.Table.TableStyles.Medium5);
-
- //worksheet.Cells[startRow, 7, worksheet.Dimension.End.Row, 7].FormulaR1C1 = "=IF(RC[-2]=0,0,RC[-1]/RC[-2])";
-
- ws.Tables[0].Columns[1].TotalsRowFunction = OfficeOpenXml.Table.RowFunctions.Sum;
- ws.Tables[0].ShowTotal = true;
- }
-
- [Ignore]
- [TestMethod]
- public void LoadEmptyDataTable()
- {
- if (_pck == null) _pck = new ExcelPackage();
- var ws = _pck.Workbook.Worksheets.Add("Loaded Empty DataTable");
-
- var dt = new DataTable();
- dt.Columns.Add(new DataColumn("col1"));
- dt.Columns.Add(new DataColumn("col2"));
- ws.Cells["A1"].LoadFromDataTable(dt, true);
-
- ws.Cells["D1"].LoadFromDataTable(dt, false);
- }
-
- [TestMethod]
- public void LoadText_Bug15015()
- {
- var package = new ExcelPackage();
- var ws = package.Workbook.Worksheets.Add("Loaded Text");
- ws.Cells["A1"].LoadFromText("\"text with eol,\r\n in a cell\",\"other value\"", new ExcelTextFormat { TextQualifier = '"', EOL = ",\r\n", Delimiter = ',' });
- }
-
- [TestMethod]
- public void LoadText_Bug15015_Negative()
- {
- var package = new ExcelPackage();
- var ws = package.Workbook.Worksheets.Add("Loaded Text");
- bool exceptionThrown = false;
- try
- {
- ws.Cells["A1"].LoadFromText("\"text with eol,\r\n",
- new ExcelTextFormat { TextQualifier = '"', EOL = ",\r\n", Delimiter = ',' });
- }
- catch (Exception e)
- {
- Assert.AreEqual("Text delimiter is not closed in line : \"text with eol", e.Message, "Exception message");
- exceptionThrown = true;
- }
- Assert.IsTrue(exceptionThrown, "Exception thrown");
- }
-
- //[Ignore]
- //[TestMethod]
- public void LoadText()
- {
- var ws = _pck.Workbook.Worksheets.Add("Loaded Text");
-
- ws.Cells["A1"].LoadFromText("1.2");
- ws.Cells["A2"].LoadFromText("1,\"Test av data\",\"12,2\",\"\"Test\"\"");
- ws.Cells["A3"].LoadFromText("\"1,3\",\"Test av \"\"data\",\"12,2\",\"Test\"\"\"", new ExcelTextFormat() { TextQualifier = '"' });
-
- ws = _pck.Workbook.Worksheets.Add("File1");
- // ws.Cells["A1"].LoadFromText(new FileInfo(@"c:\temp\csv\et1c1004.csv"), new ExcelTextFormat() {SkipLinesBeginning=3,SkipLinesEnd=1, EOL="\n"});
-
- ws = _pck.Workbook.Worksheets.Add("File2");
- //ws.Cells["A1"].LoadFromText(new FileInfo(@"c:\temp\csv\etiv2812.csv"), new ExcelTextFormat() { SkipLinesBeginning = 3, SkipLinesEnd = 1, EOL = "\n" });
-
- //ws = _pck.Workbook.Worksheets.Add("File3");
- //ws.Cells["A1"].LoadFromText(new FileInfo(@"c:\temp\csv\last_gics.txt"), new ExcelTextFormat() { SkipLinesBeginning = 1, Delimiter='|'});
-
- ws = _pck.Workbook.Worksheets.Add("File4");
- //ws.Cells["A1"].LoadFromText(new FileInfo(@"c:\temp\csv\20060927.custom_open_positions.cdf.SPP"), new ExcelTextFormat() { SkipLinesBeginning = 2, SkipLinesEnd=2, TextQualifier='"', DataTypes=new eDataTypes[] {eDataTypes.Number,eDataTypes.String, eDataTypes.Number, eDataTypes.Number, eDataTypes.Number, eDataTypes.String, eDataTypes.Number, eDataTypes.Number, eDataTypes.String, eDataTypes.String, eDataTypes.Number, eDataTypes.Number, eDataTypes.Number}},
- // OfficeOpenXml.Table.TableStyles.Medium27, true);
-
- ws.Cells["A1"].LoadFromText("1,\"Test\",\"\",\"\"\"\",3", new ExcelTextFormat() { TextQualifier = '\"' });
-
- var style = _pck.Workbook.Styles.CreateNamedStyle("RedStyle");
- style.Style.Fill.PatternType = ExcelFillStyle.Solid;
- style.Style.Fill.BackgroundColor.SetColor(Color.Red);
-
- //var tbl = ws.Tables[ws.Tables.Count - 1];
- //tbl.ShowTotal = true;
- //tbl.TotalsRowCellStyle = "RedStyle";
- //tbl.HeaderRowCellStyle = "RedStyle";
- }
- [TestMethod]
- public void TestRepeatRowsAndColumnsTest()
- {
- var p = new ExcelPackage();
-
- var w = p.Workbook.Worksheets.Add("RepeatRowsAndColumnsTest");
-
- w.PrinterSettings.RepeatColumns = new ExcelAddress("A:A");
- w.PrinterSettings.RepeatRows = new ExcelAddress("1:1");
-
- Assert.IsNotNull(w.PrinterSettings.RepeatColumns);
- Assert.IsNotNull(w.PrinterSettings.RepeatRows); // Fails!
- }
- //[Ignore]
- //[TestMethod]
- public void Merge()
- {
- var ws = _pck.Workbook.Worksheets.Add("Merge");
- ws.Cells["A1:A4"].Merge = true;
- ws.Cells["C1:C4,C8:C12"].Merge = true;
- ws.Cells["D13:E18,G5,U32:U45"].Merge = true;
- ws.Cells["D13:E18,G5,U32:U45"].Style.WrapText = true;
- //ws.Cells["50:52"].Merge = true;
- ws.Cells["AA:AC"].Merge = true;
- ws.SetValue(13, 4, "Merged\r\nnew row");
- }
- //[Ignore]
- //[TestMethod]
- public void DefaultColWidth()
- {
- var ws = _pck.Workbook.Worksheets.Add("DefColWidth");
- ws.DefaultColWidth = 45;
- }
- //[Ignore]
- //[TestMethod]
- public void LoadArray()
- {
- var ws = _pck.Workbook.Worksheets.Add("Loaded Array");
- List<object[]> testArray = new List<object[]>() { new object[] { 3, 4, 5, 6 }, new string[] { "Test1", "test", "5", "6" } };
- ws.Cells["A1"].LoadFromArrays(testArray);
- }
- [Ignore]
- [TestMethod]
- public void DefColWidthBug()
- {
- ExcelWorkbook book = _pck.Workbook;
- ExcelWorksheet sheet = book.Worksheets.Add("Gebruikers");
-
- sheet.DefaultColWidth = 25d;
- //sheet.defaultRowHeight = 15d; // needed to make sure the resulting file is valid!
-
- // Create the header row
- sheet.Cells[1, 1].Value = "Afdeling code";
- sheet.Cells[1, 2].Value = "Afdeling naam";
- sheet.Cells[1, 3].Value = "Voornaam";
- sheet.Cells[1, 4].Value = "Tussenvoegsel";
- sheet.Cells[1, 5].Value = "Achternaam";
- sheet.Cells[1, 6].Value = "Gebruikersnaam";
- sheet.Cells[1, 7].Value = "E-mail adres";
- ExcelRange headerRow = sheet.Cells[1, 1, 1, 7];
- headerRow.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
- headerRow.Style.Font.Size = 12;
- headerRow.Style.Font.Bold = true;
-
- //// Create a context for retrieving the users
- //using (PalauDataContext context = new PalauDataContext())
- //{
- // int currentRow = 2;
-
- // // iterate through all users in the export and add their info
- // // to the worksheet.
- // foreach (vw_ExportUser user in
- // context.vw_ExportUsers
- // .OrderBy(u => u.DepartmentCode)
- // .ThenBy(u => u.AspNetUserName))
- // {
- // sheet.Cells[currentRow, 1].Value = user.DepartmentCode;
- // sheet.Cells[currentRow, 2].Value = user.DepartmentName;
- // sheet.Cells[currentRow, 3].Value = user.UserFirstName;
- // sheet.Cells[currentRow, 4].Value = user.UserInfix;
- // sheet.Cells[currentRow, 5].Value = user.UserSurname;
- // sheet.Cells[currentRow, 6].Value = user.AspNetUserName;
- // sheet.Cells[currentRow, 7].Value = user.AspNetEmail;
-
- // currentRow++;
- // }
- //}
-
- // return the filled Excel workbook
- // return pkg
-
- }
- [Ignore]
- [TestMethod]
- public void CloseProblem()
- {
- ExcelPackage pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Manual Receipts");
-
- ws.Cells["A1"].Value = " SpaceNeedle Manual Receipt Form";
-
- using (ExcelRange r = ws.Cells["A1:F1"])
- {
- r.Merge = true;
- r.Style.Font.SetFromFont(new Font("Arial", 18, FontStyle.Italic));
- r.Style.Font.Color.SetColor(Color.DarkRed);
- r.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.CenterContinuous;
- //r.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
- //r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23, 55, 93));
- }
- // ws.Column(1).BestFit = true;
- ws.Column(1).Width = 17;
- ws.Column(5).Width = 20;
-
-
- ws.Cells["A2"].Value = "Date Produced";
-
- ws.Cells["A2"].Style.Font.Bold = true;
- ws.Cells["B2"].Value = DateTime.Now.ToShortDateString();
- ws.Cells["D2"].Value = "Quantity";
- ws.Cells["D2"].Style.Font.Bold = true;
- ws.Cells["E2"].Value = "txt";
-
- ws.Cells["C4"].Value = "Receipt Number";
- ws.Cells["C4"].Style.WrapText = true;
- ws.Cells["C4"].Style.Font.Bold = true;
-
- int rowNbr = 5;
- for (int entryNbr = 1; entryNbr <= 1; entryNbr += 1)
- {
- ws.Cells["B" + rowNbr].Value = entryNbr;
- ws.Cells["C" + rowNbr].Value = 1 + entryNbr - 1;
- rowNbr += 1;
- }
- pck.SaveAs(new FileInfo(".\\test.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void OpenXlsm()
- {
- ExcelPackage p = new ExcelPackage(new FileInfo("c:\\temp\\cs1.xlsx"));
- int c = p.Workbook.Worksheets.Count;
- p.Save();
- }
- [Ignore]
- [TestMethod]
- public void Mergebug()
- {
- var xlPackage = new ExcelPackage();
- var xlWorkSheet = xlPackage.Workbook.Worksheets.Add("Test Sheet");
- var Cells = xlWorkSheet.Cells;
- var TitleCell = Cells[1, 1, 1, 3];
-
- TitleCell.Merge = true;
- TitleCell.Value = "Test Spreadsheet";
- Cells[2, 1].Value = "Test Sub Heading\r\ntest" + (char)22;
- for (int i = 0; i < 256; i++)
- {
- Cells[3, i + 1].Value = (char)i;
- }
- Cells[2, 1].Style.WrapText = true;
- xlWorkSheet.Row(1).Height = 50;
- xlPackage.SaveAs(new FileInfo("c:\\temp\\Mergebug.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void OpenProblem()
- {
- var xlPackage = new ExcelPackage();
- var ws = xlPackage.Workbook.Worksheets.Add("W1");
- xlPackage.Workbook.Worksheets.Add("W2");
-
- ws.Cells["A1:A10"].Formula = "W2!A1+C1";
- ws.Cells["B1:B10"].FormulaR1C1 = "W2!R1C1+C1";
- xlPackage.SaveAs(new FileInfo("c:\\temp\\Mergebug.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void ProtectionProblem()
- {
- var xlPackage = new ExcelPackage(new FileInfo("c:\\temp\\CovenantsCheckReportTemplate.xlsx"));
- var ws = xlPackage.Workbook.Worksheets.First();
- ws.Protection.SetPassword("Test");
- xlPackage.SaveAs(new FileInfo("c:\\temp\\Mergebug.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void Nametest()
- {
- var pck = new ExcelPackage(new FileInfo("c:\\temp\\names.xlsx"));
- var ws = pck.Workbook.Worksheets.First();
- ws.Cells["H37"].Formula = "\"Test\"";
- pck.SaveAs(new FileInfo(@"c:\\temp\\nametest_new.xlsx"));
- }
- //[Ignore]
- //[TestMethod]
- public void CreatePivotTable()
- {
- var wsPivot1 = _pck.Workbook.Worksheets.Add("Rows-Data on columns");
- var wsPivot2 = _pck.Workbook.Worksheets.Add("Rows-Data on rows");
- var wsPivot3 = _pck.Workbook.Worksheets.Add("Columns-Data on columns");
- var wsPivot4 = _pck.Workbook.Worksheets.Add("Columns-Data on rows");
- var wsPivot5 = _pck.Workbook.Worksheets.Add("Columns/Rows-Data on columns");
- var wsPivot6 = _pck.Workbook.Worksheets.Add("Columns/Rows-Data on rows");
- var wsPivot7 = _pck.Workbook.Worksheets.Add("Rows/Page-Data on Columns");
- var wsPivot8 = _pck.Workbook.Worksheets.Add("Pivot-Group Date");
- var wsPivot9 = _pck.Workbook.Worksheets.Add("Pivot-Group Number");
-
- var ws = _pck.Workbook.Worksheets.Add("Data");
- ws.Cells["K1"].Value = "Item";
- ws.Cells["L1"].Value = "Category";
- ws.Cells["M1"].Value = "Stock";
- ws.Cells["N1"].Value = "Price";
- ws.Cells["O1"].Value = "Date for grouping";
-
- ws.Cells["K2"].Value = "Crowbar";
- ws.Cells["L2"].Value = "Hardware";
- ws.Cells["M2"].Value = 12;
- ws.Cells["N2"].Value = 85.2;
- ws.Cells["O2"].Value = new DateTime(2010, 1, 31);
-
- ws.Cells["K3"].Value = "Crowbar";
- ws.Cells["L3"].Value = "Hardware";
- ws.Cells["M3"].Value = 15;
- ws.Cells["N3"].Value = 12.2;
- ws.Cells["O3"].Value = new DateTime(2010, 2, 28);
-
- ws.Cells["K4"].Value = "Hammer";
- ws.Cells["L4"].Value = "Hardware";
- ws.Cells["M4"].Value = 550;
- ws.Cells["N4"].Value = 72.7;
- ws.Cells["O4"].Value = new DateTime(2010, 3, 31);
-
- ws.Cells["K5"].Value = "Hammer";
- ws.Cells["L5"].Value = "Hardware";
- ws.Cells["M5"].Value = 120;
- ws.Cells["N5"].Value = 11.3;
- ws.Cells["O5"].Value = new DateTime(2010, 4, 30);
-
- ws.Cells["K6"].Value = "Crowbar";
- ws.Cells["L6"].Value = "Hardware";
- ws.Cells["M6"].Value = 120;
- ws.Cells["N6"].Value = 173.2;
- ws.Cells["O6"].Value = new DateTime(2010, 5, 31);
-
- ws.Cells["K7"].Value = "Hammer";
- ws.Cells["L7"].Value = "Hardware";
- ws.Cells["M7"].Value = 1;
- ws.Cells["N7"].Value = 4.2;
- ws.Cells["O7"].Value = new DateTime(2010, 6, 30);
-
- ws.Cells["K8"].Value = "Saw";
- ws.Cells["L8"].Value = "Hardware";
- ws.Cells["M8"].Value = 4;
- ws.Cells["N8"].Value = 33.12;
- ws.Cells["O8"].Value = new DateTime(2010, 6, 28);
-
- ws.Cells["K9"].Value = "Screwdriver";
- ws.Cells["L9"].Value = "Hardware";
- ws.Cells["M9"].Value = 1200;
- ws.Cells["N9"].Value = 45.2;
- ws.Cells["O9"].Value = new DateTime(2010, 8, 31);
-
- ws.Cells["K10"].Value = "Apple";
- ws.Cells["L10"].Value = "Groceries";
- ws.Cells["M10"].Value = 807;
- ws.Cells["N10"].Value = 1.2;
- ws.Cells["O10"].Value = new DateTime(2010, 9, 30);
-
- ws.Cells["K11"].Value = "Butter";
- ws.Cells["L11"].Value = "Groceries";
- ws.Cells["M11"].Value = 52;
- ws.Cells["N11"].Value = 7.2;
- ws.Cells["O11"].Value = new DateTime(2010, 10, 31);
- ws.Cells["O2:O11"].Style.Numberformat.Format = "yyyy-MM-dd";
-
- var pt = wsPivot1.PivotTables.Add(wsPivot1.Cells["A1"], ws.Cells["K1:N11"], "Pivottable1");
- pt.GrandTotalCaption = "Total amount";
- pt.RowFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataFields[0].Function = DataFieldFunctions.Product;
- pt.DataOnRows = false;
-
- pt = wsPivot2.PivotTables.Add(wsPivot2.Cells["A1"], ws.Cells["K1:N11"], "Pivottable2");
- pt.RowFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataFields[0].Function = DataFieldFunctions.Average;
- pt.DataOnRows = true;
-
- pt = wsPivot3.PivotTables.Add(wsPivot3.Cells["A1"], ws.Cells["K1:N11"], "Pivottable3");
- pt.ColumnFields.Add(pt.Fields[1]);
- pt.ColumnFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = false;
-
- pt = wsPivot4.PivotTables.Add(wsPivot4.Cells["A1"], ws.Cells["K1:N11"], "Pivottable4");
- pt.ColumnFields.Add(pt.Fields[1]);
- pt.ColumnFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = true;
-
- pt = wsPivot5.PivotTables.Add(wsPivot5.Cells["A1"], ws.Cells["K1:N11"], "Pivottable5");
- pt.ColumnFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = false;
-
- pt = wsPivot6.PivotTables.Add(wsPivot6.Cells["A1"], ws.Cells["K1:N11"], "Pivottable6");
- pt.ColumnFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = true;
- wsPivot6.Drawings.AddChart("Pivotchart6", OfficeOpenXml.Drawing.Chart.eChartType.BarStacked3D, pt);
-
- pt = wsPivot7.PivotTables.Add(wsPivot7.Cells["A3"], ws.Cells["K1:N11"], "Pivottable7");
- pt.PageFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[0]);
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = false;
-
- pt.Fields[0].SubTotalFunctions = eSubTotalFunctions.Sum | eSubTotalFunctions.Max;
- Assert.AreEqual(pt.Fields[0].SubTotalFunctions, eSubTotalFunctions.Sum | eSubTotalFunctions.Max);
-
- pt.Fields[0].SubTotalFunctions = eSubTotalFunctions.Sum | eSubTotalFunctions.Product | eSubTotalFunctions.StdDevP;
- Assert.AreEqual(pt.Fields[0].SubTotalFunctions, eSubTotalFunctions.Sum | eSubTotalFunctions.Product | eSubTotalFunctions.StdDevP);
-
- pt.Fields[0].SubTotalFunctions = eSubTotalFunctions.None;
- Assert.AreEqual(pt.Fields[0].SubTotalFunctions, eSubTotalFunctions.None);
-
- pt.Fields[0].SubTotalFunctions = eSubTotalFunctions.Default;
- Assert.AreEqual(pt.Fields[0].SubTotalFunctions, eSubTotalFunctions.Default);
-
- pt.Fields[0].Sort = eSortType.Descending;
- pt.TableStyle = OfficeOpenXml.Table.TableStyles.Medium14;
-
- pt = wsPivot8.PivotTables.Add(wsPivot8.Cells["A3"], ws.Cells["K1:O11"], "Pivottable8");
- pt.RowFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[4]);
- pt.Fields[4].AddDateGrouping(eDateGroupBy.Years | eDateGroupBy.Months | eDateGroupBy.Days | eDateGroupBy.Quarters, new DateTime(2010, 01, 31), new DateTime(2010, 11, 30));
- pt.RowHeaderCaption = "År";
- pt.Fields[4].Name = "Dag";
- pt.Fields[5].Name = "Månad";
- pt.Fields[6].Name = "Kvartal";
- pt.GrandTotalCaption = "Totalt";
-
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = true;
-
- pt = wsPivot9.PivotTables.Add(wsPivot9.Cells["A3"], ws.Cells["K1:N11"], "Pivottable9");
- pt.PageFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[3]);
- pt.RowFields[0].AddNumericGrouping(-3.3, 5.5, 4.0);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = false;
- pt.TableStyle = OfficeOpenXml.Table.TableStyles.Medium14;
-
- pt = wsPivot8.PivotTables.Add(wsPivot8.Cells["H3"], ws.Cells["K1:O11"], "Pivottable10");
- pt.RowFields.Add(pt.Fields[1]);
- pt.RowFields.Add(pt.Fields[4]);
- pt.Fields[4].AddDateGrouping(7, new DateTime(2010, 01, 31), new DateTime(2010, 11, 30));
- pt.RowHeaderCaption = "Veckor";
- pt.GrandTotalCaption = "Totalt";
-
- pt = wsPivot8.PivotTables.Add(wsPivot8.Cells["A60"], ws.Cells["K1:O11"], "Pivottable11");
- pt.RowFields.Add(pt.Fields["Category"]);
- pt.RowFields.Add(pt.Fields["Item"]);
- pt.RowFields.Add(pt.Fields["Date for grouping"]);
-
- pt.DataFields.Add(pt.Fields[3]);
- pt.DataFields.Add(pt.Fields[2]);
- pt.DataOnRows = true;
- }
- [Ignore]
- [TestMethod]
- public void ReadPivotTable()
- {
- ExcelPackage pck = new ExcelPackage(new FileInfo(@"c:\temp\pivot\pivotforread.xlsx"));
-
- var pivot1 = pck.Workbook.Worksheets[2].PivotTables[0];
-
- Assert.AreEqual(pivot1.Fields.Count, 24);
- Assert.AreEqual(pivot1.RowFields.Count, 3);
- Assert.AreEqual(pivot1.DataFields.Count, 7);
- Assert.AreEqual(pivot1.ColumnFields.Count, 0);
-
- Assert.AreEqual(pivot1.DataFields[1].Name, "Sum of n3");
- Assert.AreEqual(pivot1.Fields[2].Sort, eSortType.Ascending);
-
- Assert.AreEqual(pivot1.DataOnRows, false);
-
- var pivot2 = pck.Workbook.Worksheets[2].PivotTables[0];
- var pivot3 = pck.Workbook.Worksheets[3].PivotTables[0];
-
- var pivot4 = pck.Workbook.Worksheets[4].PivotTables[0];
- var pivot5 = pck.Workbook.Worksheets[5].PivotTables[0];
- pivot5.CacheDefinition.SourceRange = pck.Workbook.Worksheets[1].Cells["Q1:X300"];
-
- var pivot6 = pck.Workbook.Worksheets[6].PivotTables[0];
-
- pck.Workbook.Worksheets[6].Drawings.AddChart("chart1", OfficeOpenXml.Drawing.Chart.eChartType.ColumnStacked3D, pivot6);
-
- pck.SaveAs(new FileInfo(@"c:\temp\pivot\pivotforread_new.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void CreatePivotMultData()
- {
- FileInfo fi = new FileInfo(@"c:\temp\test.xlsx");
- ExcelPackage pck = new ExcelPackage(fi);
-
- var ws = pck.Workbook.Worksheets.Add("Data");
- var pv = pck.Workbook.Worksheets.Add("Pivot");
-
- ws.Cells["A1"].Value = "Data1";
- ws.Cells["B1"].Value = "Data2";
-
- ws.Cells["A2"].Value = "1";
- ws.Cells["B2"].Value = "2";
-
- ws.Cells["A3"].Value = "3";
- ws.Cells["B3"].Value = "4";
-
- ws.Select("A1:B3");
-
- var pt = pv.PivotTables.Add(pv.SelectedRange, ws.SelectedRange, "Pivot");
-
- pt.RowFields.Add(pt.Fields["Data2"]);
-
- var df = pt.DataFields.Add(pt.Fields["Data1"]);
- df.Function = DataFieldFunctions.Count;
-
- df = pt.DataFields.Add(pt.Fields["Data1"]);
- df.Function = DataFieldFunctions.Sum;
-
- df = pt.DataFields.Add(pt.Fields["Data1"]);
- df.Function = DataFieldFunctions.StdDev;
- df.Name = "DatA1_2";
-
- pck.Save();
- }
- //[Ignore]
- [TestMethod]
- public void SetBackground()
- {
- var ws = _pck.Workbook.Worksheets.Add("backimg");
-
- ws.BackgroundImage.Image = Properties.Resources.Test1;
- ws = _pck.Workbook.Worksheets.Add("backimg2");
- ws.BackgroundImage.SetFromFile(new FileInfo(Path.Combine(_clipartPath,"Vector Drawing.wmf")));
- }
- //[Ignore]
- [TestMethod]
- public void SetHeaderFooterImage()
- {
-
- var ws = _pck.Workbook.Worksheets.Add("HeaderImage");
- ws.HeaderFooter.OddHeader.CenteredText = "Before ";
- var img = ws.HeaderFooter.OddHeader.InsertPicture(Properties.Resources.Test1, PictureAlignment.Centered);
- img.Title = "Renamed Image";
- img.GrayScale = true;
- img.BiLevel = true;
- img.Gain = .5;
- img.Gamma = .35;
-
- Assert.AreEqual(img.Width, 426);
- img.Width /= 4;
- Assert.AreEqual(img.Height, 49.5);
- img.Height /= 4;
- Assert.AreEqual(img.Left, 0);
- Assert.AreEqual(img.Top, 0);
- ws.HeaderFooter.OddHeader.CenteredText += " After";
-
-
- img = ws.HeaderFooter.EvenFooter.InsertPicture(new FileInfo(Path.Combine(_clipartPath,"Vector Drawing.wmf")), PictureAlignment.Left);
- img.Title = "DiskFile";
-
- img = ws.HeaderFooter.FirstHeader.InsertPicture(new FileInfo(Path.Combine(_clipartPath, "Vector Drawing2.WMF")), PictureAlignment.Right);
- img.Title = "DiskFile2";
- ws.Cells["A1:A400"].Value = 1;
-
- _pck.Workbook.Worksheets.Copy(ws.Name, "Copied HeaderImage");
- }
- //[Ignore]
- //[TestMethod]
- public void NamedStyles()
- {
- var wsSheet = _pck.Workbook.Worksheets.Add("NamedStyles");
-
- var firstNamedStyle =
- _pck.Workbook.Styles.CreateNamedStyle("templateFirst");
-
- var s = firstNamedStyle.Style;
-
- s.Fill.PatternType = ExcelFillStyle.Solid;
- s.Fill.BackgroundColor.SetColor(Color.LightGreen);
- s.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
- s.VerticalAlignment = ExcelVerticalAlignment.Center;
-
- var secondNamedStyle = _pck.Workbook.Styles.CreateNamedStyle("first", firstNamedStyle.Style).Style;
- secondNamedStyle.Font.Bold = true;
- secondNamedStyle.Font.SetFromFont(new Font("Arial Black", 8));
- secondNamedStyle.Border.Bottom.Style = ExcelBorderStyle.Medium;
- secondNamedStyle.Border.Left.Style = ExcelBorderStyle.Medium;
-
- wsSheet.Cells["B2"].Value = "Text Center";
- wsSheet.Cells["B2"].StyleName = "first";
- _pck.Workbook.Styles.NamedStyles[0].Style.Font.Name = "Arial";
-
- var rowStyle = _pck.Workbook.Styles.CreateNamedStyle("RowStyle", firstNamedStyle.Style).Style;
- rowStyle.Fill.BackgroundColor.SetColor(Color.Pink);
- wsSheet.Cells.StyleName = "templateFirst";
- wsSheet.Cells["C5:H15"].Style.Fill.PatternType = ExcelFillStyle.Solid;
- wsSheet.Cells["C5:H15"].Style.Fill.BackgroundColor.SetColor(Color.OrangeRed);
-
- wsSheet.Cells["30:35"].StyleName = "RowStyle";
- var colStyle = _pck.Workbook.Styles.CreateNamedStyle("columnStyle", firstNamedStyle.Style).Style;
- colStyle.Fill.BackgroundColor.SetColor(Color.CadetBlue);
-
- wsSheet.Cells["D:E"].StyleName = "ColumnStyle";
- }
- //[Ignore]
- //[TestMethod]
- public void StyleFill()
- {
- var ws = _pck.Workbook.Worksheets.Add("Fills");
- ws.Cells["A1:C3"].Style.Fill.Gradient.Type = ExcelFillGradientType.Linear;
- ws.Cells["A1:C3"].Style.Fill.Gradient.Color1.SetColor(Color.Red);
- ws.Cells["A1:C3"].Style.Fill.Gradient.Color2.SetColor(Color.Blue);
-
- ws.Cells["A1"].Style.Fill.PatternType = ExcelFillStyle.MediumGray;
- ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(Color.ForestGreen);
- var r = ws.Cells["A2:A3"];
- r.Style.Fill.Gradient.Type = ExcelFillGradientType.Path;
- r.Style.Fill.Gradient.Left = 0.7;
- r.Style.Fill.Gradient.Right = 0.7;
- r.Style.Fill.Gradient.Top = 0.7;
- r.Style.Fill.Gradient.Bottom = 0.7;
-
- ws.Cells[4, 1, 4, 360].Style.Fill.Gradient.Type = ExcelFillGradientType.Path;
-
- for (double col = 1; col < 360; col++)
- {
- r = ws.Cells[4, Convert.ToInt32(col)];
- r.Style.Fill.Gradient.Degree = col;
- r.Style.Fill.Gradient.Left = col / 360;
- r.Style.Fill.Gradient.Right = col / 360;
- r.Style.Fill.Gradient.Top = col / 360;
- r.Style.Fill.Gradient.Bottom = col / 360;
- }
- r = ws.Cells["A5"];
- r.Style.Fill.Gradient.Left = .50;
-
- ws = _pck.Workbook.Worksheets.Add("FullFills");
- ws.Cells.Style.Fill.Gradient.Left = 0.25;
- ws.Cells["A1"].Value = "test";
- ws.Cells["A1"].RichText.Add("Test rt");
- ws.Cells.AutoFilter = true;
- Assert.AreNotEqual(ws.Cells["A1:D5"].Value, null);
- }
- [Ignore]
- [TestMethod]
- public void BuildInStyles()
- {
- var pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Default");
- ws.Cells.Style.Font.Name = "Arial";
- ws.Cells.Style.Font.Size = 15;
- ws.Cells.Style.Border.Bottom.Style = ExcelBorderStyle.MediumDashed;
- var n = pck.Workbook.Styles.NamedStyles[0];
- n.Style.Numberformat.Format = "yyyy";
- n.Style.Font.Name = "Arial";
- n.Style.Font.Size = 15;
- n.Style.Border.Bottom.Style = ExcelBorderStyle.Dotted;
- n.Style.Border.Bottom.Color.SetColor(Color.Red);
- n.Style.Fill.PatternType = ExcelFillStyle.Solid;
- n.Style.Fill.BackgroundColor.SetColor(Color.Blue);
- n.Style.Border.Bottom.Color.SetColor(Color.Red);
- n.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
- n.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
- n.Style.TextRotation = 90;
- ws.Cells["a1:c3"].StyleName = "Normal";
- // n.CustomBuildin = true;
- pck.SaveAs(new FileInfo(@"c:\temp\style.xlsx"));
- }
- //[Ignore]
- //[TestMethod]
- public void AutoFitColumns()
- {
- var ws = _pck.Workbook.Worksheets.Add("Autofit");
- ws.Cells["A1:H1"].Value = "Auto fit column that is veeery long...";
- ws.Cells["B1"].Style.TextRotation = 30;
- ws.Cells["C1"].Style.TextRotation = 45;
- ws.Cells["D1"].Style.TextRotation = 75;
- ws.Cells["E1"].Style.TextRotation = 90;
- ws.Cells["F1"].Style.TextRotation = 120;
- ws.Cells["G1"].Style.TextRotation = 135;
- ws.Cells["H1"].Style.TextRotation = 180;
- ws.Cells["A1:H1"].AutoFitColumns(0);
- }
-
- [TestMethod, Ignore]
- public void Moveissue()
- {
- _pck = new ExcelPackage(new FileInfo(@"C:\temp\bug\FormulaIssue\PreDelete.xlsx"));
- _pck.Workbook.Worksheets[1].DeleteRow(2, 4);
- _pck.SaveAs(new FileInfo(@"c:\temp\move.xlsx"));
- }
- [TestMethod, Ignore]
- public void DelCol()
- {
- _pck = new ExcelPackage(new FileInfo(@"C:\temp\bug\FormulaIssue\PreDeleteCol.xlsx"));
- _pck.Workbook.Worksheets[1].DeleteColumn(5, 1);
- _pck.SaveAs(new FileInfo(@"c:\temp\move.xlsx"));
- }
- [TestMethod, Ignore]
- public void InsCol()
- {
- _pck = new ExcelPackage(new FileInfo(@"C:\temp\bug\FormulaIssue\PreDeleteCol.xlsx"));
- _pck.Workbook.Worksheets[1].InsertColumn(4, 5);
- _pck.SaveAs(new FileInfo(@"c:\temp\move.xlsx"));
- }
- [Ignore]
- [TestMethod]
- public void FileLockedProblem()
- {
- using (ExcelPackage pck = new ExcelPackage(new FileInfo(@"c:\temp\url.xlsx")))
- {
- pck.Workbook.Worksheets[1].DeleteRow(1, 1);
- pck.Save();
- pck.Dispose();
- }
- }
- //[Ignore]
- //[TestMethod]
- public void CopyOverwrite()
- {
- var ws = _pck.Workbook.Worksheets.Add("CopyOverwrite");
-
- for (int col = 1; col < 15; col++)
- {
- for (int row = 1; row < 30; row++)
- {
- ws.SetValue(row, col, "cell " + ExcelAddressBase.GetAddress(row, col));
- }
- }
- ws.Cells["A1:P30"].Copy(ws.Cells["B1"]);
- }
- [Ignore]
- [TestMethod]
- public void RunSample0()
- {
- FileInfo newFile = new FileInfo(@"c:\temp\bug\sample0.xlsx");
- using (ExcelPackage package = new ExcelPackage(newFile))
- {
- ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
- worksheet.InsertColumn(1, 1);
-
- ExcelColumn entireColumn = worksheet.Column(1);
-
- var last = worksheet.Column(6);
- last.Style.Fill.PatternType = ExcelFillStyle.Solid;
- last.Style.Fill.BackgroundColor.SetColor(Color.Blue);
- last.ColumnMax = 7;
- worksheet.InsertColumn(7, 1);
-
- //save our new workbook and we are done!
- package.Save();
- }
- }
- [Ignore]
- [TestMethod]
- public void Deletews()
- {
- FileInfo newFile = new FileInfo(@"c:\temp\bug\worksheet error.xlsx");
- using (ExcelPackage package = new ExcelPackage(newFile))
- {
- var ws1 = package.Workbook.Worksheets.Add("sheet1");
- var ws2 = package.Workbook.Worksheets.Add("sheet2");
- var ws3 = package.Workbook.Worksheets.Add("sheet3");
-
- package.Workbook.Worksheets.MoveToStart(ws3.Name);
- //save our new workbook and we are done!
- package.Save();
- }
- using (ExcelPackage package = new ExcelPackage(newFile))
- {
- package.Workbook.Worksheets.Delete(1);
- var ws3 = package.Workbook.Worksheets.Add("sheet3");
- package.SaveAs(new FileInfo(@"c:\temp\bug\worksheet error_save.xlsx"));
- }
- }
-
- [TestMethod, Ignore]
- public void Issue15207()
- {
- using (ExcelPackage ep = new ExcelPackage(new FileInfo(@"c:\temp\bug\worksheet error.xlsx")))
- {
- ExcelWorkbook wb = ep.Workbook;
-
- if (wb != null)
- {
- ExcelWorksheet ws = null;
-
- ws = wb.Worksheets[1];
-
- if (ws != null)
- {
- //do something with the worksheet
- ws.Dispose();
- }
-
- wb.Dispose();
-
- } //if wb != null
-
- wb = null;
-
- //do some other things
-
- //running through this next line now throws the null reference exception
- //so the inbuilt dispose method doesn't work properly.
- } //using (ExcelPackage ep = new ExcelPackage(new FileInfo(some_file))
- }
- #region Date1904 Test Cases
- [TestMethod]
- public void TestDate1904WithoutSetting()
- {
- string file = "test1904.xlsx";
- DateTime dateTest1 = new DateTime(2008, 2, 29);
- DateTime dateTest2 = new DateTime(1950, 11, 30);
-
- if (File.Exists(file))
- File.Delete(file);
-
- ExcelPackage pack = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w = pack.Workbook.Worksheets.Add("test");
- w.Cells[1, 1, 2, 1].Style.Numberformat.Format = ExcelNumberFormat.GetFromBuildInFromID(14);
- w.Cells[1, 1].Value = dateTest1;
- w.Cells[2, 1].Value = dateTest2;
- pack.Save();
-
-
- ExcelPackage pack2 = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w2 = pack2.Workbook.Worksheets["test"];
-
- Assert.AreEqual(dateTest1, w2.Cells[1, 1].Value);
- Assert.AreEqual(dateTest2, w2.Cells[2, 1].Value);
- }
-
- [TestMethod]
- public void TestDate1904WithSetting()
- {
- string file = "test1904.xlsx";
- DateTime dateTest1 = new DateTime(2008, 2, 29);
- DateTime dateTest2 = new DateTime(1950, 11, 30);
-
- if (File.Exists(file))
- File.Delete(file);
-
- ExcelPackage pack = new ExcelPackage(new FileInfo(file));
- pack.Workbook.Date1904 = true;
-
- ExcelWorksheet w = pack.Workbook.Worksheets.Add("test");
- w.Cells[1, 1, 2, 1].Style.Numberformat.Format = ExcelNumberFormat.GetFromBuildInFromID(14);
- w.Cells[1, 1].Value = dateTest1;
- w.Cells[2, 1].Value = dateTest2;
- pack.Save();
-
-
- ExcelPackage pack2 = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w2 = pack2.Workbook.Worksheets["test"];
-
- Assert.AreEqual(dateTest1, w2.Cells[1, 1].Value);
- Assert.AreEqual(dateTest2, w2.Cells[2, 1].Value);
- }
-
- [TestMethod]
- public void TestDate1904SetAndRemoveSetting()
- {
- string file = "test1904.xlsx";
- DateTime dateTest1 = new DateTime(2008, 2, 29);
- DateTime dateTest2 = new DateTime(1950, 11, 30);
-
- if (File.Exists(file))
- File.Delete(file);
-
- ExcelPackage pack = new ExcelPackage(new FileInfo(file));
- pack.Workbook.Date1904 = true;
-
- ExcelWorksheet w = pack.Workbook.Worksheets.Add("test");
- w.Cells[1, 1, 2, 1].Style.Numberformat.Format = ExcelNumberFormat.GetFromBuildInFromID(14);
- w.Cells[1, 1].Value = dateTest1;
- w.Cells[2, 1].Value = dateTest2;
- pack.Save();
-
-
- ExcelPackage pack2 = new ExcelPackage(new FileInfo(file));
- pack2.Workbook.Date1904 = false;
- pack2.Save();
-
-
- ExcelPackage pack3 = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w3 = pack3.Workbook.Worksheets["test"];
-
- Assert.AreEqual(dateTest1.AddDays(365.5 * -4), w3.Cells[1, 1].Value);
- Assert.AreEqual(dateTest2.AddDays(365.5 * -4), w3.Cells[2, 1].Value);
- }
-
- [TestMethod]
- public void TestDate1904SetAndSetSetting()
- {
- string file = "test1904.xlsx";
- DateTime dateTest1 = new DateTime(2008, 2, 29);
- DateTime dateTest2 = new DateTime(1950, 11, 30);
-
- if (File.Exists(file))
- File.Delete(file);
-
- ExcelPackage pack = new ExcelPackage(new FileInfo(file));
- pack.Workbook.Date1904 = true;
-
- ExcelWorksheet w = pack.Workbook.Worksheets.Add("test");
- w.Cells[1, 1, 2, 1].Style.Numberformat.Format = ExcelNumberFormat.GetFromBuildInFromID(14);
- w.Cells[1, 1].Value = dateTest1;
- w.Cells[2, 1].Value = dateTest2;
- pack.Save();
-
-
- ExcelPackage pack2 = new ExcelPackage(new FileInfo(file));
- pack2.Workbook.Date1904 = true; // Only the cells must be updated when this change, if set the same nothing must change
- pack2.Save();
-
-
- ExcelPackage pack3 = new ExcelPackage(new FileInfo(file));
- ExcelWorksheet w3 = pack3.Workbook.Worksheets["test"];
-
- Assert.AreEqual(dateTest1, w3.Cells[1, 1].Value);
- Assert.AreEqual(dateTest2, w3.Cells[2, 1].Value);
- }
- [TestMethod, Ignore]
- public void SaveToStream()
- {
- var stream = new MemoryStream(File.ReadAllBytes(@"c:\temp\book1.xlsx"));
- var excelPackage = new ExcelPackage(stream);
- excelPackage.Workbook.Worksheets.Add("test");
- excelPackage.Save();
- var s = stream.ToArray();
- }
- [TestMethod, Ignore]
- public void ColumnsTest()
- {
- var excelPackage = new ExcelPackage();
- var ws = excelPackage.Workbook.Worksheets.Add("ColumnTest");
-
-
- for (var c = 4; c <= 20; c += 4)
- {
- var col = ws.Column(c);
- col.ColumnMax = c + 3;
- }
-
- ws.Column(3).Hidden = true;
- ws.Column(6).Hidden = true;
- ws.Column(9).Hidden = true;
- ws.Column(15).Hidden = true;
- ws.Cells["a1:Z1"].Value = "Test";
- ws.Cells["a1:FF33"].AutoFitColumns(0);
- ws.Column(26).ColumnMax = ExcelPackage.MaxColumns;
- excelPackage.SaveAs(new FileInfo(@"c:\temp\autofit.xlsx"));
- }
-
- [TestMethod]
- public void Comment()
- {
- InitBase();
- var pck = new ExcelPackage();
- var ws1 = pck.Workbook.Worksheets.Add("Comment1");
- ws1.Cells[1, 1].AddComment("Testing", "test1");
-
- pck.SaveAs(new FileInfo(_worksheetPath + "comment.xlsx"));
-
- pck = new ExcelPackage(new FileInfo(_worksheetPath + "comment.xlsx"));
- var ws2 = pck.Workbook.Worksheets[1];
- ws2.Cells[1, 2].AddComment("Testing", "test1");
- pck.Save();
- }
- #endregion
- }
-}
diff --git a/EPPlusTest/Workbooks/FormulaTest.xlsx b/EPPlusTest/Workbooks/FormulaTest.xlsx
deleted file mode 100644
index dcaa304..0000000
--- a/EPPlusTest/Workbooks/FormulaTest.xlsx
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/Workbooks/MultiColorConditionalFormatting.xlsx b/EPPlusTest/Workbooks/MultiColorConditionalFormatting.xlsx
deleted file mode 100644
index 6bb9677..0000000
--- a/EPPlusTest/Workbooks/MultiColorConditionalFormatting.xlsx
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/Workbooks/VBADecompressBug.xlsm b/EPPlusTest/Workbooks/VBADecompressBug.xlsm
deleted file mode 100644
index 27dd306..0000000
--- a/EPPlusTest/Workbooks/VBADecompressBug.xlsm
+++ /dev/null
Binary files differ
diff --git a/EPPlusTest/WorksheetsTests.cs b/EPPlusTest/WorksheetsTests.cs
deleted file mode 100644
index 27cee9f..0000000
--- a/EPPlusTest/WorksheetsTests.cs
+++ /dev/null
@@ -1,281 +0,0 @@
-using System;
-using System.IO;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using OfficeOpenXml;
-using System.Reflection;
-
-namespace EPPlusTest
-{
- [TestClass]
- public class WorksheetsTests
- {
- private ExcelPackage package;
- private ExcelWorkbook workbook;
-
- [TestInitialize]
- public void TestInitialize()
- {
- package = new ExcelPackage();
- workbook = package.Workbook;
- workbook.Worksheets.Add("NEW1");
- }
-
- [TestMethod]
- public void ConfirmFileStructure()
- {
- Assert.IsNotNull(package, "Package not created");
- Assert.IsNotNull(workbook, "No workbook found");
- }
-
- [TestMethod]
- public void ShouldBeAbleToDeleteAndThenAdd()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Delete(1);
- workbook.Worksheets.Add("NEW3");
- }
-
- [TestMethod]
- public void DeleteByNameWhereWorkSheetExists()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Delete("NEW2");
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void DeleteByNameWhereWorkSheetDoesNotExist()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Delete("NEW3");
- }
-
- [TestMethod]
- public void MoveBeforeByNameWhereWorkSheetExists()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Add("NEW3");
- workbook.Worksheets.Add("NEW4");
- workbook.Worksheets.Add("NEW5");
-
- workbook.Worksheets.MoveBefore("NEW4", "NEW2");
-
- CompareOrderOfWorksheetsAfterSaving(package);
- }
-
- [TestMethod]
- public void MoveAfterByNameWhereWorkSheetExists()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Add("NEW3");
- workbook.Worksheets.Add("NEW4");
- workbook.Worksheets.Add("NEW5");
-
- workbook.Worksheets.MoveAfter("NEW4", "NEW2");
-
- CompareOrderOfWorksheetsAfterSaving(package);
- }
-
- [TestMethod]
- public void MoveBeforeByPositionWhereWorkSheetExists()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Add("NEW3");
- workbook.Worksheets.Add("NEW4");
- workbook.Worksheets.Add("NEW5");
-
- workbook.Worksheets.MoveBefore(4, 2);
-
- CompareOrderOfWorksheetsAfterSaving(package);
- }
-
- [TestMethod]
- public void MoveAfterByPositionWhereWorkSheetExists()
- {
- workbook.Worksheets.Add("NEW2");
- workbook.Worksheets.Add("NEW3");
- workbook.Worksheets.Add("NEW4");
- workbook.Worksheets.Add("NEW5");
-
- workbook.Worksheets.MoveAfter(4, 2);
-
- CompareOrderOfWorksheetsAfterSaving(package);
- }
- #region Delete Column with Save Tests
-
- private const string OutputDirectory = @"d:\temp\";
-
- [TestMethod]
- public void DeleteFirstColumnInRangeColumnShouldBeDeleted()
- {
- // Arrange
- ExcelPackage pck = new ExcelPackage();
- using (
- Stream file =
- Assembly.GetExecutingAssembly()
- .GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
- {
- pck.Load(file);
- }
- var wsData = pck.Workbook.Worksheets[1];
-
- // Act
- wsData.DeleteColumn(1);
- pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
-
- // Assert
- Assert.AreEqual("Title", wsData.Cells["A1"].Text);
- Assert.AreEqual("First Name", wsData.Cells["B1"].Text);
- Assert.AreEqual("Family Name", wsData.Cells["C1"].Text);
- }
-
-
- [TestMethod]
- public void DeleteLastColumnInRangeColumnShouldBeDeleted()
- {
- // Arrange
- ExcelPackage pck = new ExcelPackage();
- using (
- Stream file =
- Assembly.GetExecutingAssembly()
- .GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
- {
- pck.Load(file);
- }
- var wsData = pck.Workbook.Worksheets[1];
-
- // Act
- wsData.DeleteColumn(4);
- pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
-
- // Assert
- Assert.AreEqual("Id", wsData.Cells["A1"].Text);
- Assert.AreEqual("Title", wsData.Cells["B1"].Text);
- Assert.AreEqual("First Name", wsData.Cells["C1"].Text);
- }
-
- [TestMethod]
- public void DeleteColumnAfterNormalRangeSheetShouldRemainUnchanged()
- {
- // Arrange
- ExcelPackage pck = new ExcelPackage();
- using (
- Stream file =
- Assembly.GetExecutingAssembly()
- .GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
- {
- pck.Load(file);
- }
- var wsData = pck.Workbook.Worksheets[1];
-
- // Act
- wsData.DeleteColumn(5);
- pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
-
- // Assert
- Assert.AreEqual("Id", wsData.Cells["A1"].Text);
- Assert.AreEqual("Title", wsData.Cells["B1"].Text);
- Assert.AreEqual("First Name", wsData.Cells["C1"].Text);
- Assert.AreEqual("Family Name", wsData.Cells["D1"].Text);
-
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentException))]
- public void DeleteColumnBeforeRangeMimitThrowsArgumentException()
- {
- // Arrange
- ExcelPackage pck = new ExcelPackage();
- using (
- Stream file =
- Assembly.GetExecutingAssembly()
- .GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
- {
- pck.Load(file);
- }
- var wsData = pck.Workbook.Worksheets[1];
-
- // Act
- wsData.DeleteColumn(0);
-
- // Assert
- Assert.Fail();
-
- }
-
- [TestMethod]
- [ExpectedException(typeof(ArgumentException))]
- public void DeleteColumnAfterRangeLimitThrowsArgumentException()
- {
- // Arrange
- ExcelPackage pck = new ExcelPackage();
- using (
- Stream file =
- Assembly.GetExecutingAssembly()
- .GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
- {
- pck.Load(file);
- }
- var wsData = pck.Workbook.Worksheets[1];
-
- // Act
- wsData.DeleteColumn(16385);
-
- // Assert
- Assert.Fail();
-
- }
-
- [TestMethod]
- public void DeleteFirstTwoColumnsFromRangeColumnsShouldBeDeleted()
- {
- // Arrange
- ExcelPackage pck = new ExcelPackage();
- using (
- Stream file =
- Assembly.GetExecutingAssembly()
- .GetManifestResourceStream("EPPlusTest.TestWorkbooks.PreDeleteColumn.xls"))
- {
- pck.Load(file);
- }
- var wsData = pck.Workbook.Worksheets[1];
-
- // Act
- wsData.DeleteColumn(1, 2);
- pck.SaveAs(new FileInfo(OutputDirectory + "AfterDeleteColumn.xlsx"));
-
- // Assert
- Assert.AreEqual("First Name", wsData.Cells["A1"].Text);
- Assert.AreEqual("Family Name", wsData.Cells["B1"].Text);
-
- }
- #endregion
-
- [TestMethod]
- public void RangeClearMethodShouldNotClearSurroundingCells()
- {
- var wks = workbook.Worksheets.Add("test");
- wks.Cells[2, 2].Value = "something";
- wks.Cells[2, 3].Value = "something";
-
- wks.Cells[2, 3].Clear();
-
- Assert.IsNotNull(wks.Cells[2, 2].Value);
- Assert.AreEqual("something", wks.Cells[2, 2].Value);
- Assert.IsNull(wks.Cells[2, 3].Value);
- }
-
- private static void CompareOrderOfWorksheetsAfterSaving(ExcelPackage editedPackage)
- {
- var packageStream = new MemoryStream();
- editedPackage.SaveAs(packageStream);
-
- var newPackage = new ExcelPackage(packageStream);
- var positionId = 1;
- foreach (var worksheet in editedPackage.Workbook.Worksheets)
- {
- Assert.AreEqual(worksheet.Name, newPackage.Workbook.Worksheets[positionId].Name, "Worksheets are not in the same order");
- positionId++;
- }
- }
- }
-}
diff --git a/EPPlusTest/packages.config b/EPPlusTest/packages.config
deleted file mode 100644
index 219b8d8..0000000
--- a/EPPlusTest/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="RhinoMocks" version="3.6.1" targetFramework="net40" />
-</packages>
\ No newline at end of file
diff --git a/EPPlusWebSample/Default.aspx b/EPPlusWebSample/Default.aspx
deleted file mode 100644
index 3bf11bd..0000000
--- a/EPPlusWebSample/Default.aspx
+++ /dev/null
@@ -1,68 +0,0 @@
-<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EPPlusWebSample._Default" %>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" >
-<head runat="server">
- <title>EPPlus Websample</title>
- <style type="text/css">
- body
- {
- BACKGROUND-COLOR:#FFFFFF;
- COLOR: #111111;
- FONT-FAMILY: Arial;
- font-size: large;
- margin-top: 1px
- }
- table
- {
- FONT-FAMILY: Arial;
- FONT-SIZE: medium
- }
-A:link {color:#003399;}
-A:visited {color:#003399;}
-A:hover{color:#CC6699}
-
- </style>
-</head>
-<body>
- <form id="form1" runat="server">
- <h1>EPPlus Web samples</h1>
- <h3>The web sample project shows a few different ways to send a workbook to the client. </h3>
- <table>
- <tr>
- <td>
- <asp:HyperLink ID="sample1" runat="server" NavigateUrl="~/GetSample.aspx?Sample=1">Sample 1</asp:HyperLink>
- </td>
- <td>
- This sample demonstrates how to output a spreadsheet using the SaveAs(Reponse.OutputSteam) method.
- </td>
- </tr>
- <tr>
- <td>
- <asp:HyperLink ID="sample2" runat="server" NavigateUrl="~/GetSample.aspx?Sample=2">Sample 2</asp:HyperLink>
- </td>
- <td>
- This sample demonstrates how to output a spreadsheet using the Response.BinaryWrite(pck.GetAsByteArray()).
- </td>
- </tr>
- <tr>
- <td>
- <asp:HyperLink ID="sample3" runat="server" NavigateUrl="~/GetSample.aspx?Sample=3">Sample 3</asp:HyperLink>
- </td>
- <td>
- This sample demonstrates how to use a template stored in the Application cashe.
- </td>
- </tr>
- <tr>
- <td>
- <asp:HyperLink ID="sample4" runat="server" NavigateUrl="~/GetSample.aspx?Sample=4">Sample 4</asp:HyperLink>
- </td>
- <td>
- This sample demonstrates how to use a macro-enabled spreadsheet.
- </td>
- </tr>
- </table>
- </form>
-</body>
-</html>
diff --git a/EPPlusWebSample/Default.aspx.cs b/EPPlusWebSample/Default.aspx.cs
deleted file mode 100644
index 2cd10ec..0000000
--- a/EPPlusWebSample/Default.aspx.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-
-namespace EPPlusWebSample
-{
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
-
- }
- }
-}
diff --git a/EPPlusWebSample/Default.aspx.designer.cs b/EPPlusWebSample/Default.aspx.designer.cs
deleted file mode 100644
index 1c364f6..0000000
--- a/EPPlusWebSample/Default.aspx.designer.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace EPPlusWebSample {
-
-
- public partial class _Default {
-
- /// <summary>
- /// form1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.HtmlControls.HtmlForm form1;
-
- /// <summary>
- /// sample1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.HyperLink sample1;
-
- /// <summary>
- /// sample2 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.HyperLink sample2;
-
- /// <summary>
- /// sample3 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.HyperLink sample3;
-
- /// <summary>
- /// sample4 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.HyperLink sample4;
- }
-}
diff --git a/EPPlusWebSample/EPPlusWebSample.csproj b/EPPlusWebSample/EPPlusWebSample.csproj
deleted file mode 100644
index 241889b..0000000
--- a/EPPlusWebSample/EPPlusWebSample.csproj
+++ /dev/null
@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" 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>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{1BF30A52-6149-432D-82F6-725250E5C662}</ProjectGuid>
- <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>EPPlusWebSample</RootNamespace>
- <AssemblyName>EPPlusWebSample</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <OldToolsVersion>4.0</OldToolsVersion>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <TargetFrameworkProfile />
- <UseIISExpress>false</UseIISExpress>
- <IISExpressSSLPort />
- <IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
- <IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
- <IISExpressUseClassicPipelineMode>false</IISExpressUseClassicPipelineMode>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup>
- <SignAssembly>true</SignAssembly>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Web" />
- <Reference Include="System.Web.DynamicData" />
- <Reference Include="System.Web.Entity" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Configuration" />
- <Reference Include="System.Web.Services" />
- <Reference Include="System.EnterpriseServices" />
- <Reference Include="System.Web.Mobile" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="Default.aspx" />
- <Content Include="GetSample.aspx" />
- <Content Include="Web.config" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Default.aspx.cs">
- <SubType>ASPXCodeBehind</SubType>
- <DependentUpon>Default.aspx</DependentUpon>
- </Compile>
- <Compile Include="Default.aspx.designer.cs">
- <DependentUpon>Default.aspx</DependentUpon>
- </Compile>
- <Compile Include="GetSample.aspx.cs">
- <DependentUpon>GetSample.aspx</DependentUpon>
- <SubType>ASPXCodeBehind</SubType>
- </Compile>
- <Compile Include="GetSample.aspx.designer.cs">
- <DependentUpon>GetSample.aspx</DependentUpon>
- </Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="App_Data\" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\EPPlus\EPPlus.csproj">
- <Project>{7B288026-5502-4A39-BF41-77E086F3E4A3}</Project>
- <Name>EPPlus</Name>
- </ProjectReference>
- </ItemGroup>
- <PropertyGroup>
- <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
- <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release 4.0|AnyCPU'">
- <OutputPath>bin\</OutputPath>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
- <ProjectExtensions>
- <VisualStudio>
- <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
- <WebProjectProperties>
- <UseIIS>False</UseIIS>
- <AutoAssignPort>True</AutoAssignPort>
- <DevelopmentServerPort>8544</DevelopmentServerPort>
- <DevelopmentServerVPath>/</DevelopmentServerVPath>
- <IISUrl>
- </IISUrl>
- <NTLMAuthentication>False</NTLMAuthentication>
- <UseCustomServer>False</UseCustomServer>
- <CustomServerUrl>
- </CustomServerUrl>
- <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
- </WebProjectProperties>
- </FlavorProperties>
- </VisualStudio>
- </ProjectExtensions>
-</Project>
\ No newline at end of file
diff --git a/EPPlusWebSample/GetSample.aspx b/EPPlusWebSample/GetSample.aspx
deleted file mode 100644
index 393ab56..0000000
--- a/EPPlusWebSample/GetSample.aspx
+++ /dev/null
@@ -1 +0,0 @@
-<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetSample.aspx.cs" Inherits="EPPlusWebSample.GetSample" %>
diff --git a/EPPlusWebSample/GetSample.aspx.cs b/EPPlusWebSample/GetSample.aspx.cs
deleted file mode 100644
index abf6d36..0000000
--- a/EPPlusWebSample/GetSample.aspx.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * See http://epplus.codeplex.com/ for details
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 23-MAR-2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Web;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using OfficeOpenXml;
-using System.IO;
-using OfficeOpenXml.Style;
-using System.Drawing;
-using System.Text;
-namespace EPPlusWebSample
-{
- public partial class GetSample : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- switch (Request.QueryString["Sample"])
- {
- case "1":
- Sample1();
- break;
- case "2":
- Sample2();
- break;
- case "3":
- Sample3();
- break;
- case "4":
- Sample4();
- break;
- default:
- Response.Write("<script>javascript:alert('Invalid querystring');</script>");
- break;
-
- }
- }
-
- /// <summary>
- /// Sample 1
- /// Demonstrates the SaveAs method
- /// </summary>
- private void Sample1()
- {
- ExcelPackage pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Sample1");
-
- ws.Cells["A1"].Value = "Sample 1";
- ws.Cells["A1"].Style.Font.Bold = true;
- var shape = ws.Drawings.AddShape("Shape1", eShapeStyle.Rect);
- shape.SetPosition(50, 200);
- shape.SetSize(200, 100);
- shape.Text = "Sample 1 saves to the Response.OutputStream";
-
- pck.SaveAs(Response.OutputStream);
- Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- Response.AddHeader("content-disposition", "attachment; filename=Sample1.xlsx");
- }
- /// <summary>
- /// Sample 2
- /// Demonstrates the GetAsByteArray method
- /// </summary>
- private void Sample2()
- {
- ExcelPackage pck = new ExcelPackage();
- var ws = pck.Workbook.Worksheets.Add("Sample2");
-
- ws.Cells["A1"].Value = "Sample 2";
- ws.Cells["A1"].Style.Font.Bold = true;
- var shape = ws.Drawings.AddShape("Shape1", eShapeStyle.Rect);
- shape.SetPosition(50, 200);
- shape.SetSize(200, 100);
- shape.Text = "Sample 2 outputs the sheet using the Response.BinaryWrite method";
-
- Response.BinaryWrite(pck.GetAsByteArray());
- Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- Response.AddHeader("content-disposition", "attachment; filename=Sample2.xlsx");
- }
- /// <summary>
- /// Sample 3
- /// Uses a cached template
- /// </summary>
- private void Sample3()
- {
- if (Application["Sample3Template"] == null) //Check if the template is loaded
- {
- //Here we create the template.
- //As an alternative the template could be loaded from disk or from a resource.
- ExcelPackage pckTemplate = new ExcelPackage();
- var wsTemplate = pckTemplate.Workbook.Worksheets.Add("Sample3");
-
- wsTemplate.Cells["A1"].Value = "Sample 3";
- wsTemplate.Cells["A1"].Style.Font.Bold = true;
- var shape = wsTemplate.Drawings.AddShape("Shape1", eShapeStyle.Rect);
- shape.SetPosition(50, 200);
- shape.SetSize(200, 100);
- shape.Text = "Sample 3 uses a template that is stored in the application cashe.";
- pckTemplate.Save();
-
- Application["Sample3Template"] = pckTemplate.Stream;
- }
-
- //Open the new package with the template stream.
- //The template stream is copied to the new stream in the constructor
- ExcelPackage pck = new ExcelPackage(new MemoryStream(), Application["Sample3Template"] as Stream);
- var ws = pck.Workbook.Worksheets[1];
- int row = new Random().Next(10) + 10; //Pick a random row to print the text
- ws.Cells[row,1].Value = "We make a small change here, after the template has been loaded...";
- ws.Cells[row, 1, row, 5].Style.Fill.PatternType = ExcelFillStyle.Solid;
- ws.Cells[row, 1, row, 5].Style.Fill.BackgroundColor.SetColor(Color.LightGoldenrodYellow);
-
- Response.BinaryWrite(pck.GetAsByteArray());
- Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- Response.AddHeader("content-disposition", "attachment; filename=Sample3.xlsx");
- }
- private void Sample4()
- {
- ExcelPackage pck = new ExcelPackage();
-
- //Add a worksheet.
- var ws=pck.Workbook.Worksheets.Add("VBA Sample");
- ws.Drawings.AddShape("VBASampleRect", eShapeStyle.RoundRect);
-
- //Create a vba project
- pck.Workbook.CreateVBAProject();
-
- //Now add some code that creates a bubble chart...
- var sb = new StringBuilder();
-
- sb.AppendLine("Private Sub Workbook_Open()");
- sb.AppendLine(" [VBA Sample].Shapes(\"VBASampleRect\").TextEffect.Text = \"This text is set from VBA!\"");
- sb.AppendLine("End Sub");
- pck.Workbook.CodeModule.Code = sb.ToString();
-
- Response.BinaryWrite(pck.GetAsByteArray());
- Response.ContentType = "application/vnd.ms-excel.sheet.macroEnabled.12"; //.xlsm files uses a different contenttype than .xlsx
- Response.AddHeader("content-disposition", "attachment; filename=Sample4.xlsm");
-
- }
-
- }
-}
diff --git a/EPPlusWebSample/GetSample.aspx.designer.cs b/EPPlusWebSample/GetSample.aspx.designer.cs
deleted file mode 100644
index e8f985a..0000000
--- a/EPPlusWebSample/GetSample.aspx.designer.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:2.0.50727.4927
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace EPPlusWebSample {
-
-
- public partial class GetSample {
- }
-}
diff --git a/EPPlusWebSample/Properties/AssemblyInfo.cs b/EPPlusWebSample/Properties/AssemblyInfo.cs
deleted file mode 100644
index da2c5ea..0000000
--- a/EPPlusWebSample/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-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("EPPlusWebSample")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("EPPlusWebSample")]
-[assembly: AssemblyCopyright("Copyright © Jan Källman 2010")]
-[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("3d5900ae-111a-45be-96b3-d9e4606ca793")]
-
-// 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 Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/EPPlusWebSample/Web.config b/EPPlusWebSample/Web.config
deleted file mode 100644
index 99d1fdb..0000000
--- a/EPPlusWebSample/Web.config
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0"?>
-<configuration>
- <configSections>
- <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
- <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
- <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
- <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
- <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
- <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
- <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
- <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
- </sectionGroup>
- </sectionGroup>
- </sectionGroup>
- </configSections>
- <appSettings/>
- <connectionStrings/>
- <system.web>
- <!--
- Set compilation debug="true" to insert debugging
- symbols into the compiled page. Because this
- affects performance, set this value to true only
- during development.
- -->
- <compilation debug="true">
- <assemblies>
- <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
- <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
- <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
- </assemblies>
- </compilation>
- <!--
- The <authentication> section enables configuration
- of the security authentication mode used by
- ASP.NET to identify an incoming user.
- -->
- <authentication mode="Windows"/>
- <!--
- The <customErrors> section enables configuration
- of what to do if/when an unhandled error occurs
- during the execution of a request. Specifically,
- it enables developers to configure html error pages
- to be displayed in place of a error stack trace.
-
- <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
- <error statusCode="403" redirect="NoAccess.htm" />
- <error statusCode="404" redirect="FileNotFound.htm" />
- </customErrors>
- -->
- <pages>
- <controls>
- <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- </controls>
- </pages>
- <httpHandlers>
- <remove verb="*" path="*.asmx"/>
- <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- </httpHandlers>
- <httpModules>
- <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- </httpModules>
- </system.web>
- <!--
- The system.webServer section is required for running ASP.NET AJAX under Internet
- Information Services 7.0. It is not necessary for previous version of IIS.
- -->
- <system.codedom>
- <compilers>
- <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
- <providerOption name="CompilerVersion" value="v3.5"/>
- <providerOption name="WarnAsError" value="false"/>
- </compiler>
- </compilers>
- </system.codedom>
- <system.webServer>
- <validation validateIntegratedModeConfiguration="false"/>
- <modules>
- <remove name="ScriptModule"/>
- <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- </modules>
- <handlers>
- <remove name="WebServiceHandlerFactory-Integrated"/>
- <remove name="ScriptHandlerFactory"/>
- <remove name="ScriptHandlerFactoryAppServices"/>
- <remove name="ScriptResource"/>
- <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
- </handlers>
- </system.webServer>
- <runtime>
- <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
- <dependentAssembly>
- <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
- </dependentAssembly>
- </assemblyBinding>
- </runtime>
-</configuration>
\ No newline at end of file
diff --git a/ExcelPackage.vsmdi b/ExcelPackage.vsmdi
deleted file mode 100644
index 00d2cc0..0000000
--- a/ExcelPackage.vsmdi
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
- <TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
- <RunConfiguration id="dde59f2c-80d4-48ea-b6ff-2cf6055f3162" name="Local Test Run" storage="localtestrun.testrunconfig" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- </TestList>
-</TestLists>
\ No newline at end of file
diff --git a/LocalTestRun.testrunconfig b/LocalTestRun.testrunconfig
deleted file mode 100644
index b7a0376..0000000
--- a/LocalTestRun.testrunconfig
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<TestSettings name="Local Test Run" id="dde59f2c-80d4-48ea-b6ff-2cf6055f3162" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
- <Description>This is a default test run configuration for a local test run.</Description>
- <Deployment enabled="false" />
- <Execution>
- <Timeouts testTimeout="0" />
- <TestTypeSpecific>
- <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
- <AssemblyResolution>
- <TestDirectory useLoadContext="true" />
- </AssemblyResolution>
- </UnitTestRunConfig>
- <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
- <Browser name="Internet Explorer 10.0" MaxConnections="6">
- <Headers>
- <Header name="User-Agent" value="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)" />
- <Header name="Accept" value="*/*" />
- <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
- <Header name="Accept-Encoding" value="GZIP" />
- </Headers>
- </Browser>
- </WebTestRunConfiguration>
- </TestTypeSpecific>
- <AgentRule name="LocalMachineDefaultRole">
- </AgentRule>
- </Execution>
- <Properties />
-</TestSettings>
\ No newline at end of file
diff --git a/Profiling/GeneratePackage/GeneratePackage.csproj b/Profiling/GeneratePackage/GeneratePackage.csproj
deleted file mode 100644
index 594174e..0000000
--- a/Profiling/GeneratePackage/GeneratePackage.csproj
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{5B83F4CF-AF0D-4F04-B992-740CE4F9C116}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>GeneratePackage</RootNamespace>
- <AssemblyName>GeneratePackage</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <TargetFrameworkProfile>
- </TargetFrameworkProfile>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <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|x86' ">
- <PlatformTarget>x86</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\EPPlus\EPPlus.csproj">
- <Project>{7B288026-5502-4A39-BF41-77E086F3E4A3}</Project>
- <Name>EPPlus</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="app.config" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
diff --git a/Profiling/GeneratePackage/Program.cs b/Profiling/GeneratePackage/Program.cs
deleted file mode 100644
index e1463d1..0000000
--- a/Profiling/GeneratePackage/Program.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-
-namespace GeneratePackage
-{
- class Program
- {
- static ExcelPackage package;
-
- static void Main(string[] args)
- {
- Console.Out.WriteLine("Press enter to Start");
- Console.In.ReadLine();
-
- for (int ca = 0; ca < 10; ca++)
- {
- if (ca % 10 == 0)
- Console.Out.WriteLine(ca);
- CreateDeletePackage(4,100000);
- }
- while (!Console.In.ReadLine().Equals("exit", StringComparison.OrdinalIgnoreCase))
- {
- CreateDeletePackage(1,1000);
- }
- }
-
- private static void CreateDeletePackage(int Sheets, int rows)
- {
- List<object> row = new List<object>();
- row.Add(1);
- row.Add("Some text");
- row.Add(12.0);
- row.Add("Some larger text that has completely no meaning. How much wood can a wood chuck chuck if a wood chuck could chuck wood. A wood chuck could chuck as much wood as a wood chuck could chuck wood.");
-
- FileInfo LocalFullFileName = new FileInfo(Path.GetTempFileName());
- LocalFullFileName.Delete();
- package = new ExcelPackage(LocalFullFileName);
-
- try
- {
- for (int ca = 0; ca < Sheets; ca++)
- {
- CreateWorksheet("Sheet" + (ca+1), row, rows);
- }
-
- package.Save();
- }
- finally
- {
- LocalFullFileName.Refresh();
- if (LocalFullFileName.Exists)
- {
- LocalFullFileName.Delete();
- }
-
- package.Dispose();
- package = null;
-
- GC.Collect();
- }
- }
-
- private static void CreateWorksheet(string sheetName, List<object> row, int numrows)
- {
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(sheetName);
- for (int ca = 1; ca <= numrows; ca++)
- {
- AddDataRow(worksheet, ca, row);
- }
- }
-
- public static void AddDataRow(ExcelWorksheet worksheet, int row, IEnumerable<object> values)
- {
- int ca = 0;
- foreach (object v in values)
- {
- ca++;
- using (ExcelRange cell = worksheet.Cells[row, ca])
- {
- object value = v;
- cell.Value = value;
- }
- }
-
- worksheet.Row(row).Height = 10.2;
- }
- }
-}
diff --git a/Profiling/GeneratePackage/Properties/AssemblyInfo.cs b/Profiling/GeneratePackage/Properties/AssemblyInfo.cs
deleted file mode 100644
index 0467914..0000000
--- a/Profiling/GeneratePackage/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-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("GeneratePackage")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("HP")]
-[assembly: AssemblyProduct("GeneratePackage")]
-[assembly: AssemblyCopyright("Copyright © HP 2013")]
-[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("632b36c0-4bfd-4529-a99b-43f78e15aaa3")]
-
-// 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")]
diff --git a/Profiling/GeneratePackage/app.config b/Profiling/GeneratePackage/app.config
deleted file mode 100644
index e59af44..0000000
--- a/Profiling/GeneratePackage/app.config
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<configuration>
-<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
diff --git a/SampleApp/EPPlusSamples.csproj b/SampleApp/EPPlusSamples.csproj
deleted file mode 100644
index eb514dc..0000000
--- a/SampleApp/EPPlusSamples.csproj
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{06BF3C68-E7D4-4579-90BE-E36DACE564EF}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>EPPlusSamples</RootNamespace>
- <AssemblyName>EPPlusSamples</AssemblyName>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <OldToolsVersion>3.5</OldToolsVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- <TargetFrameworkProfile>Client</TargetFrameworkProfile>
- </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>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <PlatformTarget>AnyCPU</PlatformTarget>
- <Prefer32Bit>false</Prefer32Bit>
- </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>
- <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
- <PlatformTarget>x86</PlatformTarget>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release 4.0|AnyCPU'">
- <OutputPath>bin\Release 4.0\</OutputPath>
- <Prefer32Bit>false</Prefer32Bit>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Data" />
- <Reference Include="System.Data.Linq" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Sample10.cs" />
- <Compile Include="Sample11.cs" />
- <Compile Include="Sample12.cs" />
- <Compile Include="Sample13.cs" />
- <Compile Include="Sample14.cs" />
- <Compile Include="Sample15.cs" />
- <Compile Include="Sample8.cs" />
- <Compile Include="Sample1.cs" />
- <Compile Include="Sample3.cs" />
- <Compile Include="Sample4.cs" />
- <Compile Include="Sample5.cs" />
- <Compile Include="Sample6.cs" />
- <Compile Include="Sample7.cs" />
- <Compile Include="Sample9.cs" />
- <Compile Include="Sample_AddFormulaFunction.cs" />
- <Compile Include="Sample_FormulaCalc.cs" />
- <Compile Include="Sample_Main.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Sample2.cs" />
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
- <Visible>False</Visible>
- <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\EPPlus\EPPlus.csproj">
- <Project>{7B288026-5502-4A39-BF41-77E086F3E4A3}</Project>
- <Name>EPPlus</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <None Include="app.config" />
- <None Include="GraphTemplate.xlsx" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="csv\Sample9-2.txt" />
- <Content Include="csv\Sample9-1.txt" />
- <Content Include="VBA-Code\ComputerPlayModule.txt" />
- <Content Include="VBA-Code\BattleshipSheet.txt" />
- <Content Include="VBA-Code\ThisWorkbook.txt" />
- <Content Include="VBA-Code\CodeModule.txt" />
- <Content Include="VBA-Code\ShipClass.txt" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
\ No newline at end of file
diff --git a/SampleApp/GraphTemplate.xlsx b/SampleApp/GraphTemplate.xlsx
deleted file mode 100644
index 296c4be..0000000
--- a/SampleApp/GraphTemplate.xlsx
+++ /dev/null
Binary files differ
diff --git a/SampleApp/Properties/AssemblyInfo.cs b/SampleApp/Properties/AssemblyInfo.cs
deleted file mode 100644
index 0b454e2..0000000
--- a/SampleApp/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * You may amend and distribute as you like, but don't remove this header!
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- *
- * See http://www.codeplex.com/EPPlus for details.
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- * ******************************************************************************
- * Jan Källman Initial Release 2009-10-01
- *******************************************************************************/
-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("EPPlusSamples")]
-[assembly: AssemblyDescription("Demonstrate Excel files being created on the server")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("EPPlus Samples")]
-[assembly: AssemblyTrademark("The GNU General Public License (GPL)")]
-[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("3795b282-73dd-47f0-accf-2197054d6cf4")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("1.0.0.1")]
-[assembly: AssemblyFileVersion("1.0.0.1")]
diff --git a/SampleApp/Sample1.cs b/SampleApp/Sample1.cs
deleted file mode 100644
index eeaf764..0000000
--- a/SampleApp/Sample1.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 21 Mar 2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Xml;
-using System.Drawing;
-using OfficeOpenXml.Style;
-namespace EPPlusSamples
-{
- class Sample1
- {
- /// <summary>
- /// Sample 1 - simply creates a new workbook from scratch.
- /// The workbook contains one worksheet with a simple invertory list
- /// </summary>
- public static string RunSample1(DirectoryInfo outputDir)
- {
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample1.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sample1.xlsx");
- }
- using (ExcelPackage package = new ExcelPackage(newFile))
- {
- // add a new worksheet to the empty workbook
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Inventory");
- //Add the headers
- worksheet.Cells[1, 1].Value = "ID";
- worksheet.Cells[1, 2].Value = "Product";
- worksheet.Cells[1, 3].Value = "Quantity";
- worksheet.Cells[1, 4].Value = "Price";
- worksheet.Cells[1, 5].Value = "Value";
-
- //Add some items...
- worksheet.Cells["A2"].Value = 12001;
- worksheet.Cells["B2"].Value = "Nails";
- worksheet.Cells["C2"].Value = 37;
- worksheet.Cells["D2"].Value = 3.99;
-
- worksheet.Cells["A3"].Value = 12002;
- worksheet.Cells["B3"].Value = "Hammer";
- worksheet.Cells["C3"].Value = 5;
- worksheet.Cells["D3"].Value = 12.10;
-
- worksheet.Cells["A4"].Value = 12003;
- worksheet.Cells["B4"].Value = "Saw";
- worksheet.Cells["C4"].Value = 12;
- worksheet.Cells["D4"].Value = 15.37;
-
- //Add a formula for the value-column
- worksheet.Cells["E2:E4"].Formula = "C2*D2";
-
- //Ok now format the values;
- using (var range = worksheet.Cells[1, 1, 1, 5])
- {
- range.Style.Font.Bold = true;
- range.Style.Fill.PatternType = ExcelFillStyle.Solid;
- range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
- range.Style.Font.Color.SetColor(Color.White);
- }
-
- worksheet.Cells["A5:E5"].Style.Border.Top.Style = ExcelBorderStyle.Thin;
- worksheet.Cells["A5:E5"].Style.Font.Bold = true;
-
- worksheet.Cells[5, 3, 5, 5].Formula = string.Format("SUBTOTAL(9,{0})", new ExcelAddress(2,3,4,3).Address);
- worksheet.Cells["C2:C5"].Style.Numberformat.Format = "#,##0";
- worksheet.Cells["D2:E5"].Style.Numberformat.Format = "#,##0.00";
-
- //Create an autofilter for the range
- worksheet.Cells["A1:E4"].AutoFilter = true;
-
- worksheet.Cells["A2:A4"].Style.Numberformat.Format = "@"; //Format as text
-
- //There is actually no need to calculate, Excel will do it for you, but in some cases it might be useful.
- //For example if you link to this workbook from another workbook or you will open the workbook in a program that hasn't a calculation engine or
- //you want to use the result of a formula in your program.
- worksheet.Calculate();
-
- worksheet.Cells.AutoFitColumns(0); //Autofit columns for all cells
-
- // lets set the header text
- worksheet.HeaderFooter.OddHeader.CenteredText = "&24&U&\"Arial,Regular Bold\" Inventory";
- // add the page number to the footer plus the total number of pages
- worksheet.HeaderFooter.OddFooter.RightAlignedText =
- string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
- // add the sheet name to the footer
- worksheet.HeaderFooter.OddFooter.CenteredText = ExcelHeaderFooter.SheetName;
- // add the file path to the footer
- worksheet.HeaderFooter.OddFooter.LeftAlignedText = ExcelHeaderFooter.FilePath + ExcelHeaderFooter.FileName;
-
- worksheet.PrinterSettings.RepeatRows = worksheet.Cells["1:2"];
- worksheet.PrinterSettings.RepeatColumns = worksheet.Cells["A:G"];
-
- // Change the sheet view to show it in page layout mode
- worksheet.View.PageLayoutView = true;
-
- // set some document properties
- package.Workbook.Properties.Title = "Invertory";
- package.Workbook.Properties.Author = "Jan Källman";
- package.Workbook.Properties.Comments = "This sample demonstrates how to create an Excel 2007 workbook using EPPlus";
-
- // set some extended property values
- package.Workbook.Properties.Company = "AdventureWorks Inc.";
-
- // set some custom property values
- package.Workbook.Properties.SetCustomPropertyValue("Checked by", "Jan Källman");
- package.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "EPPlus");
- // save our new workbook and we are done!
- package.Save();
-
- }
-
- return newFile.FullName;
- }
- }
-}
diff --git a/SampleApp/Sample10.cs b/SampleApp/Sample10.cs
deleted file mode 100644
index ab2f3ec..0000000
--- a/SampleApp/Sample10.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 28 Oct 2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Drawing;
-using OfficeOpenXml.Style;
-
-namespace EPPlusSamples
-{
- public static class Sample10
- {
- public static void RunSample10(DirectoryInfo outputDir)
- {
- //Create a Sample10 directory...
- if(!Directory.Exists(outputDir.FullName + @"\Sample10"))
- {
- outputDir.CreateSubdirectory("Sample10");
- }
- outputDir=new DirectoryInfo(outputDir + @"\Sample10");
-
- //create the three FileInfo objects...
- FileInfo templateFile = new FileInfo(outputDir.FullName + @"\Template.xlsx");
- if (templateFile.Exists)
- {
- templateFile.Delete();
- templateFile = new FileInfo(outputDir.FullName + @"\Template.xlsx");
- }
- FileInfo answerFile = new FileInfo(outputDir.FullName + @"\Answers.xlsx");
- if (answerFile.Exists)
- {
- answerFile.Delete();
- answerFile = new FileInfo(outputDir.FullName + @"\Answers.xlsx");
- }
-
- FileInfo JKAnswerFile = new FileInfo(outputDir.FullName + @"\JKAnswers.xlsx");
- if (JKAnswerFile.Exists)
- {
- JKAnswerFile.Delete();
- JKAnswerFile = new FileInfo(outputDir.FullName + @"\JKAnswers.xlsx");
- }
-
- //Create the template...
- using (
- ExcelPackage package = new ExcelPackage(templateFile))
- {
- //Lock the workbook totally
- var workbook = package.Workbook;
- workbook.Protection.LockWindows = true;
- workbook.Protection.LockStructure = true;
- workbook.View.SetWindowSize(150, 525, 14500, 6000);
- workbook.View.ShowHorizontalScrollBar = false;
- workbook.View.ShowVerticalScrollBar = false;
- workbook.View.ShowSheetTabs = false;
-
- //Set a password for the workbookprotection
- workbook.Protection.SetPassword("EPPlus");
-
- //Encrypt with no password
- package.Encryption.IsEncrypted = true;
-
- var sheet = package.Workbook.Worksheets.Add("Quiz");
- sheet.View.ShowGridLines = false;
- sheet.View.ShowHeaders = false;
- using(var range=sheet.Cells["A:XFD"])
- {
- range.Style.Fill.PatternType=ExcelFillStyle.Solid;
- range.Style.Fill.BackgroundColor.SetColor(Color.LightGray);
- range.Style.Font.Name = "Broadway";
- range.Style.Hidden = true;
- }
-
- sheet.Cells["A1"].Value = "Quiz-Sweden";
- sheet.Cells["A1"].Style.Font.Size = 18;
-
- sheet.Cells["A3"].Value = "Enter your name:";
-
- sheet.Column(1).Width = 30;
- sheet.Column(2).Width = 80;
- sheet.Column(3).Width = 20;
-
- sheet.Cells["A7"].Value = "What is the name of the capital of Sweden?";
- sheet.Cells["A9"].Value = "At which place did the Swedish team end up in the Soccer Worldcup 1994?";
- sheet.Cells["A11"].Value = "What is the first name of the famous Swedish inventor/scientist that founded the Nobel-prize?";
-
- using (var r = sheet.Cells["B3,C7,C9,C11"])
- {
- r.Style.Fill.BackgroundColor.SetColor(Color.WhiteSmoke);
- r.Style.Border.Top.Style = ExcelBorderStyle.Dotted;
- r.Style.Border.Top.Color.SetColor(Color.Black);
- r.Style.Border.Right.Style = ExcelBorderStyle.Dotted;
- r.Style.Border.Right.Color.SetColor(Color.Black);
- r.Style.Border.Bottom.Style = ExcelBorderStyle.Dotted;
- r.Style.Border.Bottom.Color.SetColor(Color.Black);
- r.Style.Border.Left.Style = ExcelBorderStyle.Dotted;
- r.Style.Border.Left.Color.SetColor(Color.Black);
- r.Style.Locked = false;
- r.Style.Hidden = false;
- r.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
- }
- sheet.Select("B3");
- sheet.Protection.SetPassword("EPPlus");
- sheet.Protection.AllowSelectLockedCells = false;
-
- //Options question 1
- var list1 = sheet.Cells["C7"].DataValidation.AddListDataValidation();
- list1.Formula.Values.Add("Bern");
- list1.Formula.Values.Add("Stockholm");
- list1.Formula.Values.Add("Oslo");
- list1.ShowErrorMessage = true;
- list1.Error = "Please select a value from the list";
-
- var list2 = sheet.Cells["C9"].DataValidation.AddListDataValidation();
- list2.Formula.Values.Add("First");
- list2.Formula.Values.Add("Second");
- list2.Formula.Values.Add("Third");
- list2.ShowErrorMessage = true;
- list2.Error = "Please select a value from the list";
-
- var list3 = sheet.Cells["C11"].DataValidation.AddListDataValidation();
- list3.Formula.Values.Add("Carl Gustaf");
- list3.Formula.Values.Add("Ingmar");
- list3.Formula.Values.Add("Alfred");
- list3.ShowErrorMessage = true;
- list3.Error = "Please select a value from the list";
-
-
- //Save, and the template is ready for use
- package.Save();
-
- //Quiz-template is done, now create the answer template and encrypt it...
- using (var packageAnswers = new ExcelPackage(package.Stream)) //We use the stream from the template here to get a copy of it.
- {
- var sheetAnswers = packageAnswers.Workbook.Worksheets[1];
- sheetAnswers.Cells["C7"].Value = "Stockholm";
- sheetAnswers.Cells["C9"].Value = "Third";
- sheetAnswers.Cells["C11"].Value = "Alfred";
-
- packageAnswers.Encryption.Algorithm = EncryptionAlgorithm.AES192; //For the answers we want a little bit stronger encryption
- packageAnswers.SaveAs(answerFile, "EPPlus"); //Save and set the password to EPPlus. The password can also be set using packageAnswers.Encryption.Password property
- }
-
- //Ok, Since this is qan example we create one user answer...
- using (var packageAnswers = new ExcelPackage(package.Stream))
- {
- var sheetUser = packageAnswers.Workbook.Worksheets[1];
- sheetUser.Cells["B3"].Value = "Jan Källman";
- sheetUser.Cells["C7"].Value = "Bern";
- sheetUser.Cells["C9"].Value = "Third";
- sheetUser.Cells["C11"].Value = "Alfred";
-
- packageAnswers.SaveAs(JKAnswerFile, "JK"); //We use default encryption here (AES128) and Password JK
- }
- }
-
-
- //Now lets correct the user form...
- var packAnswers = new ExcelPackage(answerFile, "EPPlus"); //Supply the password, so the file can be decrypted
- var packUser = new ExcelPackage(JKAnswerFile, "JK"); //Supply the password, so the file can be decrypted
-
- var wsAnswers = packAnswers.Workbook.Worksheets[1];
- var wsUser = packUser.Workbook.Worksheets[1];
-
- //Enumerate the three answers
- foreach (var cell in wsAnswers.Cells["C7,C9,C11"])
- {
- wsUser.Cells[cell.Address].Style.Fill.PatternType = ExcelFillStyle.Solid;
- if (cell.Value.ToString().Equals(wsUser.Cells[cell.Address].Value.ToString(), StringComparison.InvariantCultureIgnoreCase)) //Correct Answer?
- {
- wsUser.Cells[cell.Address].Style.Fill.BackgroundColor.SetColor(Color.Green);
- }
- else
- {
- wsUser.Cells[cell.Address].Style.Fill.BackgroundColor.SetColor(Color.Red);
- }
- }
- packUser.Save();
- }
- }
-}
diff --git a/SampleApp/Sample11.cs b/SampleApp/Sample11.cs
deleted file mode 100644
index b2fb0cb..0000000
--- a/SampleApp/Sample11.cs
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * You may amend and distribute as you like, but don't remove this header!
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- * Code change notes:
- *
- * Author Change Date
- * ******************************************************************************
- * Mats Alm Added 2011-01-08
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using OfficeOpenXml.DataValidation;
-using OfficeOpenXml.DataValidation.Contracts;
-
-namespace EPPlusSamples
-{
- /// <summary>
- /// This sample shows how to use data validation
- /// </summary>
- class Sample11
- {
- public static string RunSample11(DirectoryInfo outputDir)
- {
- //Create a Sample10 directory...
- if (!Directory.Exists(outputDir.FullName + @"\Sample11"))
- {
- outputDir.CreateSubdirectory("Sample11");
- }
- outputDir = new DirectoryInfo(outputDir + @"\Sample11");
-
- //create FileInfo object...
- FileInfo output = new FileInfo(outputDir.FullName + @"\Output.xlsx");
- if (output.Exists)
- {
- output.Delete();
- output = new FileInfo(outputDir.FullName + @"\Output.xlsx");
- }
-
- using (var package = new ExcelPackage(output))
- {
- AddIntegerValidation(package);
- AddListValidationFormula(package);
- AddListValidationValues(package);
- AddTimeValidation(package);
- AddDateTimeValidation(package);
- ReadExistingValidationsFromPackage(package);
- package.SaveAs(output);
- }
- return output.FullName;
- }
-
- /// <summary>
- /// Adds integer validation
- /// </summary>
- /// <param name="file"></param>
- private static void AddIntegerValidation(ExcelPackage package)
- {
- var sheet = package.Workbook.Worksheets.Add("integer");
- // add a validation and set values
- var validation = sheet.DataValidations.AddIntegerValidation("A1:A2");
- // Alternatively:
- //var validation = sheet.Cells["A1:A2"].DataValidation.AddIntegerDataValidation();
- validation.ErrorStyle = ExcelDataValidationWarningStyle.stop;
- validation.PromptTitle = "Enter a integer value here";
- validation.Prompt = "Value should be between 1 and 5";
- validation.ShowInputMessage = true;
- validation.ErrorTitle = "An invalid value was entered";
- validation.Error = "Value must be between 1 and 5";
- validation.ShowErrorMessage = true;
- validation.Operator = ExcelDataValidationOperator.between;
- validation.Formula.Value = 1;
- validation.Formula2.Value = 5;
-
- Console.WriteLine("Added sheet for integer validation");
- }
-
- /// <summary>
- /// Adds a list validation where the list source is a formula
- /// </summary>
- /// <param name="package"></param>
- private static void AddListValidationFormula(ExcelPackage package)
- {
- var sheet = package.Workbook.Worksheets.Add("list formula");
- sheet.Cells["B1"].Style.Font.Bold = true;
- sheet.Cells["B1"].Value = "Source values";
- sheet.Cells["B2"].Value = 1;
- sheet.Cells["B3"].Value = 2;
- sheet.Cells["B4"].Value = 3;
-
- // add a validation and set values
- var validation = sheet.DataValidations.AddListValidation("A1");
- // Alternatively:
- // var validation = sheet.Cells["A1"].DataValidation.AddListDataValidation();
- validation.ShowErrorMessage = true;
- validation.ErrorStyle = ExcelDataValidationWarningStyle.warning;
- validation.ErrorTitle = "An invalid value was entered";
- validation.Error = "Select a value from the list";
- validation.Formula.ExcelFormula = "B2:B4";
-
- Console.WriteLine("Added sheet for list validation with formula");
-
- }
-
- /// <summary>
- /// Adds a list validation where the selectable values are set
- /// </summary>
- /// <param name="package"></param>
- private static void AddListValidationValues(ExcelPackage package)
- {
- var sheet = package.Workbook.Worksheets.Add("list values");
-
- // add a validation and set values
- var validation = sheet.DataValidations.AddListValidation("A1");
- validation.ShowErrorMessage = true;
- validation.ErrorStyle = ExcelDataValidationWarningStyle.warning;
- validation.ErrorTitle = "An invalid value was entered";
- validation.Error = "Select a value from the list";
- for (var i = 1; i <= 5; i++)
- {
- validation.Formula.Values.Add(i.ToString());
- }
- Console.WriteLine("Added sheet for list validation with values");
-
- }
-
- /// <summary>
- /// Adds a time validation
- /// </summary>
- /// <param name="package"></param>
- private static void AddTimeValidation(ExcelPackage package)
- {
- var sheet = package.Workbook.Worksheets.Add("time");
- // add a validation and set values
- var validation = sheet.DataValidations.AddTimeValidation("A1");
- // Alternatively:
- // var validation = sheet.Cells["A1"].DataValidation.AddTimeDataValidation();
- validation.ShowErrorMessage = true;
- validation.ErrorStyle = ExcelDataValidationWarningStyle.stop;
- validation.ShowInputMessage = true;
- validation.PromptTitle = "Enter time in format HH:MM:SS";
- validation.Prompt = "Should be greater than 13:30:10";
- validation.Operator = ExcelDataValidationOperator.greaterThan;
- var time = validation.Formula.Value;
- time.Hour = 13;
- time.Minute = 30;
- time.Second = 10;
- Console.WriteLine("Added sheet for time validation");
- }
-
- private static void AddDateTimeValidation(ExcelPackage package)
- {
- var sheet = package.Workbook.Worksheets.Add("datetime");
- // add a validation and set values
- var validation = sheet.DataValidations.AddDateTimeValidation("A1");
- // Alternatively:
- // var validation = sheet.Cells["A1"].DataValidation.AddDateTimeDataValidation();
- validation.ShowErrorMessage = true;
- validation.ErrorStyle = ExcelDataValidationWarningStyle.stop;
- validation.Error = "Invalid date!";
- validation.ShowInputMessage = true;
- validation.Prompt = "Enter a date greater than todays date here";
- validation.Operator = ExcelDataValidationOperator.greaterThan;
- validation.Formula.Value = DateTime.Now.Date;
- Console.WriteLine("Added sheet for date time validation");
-
- }
-
- /// <summary>
- /// shows details about all existing validations in the entire workbook
- /// </summary>
- /// <param name="package"></param>
- private static void ReadExistingValidationsFromPackage(ExcelPackage package)
- {
- var sheet = package.Workbook.Worksheets.Add("Package validations");
- // print headers
- sheet.Cells["A1:E1"].Style.Font.Bold = true;
- sheet.Cells["A1"].Value = "Type";
- sheet.Cells["B1"].Value = "Address";
- sheet.Cells["C1"].Value = "Operator";
- sheet.Cells["D1"].Value = "Formula1";
- sheet.Cells["E1"].Value = "Formula2";
-
- int row = 2;
- foreach (var otherSheet in package.Workbook.Worksheets)
- {
- if(otherSheet == sheet)
- {
- continue;
- }
- foreach (var dataValidation in otherSheet.DataValidations)
- {
- sheet.Cells["A" + row.ToString()].Value = dataValidation.ValidationType.Type.ToString();
- sheet.Cells["B" + row.ToString()].Value = dataValidation.Address.Address;
- if (dataValidation.AllowsOperator)
- {
- sheet.Cells["C" + row.ToString()].Value = ((IExcelDataValidationWithOperator)dataValidation).Operator.ToString();
- }
- // type casting is needed to get validationtype-specific values
- switch(dataValidation.ValidationType.Type)
- {
- case eDataValidationType.Whole:
- PrintWholeValidationDetails(sheet, (IExcelDataValidationInt)dataValidation, row);
- break;
- case eDataValidationType.List:
- PrintListValidationDetails(sheet, (IExcelDataValidationList)dataValidation, row);
- break;
- case eDataValidationType.Time:
- PrintTimeValidationDetails(sheet, (ExcelDataValidationTime)dataValidation, row);
- break;
- default:
- // the rest of the types are not supported in this sample, but I hope you get the picture...
- break;
- }
- row++;
- }
- }
- }
-
- private static void PrintWholeValidationDetails(ExcelWorksheet sheet, IExcelDataValidationInt wholeValidation, int row)
- {
- sheet.Cells["D" + row.ToString()].Value = wholeValidation.Formula.Value.HasValue ? wholeValidation.Formula.Value.Value.ToString() : wholeValidation.Formula.ExcelFormula;
- sheet.Cells["E" + row.ToString()].Value = wholeValidation.Formula2.Value.HasValue ? wholeValidation.Formula2.Value.Value.ToString() : wholeValidation.Formula2.ExcelFormula;
- }
-
- private static void PrintListValidationDetails(ExcelWorksheet sheet, IExcelDataValidationList listValidation, int row)
- {
- string value = string.Empty;
- // if formula is used - show it...
- if(!string.IsNullOrEmpty(listValidation.Formula.ExcelFormula))
- {
- value = listValidation.Formula.ExcelFormula;
- }
- else
- {
- // otherwise - show the values from the list collection
- var sb = new StringBuilder();
- foreach(var listValue in listValidation.Formula.Values)
- {
- if(sb.Length > 0)
- {
- sb.Append(",");
- }
- sb.Append(listValue);
- }
- value = sb.ToString();
- }
- sheet.Cells["D" + row.ToString()].Value = value;
- }
-
- private static void PrintTimeValidationDetails(ExcelWorksheet sheet, ExcelDataValidationTime validation, int row)
- {
- var value1 = string.Empty;
- if(!string.IsNullOrEmpty(validation.Formula.ExcelFormula))
- {
- value1 = validation.Formula.ExcelFormula;
- }
- else
- {
- value1 = string.Format("{0}:{1}:{2}", validation.Formula.Value.Hour, validation.Formula.Value.Minute, validation.Formula.Value.Second ?? 0);
- }
- sheet.Cells["D" + row.ToString()].Value = value1;
- }
- }
-}
diff --git a/SampleApp/Sample12.cs b/SampleApp/Sample12.cs
deleted file mode 100644
index f48bf9d..0000000
--- a/SampleApp/Sample12.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * You may amend and distribute as you like, but don't remove this header!
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- * Code change notes:
- *
- * Author Change Date
- * ******************************************************************************
- * Jan Källman Added 2011-04-18
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Data.SqlClient;
-using OfficeOpenXml.Table.PivotTable;
-using OfficeOpenXml.Drawing.Chart;
-namespace EPPlusSamples
-{
- /// <summary>
- /// This class shows how to use pivottables
- /// </summary>
- public static class Sample12
- {
- public class SalesDTO
- {
- public string Title { get; set; }
- public string FirstName { get; set; }
- public string MiddleName { get; set; }
- public string LastName { get; set; }
- public string Name
- {
- get
- {
- return string.IsNullOrEmpty(MiddleName) ? FirstName + " " + LastName : FirstName + " " + MiddleName + " " + LastName;
- }
- }
- public DateTime OrderDate { get; set; }
- public decimal SubTotal { get; set; }
- public decimal Tax { get; set; }
- public decimal Freight { get; set; }
- public decimal Total
- {
- get
- {
- return SubTotal + Tax + Freight;
- }
- }
- }
- public static string RunSample12(string sqlServerName, DirectoryInfo outputDir)
- {
- var list = new List<SalesDTO>();
- if (sqlServerName == "")
- {
- list = GetRandomData();
- }
- else
- {
- list = GetDataFromSQL(sqlServerName);
- }
-
- string file = outputDir.FullName + @"\sample12.xlsx";
- if (File.Exists(file)) File.Delete(file);
- FileInfo newFile = new FileInfo(file);
-
- using (ExcelPackage pck = new ExcelPackage(newFile))
- {
- // get the handle to the existing worksheet
- var wsData = pck.Workbook.Worksheets.Add("SalesData");
-
- var dataRange = wsData.Cells["A1"].LoadFromCollection(
- from s in list
- orderby s.LastName, s.FirstName
- select s,
- true, OfficeOpenXml.Table.TableStyles.Medium2);
-
- wsData.Cells[2, 6, dataRange.End.Row, 6].Style.Numberformat.Format = "mm-dd-yy";
- wsData.Cells[2, 7, dataRange.End.Row, 11].Style.Numberformat.Format = "#,##0";
-
- dataRange.AutoFitColumns();
-
- var wsPivot = pck.Workbook.Worksheets.Add("PivotSimple");
- var pivotTable1 = wsPivot.PivotTables.Add(wsPivot.Cells["A1"], dataRange, "PerEmploee");
-
- pivotTable1.RowFields.Add(pivotTable1.Fields[4]);
- var dataField = pivotTable1.DataFields.Add(pivotTable1.Fields[6]);
- dataField.Format="#,##0";
- pivotTable1.DataOnRows = true;
-
- var chart = wsPivot.Drawings.AddChart("PivotChart", eChartType.Pie, pivotTable1);
- chart.SetPosition(1, 0, 4, 0);
- chart.SetSize(600, 400);
-
- var wsPivot2 = pck.Workbook.Worksheets.Add("PivotDateGrp");
- var pivotTable2 = wsPivot2.PivotTables.Add(wsPivot2.Cells["A3"], dataRange, "PerEmploeeAndQuarter");
-
- pivotTable2.RowFields.Add(pivotTable2.Fields["Name"]);
-
- //Add a rowfield
- var rowField = pivotTable2.RowFields.Add(pivotTable2.Fields["OrderDate"]);
- //This is a date field so we want to group by Years and quaters. This will create one additional field for years.
- rowField.AddDateGrouping(eDateGroupBy.Years | eDateGroupBy.Quarters);
- //Get the Quaters field and change the texts
- var quaterField = pivotTable2.Fields.GetDateGroupField(eDateGroupBy.Quarters);
- quaterField.Items[0].Text = "<"; //Values below min date, but we use auto so its not used
- quaterField.Items[1].Text = "Q1";
- quaterField.Items[2].Text = "Q2";
- quaterField.Items[3].Text = "Q3";
- quaterField.Items[4].Text = "Q4";
- quaterField.Items[5].Text = ">"; //Values above max date, but we use auto so its not used
-
- //Add a pagefield
- var pageField = pivotTable2.PageFields.Add(pivotTable2.Fields["Title"]);
-
- //Add the data fields and format them
- dataField = pivotTable2.DataFields.Add(pivotTable2.Fields["SubTotal"]);
- dataField.Format = "#,##0";
- dataField = pivotTable2.DataFields.Add(pivotTable2.Fields["Tax"]);
- dataField.Format = "#,##0";
- dataField = pivotTable2.DataFields.Add(pivotTable2.Fields["Freight"]);
- dataField.Format = "#,##0";
-
- //We want the datafields to appear in columns
- pivotTable2.DataOnRows = false;
-
- pck.Save();
- }
- return file;
- }
-
- private static List<SalesDTO> GetRandomData()
- {
- List<SalesDTO> ret = new List<SalesDTO>();
- var firstNames = new string[] {"John", "Gunnar", "Karl", "Alice"};
- var lastNames = new string[] {"Smith", "Johansson", "Lindeman"};
- Random r = new Random();
- for (int i = 0; i < 500; i++)
- {
- ret.Add(
- new SalesDTO()
- {
- FirstName = firstNames[r.Next(4)],
- LastName = lastNames[r.Next(3)],
- OrderDate = new DateTime(2002, 1, 1).AddDays(r.Next(1000)),
- Title="Sales Representative",
- SubTotal = r.Next(100, 10000),
- Tax = 0,
- Freight = 0
- });
- }
- return ret;
- }
-
- private static List<SalesDTO> GetDataFromSQL(string sqlServerName)
- {
- string connectionStr = string.Format(@"server={0};database=AdventureWorks;Integrated Security=true;", sqlServerName);
- var ret = new List<SalesDTO>();
- // lets connect to the AdventureWorks sample database for some data
- using (SqlConnection sqlConn = new SqlConnection(connectionStr))
- {
- sqlConn.Open();
- using (SqlCommand sqlCmd = new SqlCommand("select h.Title, FirstName, MiddleName, LastName, SubTotal, OrderDate, TaxAmt, Freight, TotalDue from Sales.SalesOrderHeader s inner join HumanResources.Employee h on s.SalesPersonID = h.EmployeeID inner join Person.Contact c on c.ContactID = h.ContactID order by LastName, FirstName, MiddleName;", sqlConn))
- {
- using (SqlDataReader sqlReader = sqlCmd.ExecuteReader())
- {
- //Get the data and fill rows 5 onwards
- while (sqlReader.Read())
- {
- ret.Add(new SalesDTO
- {
- Title = sqlReader["Title"].ToString(),
- FirstName=sqlReader["FirstName"].ToString(),
- MiddleName=sqlReader["MiddleName"].ToString(),
- LastName=sqlReader["LastName"].ToString(),
- OrderDate = (DateTime)sqlReader["OrderDate"],
- SubTotal = (decimal)sqlReader["SubTotal"],
- Tax=(decimal)sqlReader["TaxAmt"],
- Freight=(decimal)sqlReader["Freight"]
- });
- }
- }
- }
- }
- return ret;
- }
- }
-}
\ No newline at end of file
diff --git a/SampleApp/Sample13.cs b/SampleApp/Sample13.cs
deleted file mode 100644
index 72ac835..0000000
--- a/SampleApp/Sample13.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * You may amend and distribute as you like, but don't remove this header!
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- * Code change notes:
- *
- * Author Change Date
- * ******************************************************************************
- * Jan Källman Added 2011-05-03
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Data;
-using OfficeOpenXml.Table;
-using System.Reflection;
-
-namespace EPPlusSamples
-{
- /// <summary>
- /// This class shows how to load data in a few ways
- /// </summary>
- public static class Sample13
- {
- public class FileDTO
- {
- public string Name { get; set; }
- public long Size {get;set;}
- public DateTime Created {get;set;}
- public DateTime LastModified {get;set;}
-
- public bool IsDirectory=false; //This is a field variable
-
- public override string ToString()
- {
- if (IsDirectory)
- {
- return Name + "\t<Dir>";
- }
- else
- {
- return Name + "\t" + Size.ToString("#,##0");
- }
- }
- }
-
- public static void RunSample13(DirectoryInfo outputDir)
- {
- ExcelPackage pck = new ExcelPackage();
-
- //Create a datatable with the directories and files from the root directory...
- DataTable dt = GetDataTable(outputDir.Root);
-
- var wsDt = pck.Workbook.Worksheets.Add("FromDataTable");
-
- //Load the datatable and set the number formats...
- wsDt.Cells["A1"].LoadFromDataTable(dt, true, TableStyles.Medium9);
- wsDt.Cells[2, 2, dt.Rows.Count + 1, 2].Style.Numberformat.Format = "#,##0";
- wsDt.Cells[2, 3, dt.Rows.Count + 1, 4].Style.Numberformat.Format = "mm-dd-yy";
- wsDt.Cells[wsDt.Dimension.Address].AutoFitColumns();
-
- //Select Name and Created-time...
- var collection = (from row in dt.Select() select new {Name=row["Name"], Created_time=(DateTime)row["Created"]});
-
- var wsEnum = pck.Workbook.Worksheets.Add("FromAnonymous");
-
- //Load the collection starting from cell A1...
- wsEnum.Cells["A1"].LoadFromCollection(collection, true, TableStyles.Medium9);
-
- //Add some formating...
- wsEnum.Cells[2, 2, dt.Rows.Count-1, 2].Style.Numberformat.Format = "mm-dd-yy";
- wsEnum.Cells[wsEnum.Dimension.Address].AutoFitColumns();
-
- //Load a list of FileDTO objects from the datatable...
- var wsList = pck.Workbook.Worksheets.Add("FromList");
- List<FileDTO> list = (from row in dt.Select()
- select new FileDTO {
- Name = row["Name"].ToString(),
- Size = row["Size"].GetType() == typeof(long) ? (long)row["Size"] : 0,
- Created = (DateTime)row["Created"],
- LastModified = (DateTime)row["Modified"],
- IsDirectory = (row["Size"]==DBNull.Value)
- }).ToList<FileDTO>();
-
- //Load files ordered by size...
- wsList.Cells["A1"].LoadFromCollection(from file in list
- orderby file.Size descending
- where file.IsDirectory == false
- select file, true, TableStyles.Medium9);
-
- wsList.Cells[2, 2, dt.Rows.Count + 1, 2].Style.Numberformat.Format = "#,##0";
- wsList.Cells[2, 3, dt.Rows.Count + 1, 4].Style.Numberformat.Format = "mm-dd-yy";
-
-
- //Load directories ordered by Name...
- wsList.Cells["F1"].LoadFromCollection(from file in list
- orderby file.Name ascending
- where file.IsDirectory == true
- select new {
- Name=file.Name,
- Created = file.Created,
- Last_modified=file.LastModified}, //Use an underscore in the property name to get a space in the title.
- true, TableStyles.Medium11);
-
- wsList.Cells[2, 7, dt.Rows.Count + 1, 8].Style.Numberformat.Format = "mm-dd-yy";
-
- //Load the list using a specified array of MemberInfo objects. Properties, fields and methods are supported.
- var rng = wsList.Cells["J1"].LoadFromCollection(list,
- true,
- TableStyles.Medium10,
- BindingFlags.Instance | BindingFlags.Public,
- new MemberInfo[] {
- typeof(FileDTO).GetProperty("Name"),
- typeof(FileDTO).GetField("IsDirectory"),
- typeof(FileDTO).GetMethod("ToString")}
- );
-
- wsList.Tables.GetFromRange(rng).Columns[2].Name = "Description";
-
- wsList.Cells[wsList.Dimension.Address].AutoFitColumns();
-
- //...and save
- var fi = new FileInfo(outputDir.FullName + @"\Sample13.xlsx");
- if (fi.Exists)
- {
- fi.Delete();
- }
- pck.SaveAs(fi);
- }
-
- private static DataTable GetDataTable(DirectoryInfo dir)
- {
- DataTable dt = new DataTable("RootDir");
- dt.Columns.Add("Name", typeof(string));
- dt.Columns.Add("Size", typeof(long));
- dt.Columns.Add("Created", typeof(DateTime));
- dt.Columns.Add("Modified", typeof(DateTime));
- foreach (var item in dir.GetDirectories())
- {
- var row=dt.NewRow();
- row["Name"]=item.Name;
- row["Created"]=item.CreationTime;
- row["Modified"]=item.LastWriteTime;
-
- dt.Rows.Add(row);
- }
- foreach (var item in dir.GetFiles())
- {
- var row = dt.NewRow();
- row["Name"] = item.Name;
- row["Size"] = item.Length;
- row["Created"] = item.CreationTime;
- row["Modified"] = item.LastWriteTime;
-
- dt.Rows.Add(row);
- }
- return dt;
- }
- }
-}
diff --git a/SampleApp/Sample14.cs b/SampleApp/Sample14.cs
deleted file mode 100644
index 34bacef..0000000
--- a/SampleApp/Sample14.cs
+++ /dev/null
@@ -1,451 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Eyal Seagull Added 2012-04-03
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Xml;
-using System.Drawing;
-using OfficeOpenXml.Style;
-using OfficeOpenXml.Style.Dxf;
-using OfficeOpenXml.DataValidation;
-using OfficeOpenXml.ConditionalFormatting;
-
-namespace EPPlusSamples
-{
- class Sample14
- {
- /// <summary>
- /// Sample 14 - Conditional formatting example
- /// </summary>
- public static string RunSample14(DirectoryInfo outputDir)
- {
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample14.xlsx");
-
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sample14.xlsx");
- }
-
- using (ExcelPackage package = new ExcelPackage(newFile))
- {
- // add a new worksheet to the empty workbook
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Conditional Formatting");
-
- // Create 4 columns of samples data
- for (int col = 1; col < 10; col++)
- {
- // Add the headers
- worksheet.Cells[1, col].Value = "Sample " + col;
-
- for (int row = 2; row < 21; row++)
- {
- // Add some items...
- worksheet.Cells[row, col].Value = row;
- }
- }
-
- // -------------------------------------------------------------------
- // TwoColorScale Conditional Formatting example
- // -------------------------------------------------------------------
- ExcelAddress cfAddress1 = new ExcelAddress("A2:A10");
- var cfRule1 = worksheet.ConditionalFormatting.AddTwoColorScale(cfAddress1);
-
- // Now, lets change some properties:
- cfRule1.LowValue.Type = eExcelConditionalFormattingValueObjectType.Num;
- cfRule1.LowValue.Value = 4;
- cfRule1.LowValue.Color = ColorTranslator.FromHtml("#FFFFEB84");
- cfRule1.HighValue.Type = eExcelConditionalFormattingValueObjectType.Formula;
- cfRule1.HighValue.Formula = "IF($G$1=\"A</x:&'cfRule>\",1,5)";
- cfRule1.StopIfTrue = true;
- cfRule1.Style.Font.Bold = true;
-
- // But others you can't (readonly)
- // cfRule1.Type = eExcelConditionalFormattingRuleType.ThreeColorScale;
-
- // -------------------------------------------------------------------
- // ThreeColorScale Conditional Formatting example
- // -------------------------------------------------------------------
- ExcelAddress cfAddress2 = new ExcelAddress(2, 2, 10, 2); //="B2:B10"
- var cfRule2 = worksheet.ConditionalFormatting.AddThreeColorScale(cfAddress2);
-
- // Changing some properties again
- cfRule2.Priority = 1;
- cfRule2.MiddleValue.Type = eExcelConditionalFormattingValueObjectType.Percentile;
- cfRule2.MiddleValue.Value = 30;
- cfRule2.StopIfTrue = true;
-
- // You can access a rule by its Priority
- var cfRule2Priority = cfRule2.Priority;
- var cfRule2_1 = worksheet.ConditionalFormatting.RulesByPriority(cfRule2Priority);
-
- // And you can even change the rule's Address
- cfRule2_1.Address = new ExcelAddress("Z1:Z3");
-
- // -------------------------------------------------------------------
- // Adding another ThreeColorScale in a different way (observe that we are
- // pointing to the same range as the first rule we entered. Excel allows it to
- // happen and group the rules in one <conditionalFormatting> node)
- // -------------------------------------------------------------------
- var cfRule3 = worksheet.Cells[cfAddress1.Address].ConditionalFormatting.AddThreeColorScale();
- cfRule3.LowValue.Color = Color.LemonChiffon;
-
- // -------------------------------------------------------------------
- // Change the rules priorities to change their execution order
- // -------------------------------------------------------------------
- cfRule3.Priority = 1;
- cfRule1.Priority = 2;
- cfRule2.Priority = 3;
-
- // -------------------------------------------------------------------
- // Create an Above Average rule
- // -------------------------------------------------------------------
- var cfRule5 = worksheet.ConditionalFormatting.AddAboveAverage(
- new ExcelAddress("B11:B20"));
- cfRule5.Style.Font.Bold = true;
- cfRule5.Style.Font.Color.Color = Color.Red;
- cfRule5.Style.Font.Strike = true;
-
- // -------------------------------------------------------------------
- // Create an Above Or Equal Average rule
- // -------------------------------------------------------------------
- var cfRule6 = worksheet.ConditionalFormatting.AddAboveOrEqualAverage(
- new ExcelAddress("B11:B20"));
-
- // -------------------------------------------------------------------
- // Create a Below Average rule
- // -------------------------------------------------------------------
- var cfRule7 = worksheet.ConditionalFormatting.AddBelowAverage(
- new ExcelAddress("B11:B20"));
-
- // -------------------------------------------------------------------
- // Create a Below Or Equal Average rule
- // -------------------------------------------------------------------
- var cfRule8 = worksheet.ConditionalFormatting.AddBelowOrEqualAverage(
- new ExcelAddress("B11:B20"));
-
- // -------------------------------------------------------------------
- // Create a Above StdDev rule
- // -------------------------------------------------------------------
- var cfRule9 = worksheet.ConditionalFormatting.AddAboveStdDev(
- new ExcelAddress("B11:B20"));
- cfRule9.StdDev = 0;
-
- // -------------------------------------------------------------------
- // Create a Below StdDev rule
- // -------------------------------------------------------------------
- var cfRule10 = worksheet.ConditionalFormatting.AddBelowStdDev(
- new ExcelAddress("B11:B20"));
-
- cfRule10.StdDev = 2;
-
- // -------------------------------------------------------------------
- // Create a Bottom rule
- // -------------------------------------------------------------------
- var cfRule11 = worksheet.ConditionalFormatting.AddBottom(
- new ExcelAddress("B11:B20"));
-
- cfRule11.Rank = 4;
-
- // -------------------------------------------------------------------
- // Create a Bottom Percent rule
- // -------------------------------------------------------------------
- var cfRule12 = worksheet.ConditionalFormatting.AddBottomPercent(
- new ExcelAddress("B11:B20"));
-
- cfRule12.Rank = 15;
-
- // -------------------------------------------------------------------
- // Create a Top rule
- // -------------------------------------------------------------------
- var cfRule13 = worksheet.ConditionalFormatting.AddTop(
- new ExcelAddress("B11:B20"));
-
- // -------------------------------------------------------------------
- // Create a Top Percent rule
- // -------------------------------------------------------------------
- var cfRule14 = worksheet.ConditionalFormatting.AddTopPercent(
- new ExcelAddress("B11:B20"));
-
- cfRule14.Style.Border.Left.Style = ExcelBorderStyle.Thin;
- cfRule14.Style.Border.Left.Color.Theme = 3;
- cfRule14.Style.Border.Bottom.Style = ExcelBorderStyle.DashDot;
- cfRule14.Style.Border.Bottom.Color.Index=8;
- cfRule14.Style.Border.Right.Style = ExcelBorderStyle.Thin;
- cfRule14.Style.Border.Right.Color.Color=Color.Blue;
- cfRule14.Style.Border.Top.Style = ExcelBorderStyle.Hair;
- cfRule14.Style.Border.Top.Color.Auto=true;
-
- // -------------------------------------------------------------------
- // Create a Last 7 Days rule
- // -------------------------------------------------------------------
- ExcelAddress timePeriodAddress = new ExcelAddress("D21:G34 C11:C20");
- var cfRule15 = worksheet.ConditionalFormatting.AddLast7Days(
- timePeriodAddress);
-
- cfRule15.Style.Fill.PatternType = ExcelFillStyle.LightTrellis;
- cfRule15.Style.Fill.PatternColor.Color = Color.BurlyWood;
- cfRule15.Style.Fill.BackgroundColor.Color = Color.LightCyan;
-
- // -------------------------------------------------------------------
- // Create a Last Month rule
- // -------------------------------------------------------------------
- var cfRule16 = worksheet.ConditionalFormatting.AddLastMonth(
- timePeriodAddress);
-
- cfRule16.Style.NumberFormat.Format = "YYYY";
- // -------------------------------------------------------------------
- // Create a Last Week rule
- // -------------------------------------------------------------------
- var cfRule17 = worksheet.ConditionalFormatting.AddLastWeek(
- timePeriodAddress);
- cfRule17.Style.NumberFormat.Format = "YYYY";
-
- // -------------------------------------------------------------------
- // Create a Next Month rule
- // -------------------------------------------------------------------
- var cfRule18 = worksheet.ConditionalFormatting.AddNextMonth(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a Next Week rule
- // -------------------------------------------------------------------
- var cfRule19 = worksheet.ConditionalFormatting.AddNextWeek(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a This Month rule
- // -------------------------------------------------------------------
- var cfRule20 = worksheet.ConditionalFormatting.AddThisMonth(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a This Week rule
- // -------------------------------------------------------------------
- var cfRule21 = worksheet.ConditionalFormatting.AddThisWeek(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a Today rule
- // -------------------------------------------------------------------
- var cfRule22 = worksheet.ConditionalFormatting.AddToday(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a Tomorrow rule
- // -------------------------------------------------------------------
- var cfRule23 = worksheet.ConditionalFormatting.AddTomorrow(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a Yesterday rule
- // -------------------------------------------------------------------
- var cfRule24 = worksheet.ConditionalFormatting.AddYesterday(
- timePeriodAddress);
-
- // -------------------------------------------------------------------
- // Create a BeginsWith rule
- // -------------------------------------------------------------------
- ExcelAddress cellIsAddress = new ExcelAddress("E11:E20");
- var cfRule25 = worksheet.ConditionalFormatting.AddBeginsWith(
- cellIsAddress);
-
- cfRule25.Text = "SearchMe";
-
- // -------------------------------------------------------------------
- // Create a Between rule
- // -------------------------------------------------------------------
- var cfRule26 = worksheet.ConditionalFormatting.AddBetween(
- cellIsAddress);
-
- cfRule26.Formula = "IF(E11>5,10,20)";
- cfRule26.Formula2 = "IF(E11>5,30,50)";
-
- // -------------------------------------------------------------------
- // Create a ContainsBlanks rule
- // -------------------------------------------------------------------
- var cfRule27 = worksheet.ConditionalFormatting.AddContainsBlanks(
- cellIsAddress);
-
- // -------------------------------------------------------------------
- // Create a ContainsErrors rule
- // -------------------------------------------------------------------
- var cfRule28 = worksheet.ConditionalFormatting.AddContainsErrors(
- cellIsAddress);
-
- // -------------------------------------------------------------------
- // Create a ContainsText rule
- // -------------------------------------------------------------------
- var cfRule29 = worksheet.ConditionalFormatting.AddContainsText(
- cellIsAddress);
-
- cfRule29.Text = "Me";
-
- // -------------------------------------------------------------------
- // Create a DuplicateValues rule
- // -------------------------------------------------------------------
- var cfRule30 = worksheet.ConditionalFormatting.AddDuplicateValues(
- cellIsAddress);
-
- // -------------------------------------------------------------------
- // Create an EndsWith rule
- // -------------------------------------------------------------------
- var cfRule31 = worksheet.ConditionalFormatting.AddEndsWith(
- cellIsAddress);
-
- cfRule31.Text = "EndText";
-
- // -------------------------------------------------------------------
- // Create an Equal rule
- // -------------------------------------------------------------------
- var cfRule32 = worksheet.ConditionalFormatting.AddEqual(
- cellIsAddress);
-
- cfRule32.Formula = "6";
-
- // -------------------------------------------------------------------
- // Create an Expression rule
- // -------------------------------------------------------------------
- var cfRule33 = worksheet.ConditionalFormatting.AddExpression(
- cellIsAddress);
-
- cfRule33.Formula = "E11=E12";
-
- // -------------------------------------------------------------------
- // Create a GreaterThan rule
- // -------------------------------------------------------------------
- var cfRule34 = worksheet.ConditionalFormatting.AddGreaterThan(
- cellIsAddress);
-
- cfRule34.Formula = "SE(E11<10,10,65)";
-
- // -------------------------------------------------------------------
- // Create a GreaterThanOrEqual rule
- // -------------------------------------------------------------------
- var cfRule35 = worksheet.ConditionalFormatting.AddGreaterThanOrEqual(
- cellIsAddress);
-
- cfRule35.Formula = "35";
-
- // -------------------------------------------------------------------
- // Create a LessThan rule
- // -------------------------------------------------------------------
- var cfRule36 = worksheet.ConditionalFormatting.AddLessThan(
- cellIsAddress);
-
- cfRule36.Formula = "36";
-
- // -------------------------------------------------------------------
- // Create a LessThanOrEqual rule
- // -------------------------------------------------------------------
- var cfRule37 = worksheet.ConditionalFormatting.AddLessThanOrEqual(
- cellIsAddress);
-
- cfRule37.Formula = "37";
-
- // -------------------------------------------------------------------
- // Create a NotBetween rule
- // -------------------------------------------------------------------
- var cfRule38 = worksheet.ConditionalFormatting.AddNotBetween(
- cellIsAddress);
-
- cfRule38.Formula = "333";
- cfRule38.Formula2 = "999";
-
- // -------------------------------------------------------------------
- // Create a NotContainsBlanks rule
- // -------------------------------------------------------------------
- var cfRule39 = worksheet.ConditionalFormatting.AddNotContainsBlanks(
- cellIsAddress);
-
- // -------------------------------------------------------------------
- // Create a NotContainsErrors rule
- // -------------------------------------------------------------------
- var cfRule40 = worksheet.ConditionalFormatting.AddNotContainsErrors(
- cellIsAddress);
-
- // -------------------------------------------------------------------
- // Create a NotContainsText rule
- // -------------------------------------------------------------------
- var cfRule41 = worksheet.ConditionalFormatting.AddNotContainsText(
- cellIsAddress);
-
- cfRule41.Text = "NotMe";
-
- // -------------------------------------------------------------------
- // Create an NotEqual rule
- // -------------------------------------------------------------------
- var cfRule42 = worksheet.ConditionalFormatting.AddNotEqual(
- cellIsAddress);
-
- cfRule42.Formula = "14";
-
- ExcelAddress cfAddress43 = new ExcelAddress("G2:G10");
- var cfRule43 = worksheet.ConditionalFormatting.AddThreeIconSet(cfAddress43, eExcelconditionalFormatting3IconsSetType.TrafficLights1);
-
- ExcelAddress cfAddress44 = new ExcelAddress("H2:H10");
- var cfRule44 = worksheet.ConditionalFormatting.AddDatabar(cfAddress44, Color.DarkBlue);
-
- // -----------------------------------------------------------
- // Removing Conditional Formatting rules
- // -----------------------------------------------------------
- // Remove one Rule by its object
- //worksheet.ConditionalFormatting.Remove(cfRule1);
-
- // Remove one Rule by index
- //worksheet.ConditionalFormatting.RemoveAt(1);
-
- // Remove one Rule by its Priority
- //worksheet.ConditionalFormatting.RemoveByPriority(2);
-
- // Remove all the Rules
- //worksheet.ConditionalFormatting.RemoveAll();
-
- // set some document properties
- package.Workbook.Properties.Title = "Conditional Formatting";
- package.Workbook.Properties.Author = "Eyal Seagull";
- package.Workbook.Properties.Comments = "This sample demonstrates how to add Conditional Formatting to an Excel 2007 worksheet using EPPlus";
-
- // set some custom property values
- package.Workbook.Properties.SetCustomPropertyValue("Checked by", "Eyal Seagull");
- package.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "EPPlus");
-
- // save our new workbook and we are done!
- package.Save();
- }
-
- return newFile.FullName;
- }
- }
-}
diff --git a/SampleApp/Sample15.cs b/SampleApp/Sample15.cs
deleted file mode 100644
index 78609e1..0000000
--- a/SampleApp/Sample15.cs
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * You may amend and distribute as you like, but don't remove this header!
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- * Code change notes:
- *
- * Author Change Date
- * ******************************************************************************
- * Jan Källman Added 2012-05-01
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Security.Cryptography.X509Certificates;
-using System.Drawing;
-using OfficeOpenXml.Style;
-using OfficeOpenXml.Drawing.Chart;
-namespace EPPlusSamples
-{
- class Sample15
- {
- public static void VBASample(DirectoryInfo outputDir)
- {
- //Create a macro-enabled workbook from scratch.
- VBASample1(outputDir);
-
- //Open Sample 1 and add code to change the chart to a bubble chart.
- VBASample2(outputDir);
-
- //Simple battleships game from scratch.
- VBASample3(outputDir);
- }
- private static void VBASample1(DirectoryInfo outputDir)
- {
- ExcelPackage pck = new ExcelPackage();
-
- //Add a worksheet.
- var ws=pck.Workbook.Worksheets.Add("VBA Sample");
- ws.Drawings.AddShape("VBASampleRect", eShapeStyle.RoundRect);
-
- //Create a vba project
- pck.Workbook.CreateVBAProject();
-
- //Now add some code to update the text of the shape...
- var sb = new StringBuilder();
-
- sb.AppendLine("Private Sub Workbook_Open()");
- sb.AppendLine(" [VBA Sample].Shapes(\"VBASampleRect\").TextEffect.Text = \"This text is set from VBA!\"");
- sb.AppendLine("End Sub");
- pck.Workbook.CodeModule.Code = sb.ToString();
-
- //And Save as xlsm
- pck.SaveAs(new FileInfo(outputDir.FullName + @"\sample15-1.xlsm"));
- }
- private static void VBASample2(DirectoryInfo outputDir)
- {
- //Open Sample 1 again
- ExcelPackage pck = new ExcelPackage(new FileInfo(outputDir.FullName + @"\sample1.xlsx"));
- //Create a vba project
- pck.Workbook.CreateVBAProject();
-
- //Now add some code that creates a bubble chart...
- var sb = new StringBuilder();
-
- sb.AppendLine("Public Sub CreateBubbleChart()");
- sb.AppendLine("Dim co As ChartObject");
- sb.AppendLine("Set co = Inventory.ChartObjects.Add(10, 100, 400, 200)");
- sb.AppendLine("co.Chart.SetSourceData Source:=Range(\"'Inventory'!$B$1:$E$5\")");
- sb.AppendLine("co.Chart.ChartType = xlBubble3DEffect 'Add a bubblechart");
- sb.AppendLine("End Sub");
-
- //Create a new module and set the code
- var module = pck.Workbook.VbaProject.Modules.AddModule("EPPlusGeneratedCode");
- module.Code = sb.ToString();
-
- //Call the newly created sub from the workbook open event
- pck.Workbook.CodeModule.Code = "Private Sub Workbook_Open()\r\nCreateBubbleChart\r\nEnd Sub";
-
- //Optionally, Sign the code with your company certificate.
- /*
- X509Store store = new X509Store(StoreLocation.CurrentUser);
- store.Open(OpenFlags.ReadOnly);
- pck.Workbook.VbaProject.Signature.Certificate = store.Certificates[0];
- */
-
- //And Save as xlsm
- pck.SaveAs(new FileInfo(outputDir.FullName + @"\sample15-2.xlsm"));
- }
- private static void VBASample3(DirectoryInfo outputDir)
- {
- //Now, lets do something a little bit more fun.
- //We are going to create a simple battleships game from scratch.
-
- ExcelPackage pck = new ExcelPackage();
-
- //Add a worksheet.
- var ws = pck.Workbook.Worksheets.Add("Battleship");
-
- ws.View.ShowGridLines = false;
- ws.View.ShowHeaders = false;
-
- ws.DefaultColWidth = 3;
- ws.DefaultRowHeight = 15;
-
- int gridSize=10;
-
- //Create the boards
- var board1 = ws.Cells[2, 2, 2 + gridSize - 1, 2 + gridSize - 1];
- var board2 = ws.Cells[2, 4+gridSize-1, 2 + gridSize-1, 4 + (gridSize-1)*2];
- CreateBoard(board1);
- CreateBoard(board2);
- ws.Select("B2");
- ws.Protection.IsProtected = true;
- ws.Protection.AllowSelectLockedCells = true;
-
- //Create the VBA Project
- pck.Workbook.CreateVBAProject();
- //Password protect your code
- pck.Workbook.VbaProject.Protection.SetPassword("EPPlus");
-
- //Add all the code from the textfiles in the Vba-Code sub-folder.
- pck.Workbook.CodeModule.Code = File.ReadAllText("..\\..\\VBA-Code\\ThisWorkbook.txt");
-
- //Add the sheet code
- ws.CodeModule.Code = File.ReadAllText("..\\..\\VBA-Code\\BattleshipSheet.txt");
- var m1=pck.Workbook.VbaProject.Modules.AddModule("Code");
- string code = File.ReadAllText("..\\..\\VBA-Code\\CodeModule.txt");
-
- //Insert your ships on the right board. you can changes these, but don't cheat ;)
- var ships = new string[]{
- "N3:N7",
- "P2:S2",
- "V9:V11",
- "O10:Q10",
- "R11:S11"};
-
- //Note: For security reasons you should never mix external data and code(to avoid code injections!), especially not on a webserver.
- //If you deside to do that anyway, be very careful with the validation of the data.
- //Be extra carefull if you sign the code.
- //Read more here http://en.wikipedia.org/wiki/Code_injection
-
- code = string.Format(code, ships[0],ships[1],ships[2],ships[3],ships[4], board1.Address, board2.Address); //Ships are injected into the constants in the module
- m1.Code = code;
-
- //Ships are displayed with a black background
- string shipsaddress = string.Join(",", ships);
- ws.Cells[shipsaddress].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
- ws.Cells[shipsaddress].Style.Fill.BackgroundColor.SetColor(Color.Black);
-
- var m2 = pck.Workbook.VbaProject.Modules.AddModule("ComputerPlay");
- m2.Code = File.ReadAllText("..\\..\\VBA-Code\\ComputerPlayModule.txt");
-
- var c1 = pck.Workbook.VbaProject.Modules.AddClass("Ship",false);
- c1.Code = File.ReadAllText("..\\..\\VBA-Code\\ShipClass.txt");
-
- //Add the info text shape.
- var tb = ws.Drawings.AddShape("txtInfo", eShapeStyle.Rect);
- tb.SetPosition(1, 0, 27, 0);
- tb.Fill.Color = Color.LightSlateGray;
- var rt1 = tb.RichText.Add("Battleships");
- rt1.Bold = true;
- tb.RichText.Add("\r\nDouble-click on the left board to make your move. Find and sink all ships to win!");
-
- //Set the headers.
- ws.SetValue("B1", "Computer Grid");
- ws.SetValue("M1", "Your Grid");
- ws.Row(1).Style.Font.Size = 18;
-
- AddChart(ws.Cells["B13"], "chtHitPercent", "Player");
- AddChart(ws.Cells["M13"], "chtComputerHitPercent", "Computer");
-
- ws.Names.Add("LogStart", ws.Cells["B24"]);
- ws.Cells["B24:X224"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Black);
- ws.Cells["B25:X224"].Style.Font.Name = "Consolas";
- ws.SetValue("B24", "Log");
- ws.Cells["B24"].Style.Font.Bold = true;
- ws.Cells["B24:X24"].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Black);
- var cf=ws.Cells["B25:B224"].ConditionalFormatting.AddContainsText();
- cf.Text = "hit";
- cf.Style.Font.Color.Color = Color.Red;
-
- //If you have a valid certificate for code signing you can use this code to set it.
- ///*** Try to find a cert valid for signing... ***/
- //X509Store store = new X509Store(StoreLocation.CurrentUser);
- //store.Open(OpenFlags.ReadOnly);
- //foreach (var cert in store.Certificates)
- //{
- // if (cert.HasPrivateKey && cert.NotBefore <= DateTime.Today && cert.NotAfter >= DateTime.Today)
- // {
- // pck.Workbook.VbaProject.Signature.Certificate = cert;
- // break;
- // }
- //}
-
- pck.SaveAs(new FileInfo(outputDir.FullName + @"\sample15-3.xlsm"));
- }
-
- private static void AddChart(ExcelRange rng,string name, string prefix)
- {
- var chrt = (ExcelPieChart)rng.Worksheet.Drawings.AddChart(name, eChartType.Pie);
- chrt.SetPosition(rng.Start.Row-1, 0, rng.Start.Column-1, 0);
- chrt.To.Row = rng.Start.Row+9;
- chrt.To.Column = rng.Start.Column + 9;
- chrt.Style = eChartStyle.Style18;
- chrt.DataLabel.ShowPercent = true;
-
- var serie = chrt.Series.Add(rng.Offset(2, 2, 1, 2), rng.Offset(1, 2, 1, 2));
- serie.Header = "Hits";
-
- chrt.Title.Text = "Hit ratio";
-
- var n1 = rng.Worksheet.Names.Add(prefix + "Misses", rng.Offset(2, 2));
- n1.Value = 0;
- var n2 = rng.Worksheet.Names.Add(prefix + "Hits", rng.Offset(2, 3));
- n2.Value = 0;
- rng.Offset(1, 2).Value = "Misses";
- rng.Offset(1, 3).Value = "Hits";
- }
-
- private static void CreateBoard(ExcelRange rng)
- {
- //Create a gradiant background with one dark and one light blue color
- rng.Style.Fill.Gradient.Color1.SetColor(Color.FromArgb(0x80, 0x80, 0XFF));
- rng.Style.Fill.Gradient.Color2.SetColor(Color.FromArgb(0x20, 0x20, 0XFF));
- rng.Style.Fill.Gradient.Type = ExcelFillGradientType.None;
- for (int col = 0; col <= rng.End.Column - rng.Start.Column; col++)
- {
- for (int row = 0; row <= rng.End.Row - rng.Start.Row; row++)
- {
- if (col % 4 == 0)
- {
- rng.Offset(row, col, 1, 1).Style.Fill.Gradient.Degree = 45;
- }
- if (col % 4 == 1)
- {
- rng.Offset(row, col, 1, 1).Style.Fill.Gradient.Degree = 70;
- }
- if (col % 4 == 2)
- {
- rng.Offset(row, col, 1, 1).Style.Fill.Gradient.Degree = 110;
- }
- else
- {
- rng.Offset(row, col, 1, 1).Style.Fill.Gradient.Degree = 135;
- }
- }
- }
- //Set the inner cell border to thin, light gray
- rng.Style.Border.Top.Style = ExcelBorderStyle.Thin;
- rng.Style.Border.Top.Color.SetColor(Color.Gray);
- rng.Style.Border.Right.Style = ExcelBorderStyle.Thin;
- rng.Style.Border.Right.Color.SetColor(Color.Gray);
- rng.Style.Border.Left.Style = ExcelBorderStyle.Thin;
- rng.Style.Border.Left.Color.SetColor(Color.Gray);
- rng.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
- rng.Style.Border.Bottom.Color.SetColor(Color.Gray);
-
- //Solid black border around the board.
- rng.Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);
- }
- }
-}
diff --git a/SampleApp/Sample16.cs b/SampleApp/Sample16.cs
deleted file mode 100644
index c750eaa..0000000
--- a/SampleApp/Sample16.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.Text;
-using OfficeOpenXml;
-using OfficeOpenXml.Table;
-
-namespace EPPlusSamples
-{
- class Sample16
- {
- public static void RunSample16(DirectoryInfo outputDir)
- {
- using (var package = new ExcelPackage())
- {
- var dataTable = new DataTable("test");
- dataTable.Columns.Add("col1");
- dataTable.Columns.Add("col2");
- dataTable.Columns.Add("col3");
- dataTable.Columns.Add("col4");
- dataTable.Rows.Add("qwe11", "qwe12", "qwe13", "qwe14");
- dataTable.Rows.Add("qwe21", "qwe22", "qwe23", "qwe24");
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(dataTable.TableName);
- worksheet.Cells["A1"].LoadFromDataTable(dataTable, true, TableStyles.None);
- worksheet.Protection.AllowSelectLockedCells = false;
- worksheet.Protection.AllowSelectUnlockedCells = true;
- worksheet.Protection.AllowSort = true;
- worksheet.Protection.AllowFormatColumns = true;
- worksheet.Protection.AllowAutoFilter = true;
- worksheet.Protection.AllowEditObject = true;
- worksheet.Protection.IsProtected = true;
- var r1=worksheet.ProtectedRanges.Add("Range1", new ExcelAddress(1, 1, worksheet.Dimension.End.Row, 4));
- worksheet.ProtectedRanges.Remove(r1);
- var r2 = worksheet.ProtectedRanges.Add("Range2", new ExcelAddress("F3:T12,F15:T30"));
- r2.SetPassword("EPPlus");
-
- worksheet.Column(1).Width = 30;
- worksheet.Column(2).Width = 30;
- worksheet.Column(3).Width = 100;
- worksheet.Column(4).Width = 100;
- worksheet.Cells[1, 4, worksheet.Dimension.End.Row, 4].Style.Locked = false;
- worksheet.Cells[1, 3, worksheet.Dimension.End.Row, 4].Style.WrapText = true;
-
- using (var fs = new FileStream(Path.Combine(outputDir.ToString(), "sample16.xlsx"), FileMode.Create))
- package.SaveAs(fs);
- }
-
- using (var fs = new FileStream(Path.Combine(outputDir.ToString(), "sample16.xlsx"), FileMode.Open, FileAccess.Read))
- using (var package = new ExcelPackage(fs))
- {
- foreach (var worksheet1 in package.Workbook.Worksheets)
- {
- var prCollection = worksheet1.ProtectedRanges;
- if (prCollection.Count != 1)
- throw new InvalidOperationException("Expected 1 element");
- }
- }
- }
- }
-}
diff --git a/SampleApp/Sample2.cs b/SampleApp/Sample2.cs
deleted file mode 100644
index 03a6eb4..0000000
--- a/SampleApp/Sample2.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 10-SEP-2009
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-
-namespace EPPlusSamples
-{
- /// <summary>
- /// Simply opens an existing file and reads some values and properties
- /// </summary>
- class Sample2
- {
- public static void RunSample2(string FilePath)
- {
- Console.WriteLine("Reading column 2 of {0}", FilePath);
- Console.WriteLine();
-
- FileInfo existingFile = new FileInfo(FilePath);
- using (ExcelPackage package = new ExcelPackage(existingFile))
- {
- // get the first worksheet in the workbook
- ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
- int col = 2; //The item description
- // output the data in column 2
- for (int row = 2; row < 5; row++)
- Console.WriteLine("\tCell({0},{1}).Value={2}", row, col, worksheet.Cells[row, col].Value);
-
- // output the formula in row 5
- Console.WriteLine("\tCell({0},{1}).Formula={2}", 3, 5, worksheet.Cells[3, 5].Formula);
- Console.WriteLine("\tCell({0},{1}).FormulaR1C1={2}", 3, 5, worksheet.Cells[3, 5].FormulaR1C1);
-
- // output the formula in row 5
- Console.WriteLine("\tCell({0},{1}).Formula={2}", 5, 3, worksheet.Cells[5, 3].Formula);
- Console.WriteLine("\tCell({0},{1}).FormulaR1C1={2}", 5, 3, worksheet.Cells[5, 3].FormulaR1C1);
-
- } // the using statement automatically calls Dispose() which closes the package.
-
- Console.WriteLine();
- Console.WriteLine("Sample 2 complete");
- Console.WriteLine();
- }
- }
-}
diff --git a/SampleApp/Sample3.cs b/SampleApp/Sample3.cs
deleted file mode 100644
index 6697cae..0000000
--- a/SampleApp/Sample3.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 10-SEP-2009
- *******************************************************************************/
-
-/*
- * Sample code demonstrating how to generate Excel spreadsheets on the server using
- * Office Open XML and the ExcelPackage wrapper classes.
- *
- * ExcelPackage provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/ExcelPackage for details.
- *
- * Sample 3: Creates a workbook based on a template and populates using the database data.
- *
- * Copyright 2007 © Dr John Tunnicliffe
- * mailto:dr.john.tunnicliffe@btinternet.com
- * All rights reserved.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- */
-using System;
-using System.IO;
-using System.Xml;
-using OfficeOpenXml;
-using System.Data.SqlClient;
-using System.Drawing;
-using OfficeOpenXml.Style;
-
-namespace EPPlusSamples
-{
- class Sample3
- {
- /// <summary>
- /// Sample 3 - creates a workbook and populates using data from the AdventureWorks database
- /// This sample requires the AdventureWorks database.
- /// This one is from the orginal Excelpackage sample project, but without the template
- /// </summary>
- /// <param name="outputDir">The output directory</param>
- /// <param name="templateDir">The location of the sample template</param>
- /// <param name="connectionString">The connection string to your copy of the AdventureWorks database</param>
- public static string RunSample3(DirectoryInfo outputDir, string connectionString)
- {
-
- string file = outputDir.FullName + @"\sample3.xlsx";
- if (File.Exists(file)) File.Delete(file);
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample3.xlsx");
-
- // ok, we can run the real code of the sample now
- using (ExcelPackage xlPackage = new ExcelPackage(newFile))
- {
- // uncomment this line if you want the XML written out to the outputDir
- //xlPackage.DebugMode = true;
-
- // get handle to the existing worksheet
- ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets.Add("Sales");
- var namedStyle = xlPackage.Workbook.Styles.CreateNamedStyle("HyperLink"); //This one is language dependent
- namedStyle.Style.Font.UnderLine = true;
- namedStyle.Style.Font.Color.SetColor(Color.Blue);
- if (worksheet != null)
- {
- const int startRow = 5;
- int row = startRow;
- //Create Headers and format them
- worksheet.Cells["A1"].Value = "AdventureWorks Inc.";
- using (ExcelRange r = worksheet.Cells["A1:G1"])
- {
- r.Merge = true;
- r.Style.Font.SetFromFont(new Font("Britannic Bold", 22, FontStyle.Italic));
- r.Style.Font.Color.SetColor(Color.White);
- r.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.CenterContinuous;
- r.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
- r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23,55,93));
- }
- worksheet.Cells["A2"].Value = "Year-End Sales Report";
- using (ExcelRange r = worksheet.Cells["A2:G2"])
- {
- r.Merge = true;
- r.Style.Font.SetFromFont(new Font("Britannic Bold", 18, FontStyle.Italic));
- r.Style.Font.Color.SetColor(Color.Black);
- r.Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
- r.Style.Fill.PatternType = ExcelFillStyle.Solid;
- r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(184,204,228));
- }
-
- worksheet.Cells["A4"].Value = "Name";
- worksheet.Cells["B4"].Value = "Job Title";
- worksheet.Cells["C4"].Value = "Region";
- worksheet.Cells["D4"].Value = "Monthly Quota";
- worksheet.Cells["E4"].Value = "Quota YTD";
- worksheet.Cells["F4"].Value = "Sales YTD";
- worksheet.Cells["G4"].Value = "Quota %";
- worksheet.Cells["A4:G4"].Style.Fill.PatternType = ExcelFillStyle.Solid;
- worksheet.Cells["A4:G4"].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(184, 204, 228));
- worksheet.Cells["A4:G4"].Style.Font.Bold = true;
-
-
- // lets connect to the AdventureWorks sample database for some data
- using (SqlConnection sqlConn = new SqlConnection(connectionString))
- {
- sqlConn.Open();
- using (SqlCommand sqlCmd = new SqlCommand("select LastName + ', ' + FirstName AS [Name], EmailAddress, JobTitle, CountryRegionName, ISNULL(SalesQuota,0) AS SalesQuota, ISNULL(SalesQuota,0)*12 AS YearlyQuota, SalesYTD from Sales.vSalesPerson ORDER BY SalesYTD desc", sqlConn))
- {
- using (SqlDataReader sqlReader = sqlCmd.ExecuteReader())
- {
- // get the data and fill rows 5 onwards
- while (sqlReader.Read())
- {
- int col = 1;
- // our query has the columns in the right order, so simply
- // iterate through the columns
- for (int i = 0; i < sqlReader.FieldCount; i++)
- {
- // use the email address as a hyperlink for column 1
- if (sqlReader.GetName(i) == "EmailAddress")
- {
- // insert the email address as a hyperlink for the name
- string hyperlink = "mailto:" + sqlReader.GetValue(i).ToString();
- worksheet.Cells[row, 1].Hyperlink = new Uri(hyperlink, UriKind.Absolute);
- }
- else
- {
- // do not bother filling cell with blank data (also useful if we have a formula in a cell)
- if (sqlReader.GetValue(i) != null)
- worksheet.Cells[row, col].Value = sqlReader.GetValue(i);
- col++;
- }
- }
- row++;
- }
- sqlReader.Close();
-
- worksheet.Cells[startRow, 1, row - 1, 1].StyleName = "HyperLink";
- worksheet.Cells[startRow, 4, row - 1, 6].Style.Numberformat.Format = "[$$-409]#,##0";
- worksheet.Cells[startRow, 7, row - 1, 7].Style.Numberformat.Format = "0%";
-
- worksheet.Cells[startRow, 7, row - 1, 7].FormulaR1C1 = "=IF(RC[-2]=0,0,RC[-1]/RC[-2])";
-
- //Set column width
- worksheet.Column(1).Width = 25;
- worksheet.Column(2).Width = 28;
- worksheet.Column(3).Width = 18;
- worksheet.Column(4).Width = 12;
- worksheet.Column(5).Width = 10;
- worksheet.Column(6).Width = 10;
- worksheet.Column(7).Width = 12;
- }
- }
- sqlConn.Close();
- }
-
- // lets set the header text
- worksheet.HeaderFooter.OddHeader.CenteredText = "AdventureWorks Inc. Sales Report";
- // add the page number to the footer plus the total number of pages
- worksheet.HeaderFooter.OddFooter.RightAlignedText =
- string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
- // add the sheet name to the footer
- worksheet.HeaderFooter.OddFooter.CenteredText = ExcelHeaderFooter.SheetName;
- // add the file path to the footer
- worksheet.HeaderFooter.OddFooter.LeftAlignedText = ExcelHeaderFooter.FilePath + ExcelHeaderFooter.FileName;
- }
- // we had better add some document properties to the spreadsheet
-
- // set some core property values
- xlPackage.Workbook.Properties.Title = "Sample 3";
- xlPackage.Workbook.Properties.Author = "John Tunnicliffe";
- xlPackage.Workbook.Properties.Subject = "ExcelPackage Samples";
- xlPackage.Workbook.Properties.Keywords = "Office Open XML";
- xlPackage.Workbook.Properties.Category = "ExcelPackage Samples";
- xlPackage.Workbook.Properties.Comments = "This sample demonstrates how to create an Excel 2007 file from scratch using the Packaging API and Office Open XML";
-
- // set some extended property values
- xlPackage.Workbook.Properties.Company = "AdventureWorks Inc.";
- xlPackage.Workbook.Properties.HyperlinkBase = new Uri("http://www.codeplex.com/MSFTDBProdSamples");
-
- // set some custom property values
- xlPackage.Workbook.Properties.SetCustomPropertyValue("Checked by", "John Tunnicliffe");
- xlPackage.Workbook.Properties.SetCustomPropertyValue("EmployeeID", "1147");
- xlPackage.Workbook.Properties.SetCustomPropertyValue("AssemblyName", "ExcelPackage");
-
- // save the new spreadsheet
- xlPackage.Save();
- }
-
- // if you want to take a look at the XML created in the package, simply uncomment the following lines
- // These copy the output file and give it a zip extension so you can open it and take a look!
- //FileInfo zipFile = new FileInfo(outputDir.FullName + @"\sample3.zip");
- //if (zipFile.Exists) zipFile.Delete();
- //newFile.CopyTo(zipFile.FullName);
-
- return newFile.FullName;
- }
- }
-}
diff --git a/SampleApp/Sample4.cs b/SampleApp/Sample4.cs
deleted file mode 100644
index b9edd0b..0000000
--- a/SampleApp/Sample4.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 10-SEP-2009
- *******************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Diagnostics;
-using OfficeOpenXml;
-using System.IO;
-using System.Data.SqlClient;
-using OfficeOpenXml.Drawing;
-using OfficeOpenXml.Drawing.Chart;
-using OfficeOpenXml.Style;
-using System.Drawing;
-
-namespace EPPlusSamples
-{
- class Sample4
- {
- /// <summary>
- /// This sample creates a new workbook from a template file containing a chart and populates it with Exchangrates from
- /// the Adventureworks database and set the three series on the chart.
- /// </summary>
- /// <param name="connectionString">Connectionstring to the Adventureworks db</param>
- /// <param name="template">the template</param>
- /// <param name="outputdir">output dir</param>
- /// <returns></returns>
- public static string RunSample4(string connectionString, FileInfo template, DirectoryInfo outputdir)
- {
- using (ExcelPackage p = new ExcelPackage(template, true))
- {
- //Set up the headers
- ExcelWorksheet ws = p.Workbook.Worksheets[1];
- ws.Cells["A20"].Value = "Date";
- ws.Cells["B20"].Value = "EOD Rate";
- ws.Cells["B20:D20"].Merge = true;
- ws.Cells["E20"].Value = "Change";
- ws.Cells["E20:G20"].Merge = true;
- ws.Cells["B20:E20"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
- using (ExcelRange row = ws.Cells["A20:G20"])
- {
- row.Style.Fill.PatternType = ExcelFillStyle.Solid;
- row.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23,55,93));
- row.Style.Font.Color.SetColor(Color.White);
- row.Style.Font.Bold = true;
- }
- ws.Cells["B21"].Value = "USD/JPY";
- ws.Cells["C21"].Value = "USD/EUR";
- ws.Cells["D21"].Value = "USD/GBP";
- ws.Cells["E21"].Value = "USD/JPY";
- ws.Cells["F21"].Value = "USD/EUR";
- ws.Cells["G21"].Value = "USD/GBP";
- using (ExcelRange row = ws.Cells["A21:G21"])
- {
- row.Style.Fill.PatternType = ExcelFillStyle.Solid;
- row.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(184, 204, 228));
- row.Style.Font.Color.SetColor(Color.Black);
- row.Style.Font.Bold = true;
- }
-
- int startRow = 22;
- //Connect to the database and fill the data
- using (SqlConnection sqlConn = new SqlConnection(connectionString))
- {
- int row = startRow;
- sqlConn.Open();
- using (SqlCommand sqlCmd = new SqlCommand("SELECT CurrencyRateDate, SUM(Case when ToCurrencyCode = 'JPY' Then EndOfDayRate Else 0 END) AS [JPY], SUM(Case when ToCurrencyCode = 'EUR' Then EndOfDayRate Else 0 END) AS [EUR], SUM(Case when ToCurrencyCode = 'GBP' Then EndOfDayRate Else 0 END) AS [GBP] FROM [AdventureWorks].[Sales].[CurrencyRate] where [FromCurrencyCode]='USD' AND ToCurrencyCode in ('JPY', 'EUR', 'GBP') GROUP BY CurrencyRateDate ORDER BY CurrencyRateDate", sqlConn))
- {
- using (SqlDataReader sqlReader = sqlCmd.ExecuteReader())
- {
- // get the data and fill rows 22 onwards
- while (sqlReader.Read())
- {
- ws.Cells[row, 1].Value = sqlReader[0];
- ws.Cells[row, 2].Value = sqlReader[1];
- ws.Cells[row, 3].Value = sqlReader[2];
- ws.Cells[row, 4].Value = sqlReader[3];
- row++;
- }
- }
- //Set the numberformat
- ws.Cells[startRow, 1, row - 1, 1].Style.Numberformat.Format = "yyyy-mm-dd";
- ws.Cells[startRow, 2, row - 1, 4].Style.Numberformat.Format = "#,##0.0000";
- //Set the Formulas
- ws.Cells[startRow + 1, 5, row - 1, 7].Formula = string.Format("B${0}/B{1}-1", startRow, startRow + 1);
- ws.Cells[startRow, 5, row - 1, 7].Style.Numberformat.Format = "0.00%";
- }
-
- //Set the series for the chart. The series must exist in the template or the program will crash.
- ExcelChart chart = ((ExcelChart)ws.Drawings["SampleChart"]);
- chart.Title.Text = "Exchange rate %";
- chart.Series[0].Header = "USD/JPY";
- chart.Series[0].XSeries = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow+1, 1, row - 1, 1);
- chart.Series[0].Series = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 5, row - 1, 5);
-
- chart.Series[1].Header = "USD/EUR";
- chart.Series[1].XSeries = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 1, row - 1, 1);
- chart.Series[1].Series = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 6, row - 1, 6);
-
- chart.Series[2].Header = "USD/GBP";
- chart.Series[2].XSeries = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 1, row - 1, 1);
- chart.Series[2].Series = "'" + ws.Name + "'!" + ExcelRange.GetAddress(startRow + 1, 7, row - 1, 7);
- }
- //Get the documet as a byte array from the stream and save it to disk. (This is usefull in a webapplication) ...
- Byte[] bin = p.GetAsByteArray();
-
- string file = outputdir + "\\sample4.xlsx";
- File.WriteAllBytes(file, bin);
- return file;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/SampleApp/Sample5.cs b/SampleApp/Sample5.cs
deleted file mode 100644
index c56c2f1..0000000
--- a/SampleApp/Sample5.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 07-JAN-2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using OfficeOpenXml.Drawing.Chart;
-using OfficeOpenXml.Drawing;
-using System.Drawing;
-
-namespace EPPlusSamples
-{
- class Sample5
- {
- /// <summary>
- /// Sample 5 - open Sample 1 and add 2 new rows and a Piechart
- /// </summary>
- public static string RunSample5(DirectoryInfo outputDir)
- {
- FileInfo templateFile = new FileInfo(outputDir.FullName + @"\sample1.xlsx");
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample5.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sample5.xlsx");
- }
- using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
- {
- //Open worksheet 1
- ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
- worksheet.InsertRow(5, 2);
-
- worksheet.Cells["A5"].Value = "12010";
- worksheet.Cells["B5"].Value = "Drill";
- worksheet.Cells["C5"].Value = 20;
- worksheet.Cells["D5"].Value = 8;
-
- worksheet.Cells["A6"].Value = "12011";
- worksheet.Cells["B6"].Value = "Crowbar";
- worksheet.Cells["C6"].Value = 7;
- worksheet.Cells["D6"].Value = 23.48;
-
- worksheet.Cells["E2:E6"].FormulaR1C1 = "RC[-2]*RC[-1]";
-
- var name = worksheet.Names.Add("SubTotalName", worksheet.Cells["C7:E7"]);
- name.Style.Font.Italic = true;
- name.Formula = "SUBTOTAL(9,C2:C6)";
-
- //Format the new rows
- worksheet.Cells["C5:C6"].Style.Numberformat.Format = "#,##0";
- worksheet.Cells["D5:E6"].Style.Numberformat.Format = "#,##0.00";
-
- var chart = (worksheet.Drawings.AddChart("PieChart", eChartType.Pie3D) as ExcelPieChart);
-
- chart.Title.Text = "Total";
- //From row 1 colum 5 with five pixels offset
- chart.SetPosition(0, 0, 5, 5);
- chart.SetSize(600, 300);
-
- ExcelAddress valueAddress = new ExcelAddress(2, 5, 6, 5);
- var ser = (chart.Series.Add(valueAddress.Address, "B2:B6") as ExcelPieChartSerie);
- chart.DataLabel.ShowCategory = true;
- chart.DataLabel.ShowPercent = true;
-
- chart.Legend.Border.LineStyle = eLineStyle.Solid;
- chart.Legend.Border.Fill.Style = eFillStyle.SolidFill;
- chart.Legend.Border.Fill.Color = Color.DarkBlue;
-
- //Switch the PageLayoutView back to normal
- worksheet.View.PageLayoutView = false;
- // save our new workbook and we are done!
- package.Save();
- }
-
- return newFile.FullName;
- }
- }
-}
diff --git a/SampleApp/Sample6.cs b/SampleApp/Sample6.cs
deleted file mode 100644
index 1ed1005..0000000
--- a/SampleApp/Sample6.cs
+++ /dev/null
@@ -1,594 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 25-JAN-2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Drawing;
-using OfficeOpenXml;
-using OfficeOpenXml.Drawing;
-using OfficeOpenXml.Drawing.Chart;
-using System.Drawing.Imaging;
-using OfficeOpenXml.Style;
-using OfficeOpenXml.Style.XmlAccess;
-using OfficeOpenXml.Table;
-namespace EPPlusSamples
-{
- /// <summary>
- /// Sample 6 - Reads the filesystem and makes a report.
- /// </summary>
- class Sample6
- {
- #region "Icon API function"
- [StructLayout(LayoutKind.Sequential)]
- public struct SHFILEINFO
- {
- public IntPtr hIcon;
- public IntPtr iIcon;
- public uint dwAttributes;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
- public string szDisplayName;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
- public string szTypeName;
- };
- public const uint SHGFI_ICON = 0x100;
- public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
- public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
- [DllImport("shell32.dll")]
- public static extern IntPtr SHGetFileInfo(string pszPath,
- uint dwFileAttributes,
- ref SHFILEINFO psfi,
- uint cbSizeFileInfo,
- uint uFlags);
- [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = CharSet.Auto)]
- extern static bool DestroyIcon(IntPtr handle);
- #endregion
- public class StatItem : IComparable<StatItem>
- {
- public string Name { get; set; }
- public int Count { get; set; }
- public long Size { get; set; }
-
- #region IComparable<StatItem> Members
-
- //Default compare Size
- public int CompareTo(StatItem other)
- {
- return Size < other.Size ? -1 :
- (Size > other.Size ? 1 : 0);
- }
-
- #endregion
- }
- static int _maxLevels;
-
- static Dictionary<string, StatItem> _extStat = new Dictionary<string, StatItem>();
- static List<StatItem> _fileSize = new List<StatItem>();
- /// <summary>
- /// Sample 6 - Reads the filesystem and makes a report.
- /// </summary>
- /// <param name="outputDir">Output directory</param>
- /// <param name="dir">Directory to scan</param>
- /// <param name="depth">How many levels?</param>
- /// <param name="skipIcons">Skip the icons in column A. A lot faster</param>
- public static string RunSample6(DirectoryInfo outputDir, DirectoryInfo dir, int depth, bool skipIcons)
- {
- _maxLevels = depth;
-
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample6.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sample6.xlsx");
- }
-
- //Create the workbook
- ExcelPackage pck = new ExcelPackage(newFile);
- //Add the Content sheet
- var ws = pck.Workbook.Worksheets.Add("Content");
-
- ws.View.ShowGridLines = false;
-
- ws.Column(1).Width = 2.5;
- ws.Column(2).Width = 60;
- ws.Column(3).Width = 16;
- ws.Column(4).Width = 20;
- ws.Column(5).Width =20;
-
- //This set the outline for column 4 and 5 and hide them
- ws.Column(4).OutlineLevel = 1;
- ws.Column(4).Collapsed = true;
- ws.Column(5).OutlineLevel = 1;
- ws.Column(5).Collapsed = true;
- ws.OutLineSummaryRight = true;
-
- //Headers
- ws.Cells["B1"].Value = "Name";
- ws.Cells["C1"].Value = "Size";
- ws.Cells["D1"].Value = "Created";
- ws.Cells["E1"].Value = "Last modified";
- ws.Cells["B1:E1"].Style.Font.Bold = true;
-
- ws.View.FreezePanes(2,1);
- ws.Select("A2");
- //height is 20 pixels
- double height = 20 * 0.75;
- //Start at row 2;
- int row = 2;
-
- //Load the directory content to sheet 1
- row = AddDirectory(ws, dir, row, height, 0, skipIcons);
- ws.OutLineSummaryBelow = false;
-
- //Format columns
- ws.Cells[1, 3, row - 1, 3].Style.Numberformat.Format = "#,##0";
- ws.Cells[1, 4, row - 1, 4].Style.Numberformat.Format = "yyyy-MM-dd hh:mm";
- ws.Cells[1, 5, row - 1, 5].Style.Numberformat.Format = "yyyy-MM-dd hh:mm";
-
- //Add the textbox
- var shape = ws.Drawings.AddShape("txtDesc", eShapeStyle.Rect);
- shape.SetPosition(1, 5, 6, 5);
- shape.SetSize(400, 200);
-
- shape.Text = "This example demonstrates how to create various drawing objects like pictures, shapes and charts.\n\r\n\rThe first sheet contains all subdirectories and files with an icon, name, size and dates.\n\r\n\rThe second sheet contains statistics about extensions and the top-10 largest files.";
- shape.Fill.Style = eFillStyle.SolidFill;
- shape.Fill.Color = Color.DarkSlateGray;
- shape.Fill.Transparancy = 20;
- shape.Border.Fill.Style = eFillStyle.SolidFill;
- shape.Border.LineStyle = eLineStyle.LongDash;
- shape.Border.Width = 1;
- shape.Border.Fill.Color = Color.Black;
- shape.Border.LineCap = eLineCap.Round;
- shape.TextAnchoring = eTextAnchoringType.Top;
- shape.TextVertical = eTextVerticalType.Horizontal;
- shape.TextAnchoringControl=false;
- ws.Calculate();
- ws.Cells[1,2,row,5].AutoFitColumns();
-
- //Add the graph sheet
- AddGraphs(pck, row, dir.FullName);
-
- //Add a HyperLink to the statistics sheet.
- var namedStyle = pck.Workbook.Styles.CreateNamedStyle("HyperLink"); //This one is language dependent
- namedStyle.Style.Font.UnderLine = true;
- namedStyle.Style.Font.Color.SetColor(Color.Blue);
- ws.Cells["K13"].Hyperlink = new ExcelHyperLink("Statistics!A1", "Statistics");
- ws.Cells["K13"].StyleName = "HyperLink";
-
- //Printer settings
- ws.PrinterSettings.FitToPage = true;
- ws.PrinterSettings.FitToWidth = 1;
- ws.PrinterSettings.FitToHeight = 0;
- ws.PrinterSettings.RepeatRows = new ExcelAddress("1:1"); //Print titles
- ws.PrinterSettings.PrintArea = ws.Cells[1, 1, row - 1, 5];
- pck.Workbook.Calculate();
-
- //Done! save the sheet
- pck.Save();
-
- return newFile.FullName;
- }
- /// <summary>
- /// This method adds the comment to the header row
- /// </summary>
- /// <param name="ws"></param>
- private static void AddComments(ExcelWorksheet ws)
- {
- //Add Comments using the range class
- var comment = ws.Cells["A3"].AddComment("Jan Källman:\r\n", "JK");
- comment.Font.Bold = true;
- var rt = comment.RichText.Add("This column contains the extensions.");
- rt.Bold = false;
- comment.AutoFit = true;
-
- //Add a comment using the Comment collection
- comment = ws.Comments.Add(ws.Cells["B3"],"This column contains the size of the files.", "JK");
- //This sets the size and position. (The position is only when the comment is visible)
- comment.From.Column = 7;
- comment.From.Row = 3;
- comment.To.Column = 16;
- comment.To.Row = 8;
- comment.BackgroundColor = Color.White;
- comment.RichText.Add("\r\nTo format the numbers use the Numberformat-property like:\r\n");
-
- ws.Cells["B3:B42"].Style.Numberformat.Format = "#,##0";
-
- //Format the code using the RichText Collection
- var rc = comment.RichText.Add("//Format the Size and Count column\r\n");
- rc.FontName = "Courier New";
- rc.Color = Color.FromArgb(0, 128, 0);
- rc = comment.RichText.Add("ws.Cells[");
- rc.Color = Color.Black;
- rc = comment.RichText.Add("\"B3:B42\"");
- rc.Color = Color.FromArgb(123, 21, 21);
- rc = comment.RichText.Add("].Style.Numberformat.Format = ");
- rc.Color = Color.Black;
- rc = comment.RichText.Add("\"#,##0\"");
- rc.Color = Color.FromArgb(123, 21, 21);
- rc = comment.RichText.Add(";");
- rc.Color = Color.Black;
- }
- /// <summary>
- /// Add the second sheet containg the graphs
- /// </summary>
- /// <param name="pck">Package</param>
- /// <param name="rows"></param>
- /// <param name="header"></param>
- private static void AddGraphs(ExcelPackage pck, int rows, string dir)
- {
- var ws = pck.Workbook.Worksheets.Add("Statistics");
- ws.View.ShowGridLines = false;
-
- //Set first the header and format it
- ws.Cells["A1"].Value = "Statistics for ";
- using (ExcelRange r = ws.Cells["A1:O1"])
- {
- r.Merge = true;
- r.Style.Font.SetFromFont(new Font("Arial", 22, FontStyle.Regular));
- r.Style.Font.Color.SetColor(Color.White);
- r.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.CenterContinuous;
- r.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
- r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(23, 55, 93));
- }
-
- //Use the RichText property to change the font for the directory part of the cell
- var rtDir = ws.Cells["A1"].RichText.Add(dir);
- rtDir.FontName = "Consolas";
- rtDir.Size=18;
-
- //Start with the Extention Size
- List<StatItem> lst = new List<StatItem>(_extStat.Values);
- lst.Sort();
-
- //Add rows
- int row=AddStatRows(ws, lst, 2, "Extensions", "Size");
-
- //Add commets to the Extensions header
- AddComments(ws);
-
- //Add the piechart
- var pieChart = ws.Drawings.AddChart("crtExtensionsSize", eChartType.PieExploded3D) as ExcelPieChart;
- //Set top left corner to row 1 column 2
- pieChart.SetPosition(1, 0, 2, 0);
- pieChart.SetSize(400, 400);
- pieChart.Series.Add(ExcelRange.GetAddress(3, 2, row-1, 2), ExcelRange.GetAddress(3, 1, row-1, 1));
-
- pieChart.Title.Text = "Extension Size";
- //Set datalabels and remove the legend
- pieChart.DataLabel.ShowCategory = true;
- pieChart.DataLabel.ShowPercent = true;
- pieChart.DataLabel.ShowLeaderLines = true;
- pieChart.Legend.Remove();
-
- //Resort on Count and add the rows
- lst.Sort((first,second) => first.Count < second.Count ? -1 : first.Count > second.Count ? 1 : 0);
- row=AddStatRows(ws, lst, 16, "", "Count");
-
- //Add the Doughnut chart
- var doughtnutChart = ws.Drawings.AddChart("crtExtensionCount", eChartType.DoughnutExploded) as ExcelDoughnutChart;
- //Set position to row 1 column 7 and 16 pixels offset
- doughtnutChart.SetPosition(1, 0, 8, 16);
- doughtnutChart.SetSize(400, 400);
- doughtnutChart.Series.Add(ExcelRange.GetAddress(16, 2, row - 1, 2), ExcelRange.GetAddress(16, 1, row - 1, 1));
-
- doughtnutChart.Title.Text = "Extension Count";
- doughtnutChart.DataLabel.ShowPercent = true;
- doughtnutChart.DataLabel.ShowLeaderLines = true;
- doughtnutChart.Style = eChartStyle.Style26; //3D look
- //Top-10 filesize
- _fileSize.Sort();
- row=AddStatRows(ws, _fileSize, 29, "Files", "Size");
- var barChart = ws.Drawings.AddChart("crtFiles", eChartType.BarClustered3D) as ExcelBarChart;
- //3d Settings
- barChart.View3D.RotX = 0;
- barChart.View3D.Perspective = 0;
-
- barChart.SetPosition(22, 0, 2, 0);
- barChart.SetSize(800, 398);
- barChart.Series.Add(ExcelRange.GetAddress(30, 2, row - 1, 2), ExcelRange.GetAddress(30, 1, row - 1, 1));
- //barChart.Series[0].Header = "Size";
- barChart.Title.Text = "Top File size";
-
- //Format the Size and Count column
- ws.Cells["B3:B42"].Style.Numberformat.Format = "#,##0";
- //Set a border around
- ws.Cells["A1:A43"].Style.Border.Left.Style = ExcelBorderStyle.Thin;
- ws.Cells["A1:O1"].Style.Border.Top.Style = ExcelBorderStyle.Thin;
- ws.Cells["O1:O43"].Style.Border.Right.Style = ExcelBorderStyle.Thin;
- ws.Cells["A43:O43"].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
- ws.Cells[1, 1, row, 2].AutoFitColumns(1);
-
- //And last the printersettings
- ws.PrinterSettings.Orientation = eOrientation.Landscape;
- ws.PrinterSettings.FitToPage = true;
- ws.PrinterSettings.Scale = 67;
- }
- /// <summary>
- /// Add statistic-rows to the statistics sheet.
- /// </summary>
- /// <param name="ws">Worksheet</param>
- /// <param name="lst">List with statistics</param>
- /// <param name="startRow"></param>
- /// <param name="header">Header text</param>
- /// <param name="propertyName">Size or Count</param>
- /// <returns></returns>
- private static int AddStatRows(ExcelWorksheet ws, List<StatItem> lst, int startRow, string header, string propertyName)
- {
- //Add Headers
- int row = startRow;
- if (header != "")
- {
- ws.Cells[row, 1].Value = header;
- using (ExcelRange r = ws.Cells[row, 1, row, 2])
- {
- r.Merge = true;
- r.Style.Font.SetFromFont(new Font("Arial", 16, FontStyle.Italic));
- r.Style.Font.Color.SetColor(Color.White);
- r.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.CenterContinuous;
- r.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
- r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79 , 129, 189));
- }
- row++;
- }
-
- int tblStart=row;
- //Header 2
- ws.Cells[row, 1].Value = "Name";
- ws.Cells[row, 2].Value = propertyName;
- using (ExcelRange r = ws.Cells[row, 1, row, 2])
- {
- r.Style.Font.SetFromFont(new Font("Arial", 12, FontStyle.Bold));
- }
-
- row++;
- //Add top 10 rows
- for (int i = 0; i < 10; i++)
- {
- if (lst.Count - i > 0)
- {
- ws.Cells[row, 1].Value = lst[lst.Count - i - 1].Name;
- if (propertyName == "Size")
- {
- ws.Cells[row, 2].Value = lst[lst.Count - i - 1].Size;
- }
- else
- {
- ws.Cells[row, 2].Value = lst[lst.Count - i - 1].Count;
- }
-
- row++;
- }
- }
-
- //If we have more than 10 items, sum...
- long rest = 0;
- for (int i = 0; i < lst.Count - 10; i++)
- {
- if (propertyName == "Size")
- {
- rest += lst[i].Size;
- }
- else
- {
- rest += lst[i].Count;
- }
- }
- //... and add anothers row
- if (rest > 0)
- {
- ws.Cells[row, 1].Value = "Others";
- ws.Cells[row, 2].Value = rest;
- ws.Cells[row, 1, row, 2].Style.Fill.PatternType = ExcelFillStyle.Solid;
- ws.Cells[row, 1, row, 2].Style.Fill.BackgroundColor.SetColor(Color.LightGray);
- row++;
- }
-
- var tbl = ws.Tables.Add(ws.Cells[tblStart, 1, row - 1, 2], null);
- tbl.TableStyle = TableStyles.Medium16;
- tbl.ShowTotal = true;
- tbl.Columns[1].TotalsRowFunction = RowFunctions.Sum;
- return row;
- }
- /// <summary>
- /// Just alters the colors in the list
- /// </summary>
- /// <param name="ws">The worksheet</param>
- /// <param name="row">Startrow</param>
- private static void AlterColor(ExcelWorksheet ws, int row)
- {
- using (ExcelRange rowRange = ws.Cells[row, 1, row, 2])
- {
- rowRange.Style.Fill.PatternType = ExcelFillStyle.Solid;
- if(row % 2==1)
- {
- rowRange.Style.Fill.BackgroundColor.SetColor(Color.LightGray);
- }
- else
- {
- rowRange.Style.Fill.BackgroundColor.SetColor(Color.LightYellow);
- }
- }
- }
-
- private static int AddDirectory(ExcelWorksheet ws, DirectoryInfo dir, int row, double height, int level, bool skipIcons)
- {
- //Get the icon as a bitmap
- Console.WriteLine("Directory " + dir.Name);
- if (!skipIcons)
- {
- Bitmap icon = GetIcon(dir.FullName);
-
- ws.Row(row).Height = height;
- //Add the icon as a picture
- if (icon != null)
- {
- ExcelPicture pic = ws.Drawings.AddPicture("pic" + (row).ToString(), icon);
- pic.SetPosition((int)20 * (row - 1) + 2, 0);
- }
- }
- ws.Cells[row, 2].Value = dir.Name;
- ws.Cells[row, 4].Value = dir.CreationTime;
- ws.Cells[row, 5].Value = dir.LastAccessTime;
-
- ws.Cells[row, 2, row, 5].Style.Font.Bold = true;
- //Sets the outline depth
- ws.Row(row).OutlineLevel = level;
-
- int prevRow = row;
- row++;
- //Add subdirectories
- foreach (DirectoryInfo subDir in dir.GetDirectories())
- {
- if (level < _maxLevels)
- {
- row = AddDirectory(ws, subDir, row, height, level + 1, skipIcons);
- }
- }
-
- //Add files in the directory
- foreach (FileInfo file in dir.GetFiles())
- {
- if (!skipIcons)
- {
- Bitmap fileIcon = GetIcon(file.FullName);
-
- ws.Row(row).Height = height;
- if (fileIcon != null)
- {
- ExcelPicture pic = ws.Drawings.AddPicture("pic" + (row).ToString(), fileIcon);
- pic.SetPosition((int)20 * (row - 1) + 2, 0);
- }
- }
-
- ws.Cells[row, 2].Value = file.Name;
- ws.Cells[row, 3].Value = file.Length;
- ws.Cells[row, 4].Value = file.CreationTime;
- ws.Cells[row, 5].Value = file.LastAccessTime;
-
- ws.Row(row).OutlineLevel = level+1;
-
- AddStatistics(file);
-
- row++;
- }
-
- //Add a subtotal for the directory
- if (row -1 > prevRow)
- {
- ws.Cells[prevRow, 3].Formula = string.Format("SUBTOTAL(9, {0})", ExcelCellBase.GetAddress(prevRow + 1, 3, row - 1, 3));
- }
- else
- {
- ws.Cells[prevRow, 3].Value = 0;
- }
-
- return row;
- }
- /// <summary>
- /// Add statistics to the collections
- /// </summary>
- /// <param name="file"></param>
- private static void AddStatistics(FileInfo file)
- {
- //Extension
- if (_extStat.ContainsKey(file.Extension))
- {
- _extStat[file.Extension].Count++;
- _extStat[file.Extension].Size+=file.Length;
- }
- else
- {
- string ext = file.Extension.Length > 0 ? file.Extension.Remove(0, 1) : "";
- _extStat.Add(file.Extension, new StatItem() { Name = ext, Count = 1, Size = file.Length });
- }
-
- //File top 10;
- if (_fileSize.Count < 10)
- {
- _fileSize.Add(new StatItem { Name = file.Name, Size = file.Length });
- if (_fileSize.Count == 10)
- {
- _fileSize.Sort();
- }
- }
- else if(_fileSize[0].Size < file.Length)
- {
- _fileSize.RemoveAt(0);
- _fileSize.Add(new StatItem { Name = file.Name, Size = file.Length });
- _fileSize.Sort();
- }
- }
- /// <summary>
- /// Gets the icon for a file or directory
- /// </summary>
- /// <param name="FileName"></param>
- /// <returns></returns>
- private static Bitmap GetIcon(string FileName)
- {
- try
- {
- SHFILEINFO shinfo = new SHFILEINFO();
-
- var ret = SHGetFileInfo(FileName,
- 0,
- ref shinfo,
- (uint)Marshal.SizeOf(shinfo),
- SHGFI_ICON | SHGFI_SMALLICON);
-
- if (shinfo.hIcon == IntPtr.Zero) return null;
-
- Bitmap bmp = Icon.FromHandle(shinfo.hIcon).ToBitmap();
- DestroyIcon(shinfo.hIcon);
-
- //Fix transparant color
- Color InvalidColor = Color.FromArgb(0, 0, 0, 0);
- for (int w = 0; w < bmp.PhysicalDimension.Width; w++)
- {
- for (int h = 0; h < bmp.PhysicalDimension.Height; h++)
- {
- if (bmp.GetPixel(w, h) == InvalidColor)
- {
- bmp.SetPixel(w, h, Color.Transparent);
- }
- }
- }
-
- return bmp;
- }
- catch
- {
- return null;
- }
- }
- }
-}
diff --git a/SampleApp/Sample7.cs b/SampleApp/Sample7.cs
deleted file mode 100644
index bb2ffad..0000000
--- a/SampleApp/Sample7.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using OfficeOpenXml.Style;
-using System.Drawing;
-namespace EPPlusSamples
-{
- class Sample7
- {
- /// <summary>
- /// This sample load a number of rows, style them and insert a row at the top.
- /// A password is set to protect locked cells. Column 3 & 4 will be editable, the rest will be locked.
- /// </summary>
- /// <param name="outputDir"></param>
- /// <param name="Rows"></param>
- public static string RunSample7(DirectoryInfo outputDir, int Rows)
- {
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample7.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sample7.xlsx");
- }
-
- using (ExcelPackage package = new ExcelPackage())
- {
- Console.WriteLine("{0:HH.mm.ss}\tStarting...", DateTime.Now);
-
- //Load the sheet with one string column, one date column and a few random numbers.
- var ws = package.Workbook.Worksheets.Add("Performance Test");
-
- //Format all cells
- ExcelRange cols = ws.Cells["A:XFD"];
- cols.Style.Fill.PatternType = ExcelFillStyle.Solid;
- cols.Style.Fill.BackgroundColor.SetColor(Color.LightGray);
-
- var rnd = new Random();
- for (int row = 1; row <= Rows; row++)
- {
- ws.SetValue(row, 1, row); //The SetValue method is a little bit faster than using the Value property
- ws.SetValue(row, 2, string.Format("Row {0}", row));
- ws.SetValue(row, 3, DateTime.Today.AddDays(row));
- ws.SetValue(row, 4, rnd.NextDouble() * 10000);
- if (row % 10000 == 0)
- {
- Console.WriteLine("{0:HH.mm.ss}\tWriting row {1}...", DateTime.Now, row);
- }
- }
- ws.Cells[1, 5, Rows, 5].FormulaR1C1 = "RC[-4]+RC[-1]";
-
- //Add a sum at the end
- ws.Cells[Rows + 1, 5].Formula = string.Format("Sum({0})", new ExcelAddress(1, 5, Rows, 5).Address);
- ws.Cells[Rows + 1, 5].Style.Font.Bold = true;
- ws.Cells[Rows + 1, 5].Style.Numberformat.Format = "#,##0.00";
-
- Console.WriteLine("{0:HH.mm.ss}\tWriting row {1}...", DateTime.Now, Rows);
- Console.WriteLine("{0:HH.mm.ss}\tFormatting...", DateTime.Now);
- //Format the date and numeric columns
- ws.Cells[1, 1, Rows, 1].Style.Numberformat.Format = "#,##0";
- ws.Cells[1, 3, Rows, 3].Style.Numberformat.Format = "YYYY-MM-DD";
- ws.Cells[1, 4, Rows, 5].Style.Numberformat.Format = "#,##0.00";
-
- Console.WriteLine("{0:HH.mm.ss}\tInsert a row at the top...", DateTime.Now);
- //Insert a row at the top. Note that the formula-addresses are shifted down
- ws.InsertRow(1, 1);
-
- //Write the headers and style them
- ws.Cells["A1"].Value = "Index";
- ws.Cells["B1"].Value = "Text";
- ws.Cells["C1"].Value = "Date";
- ws.Cells["D1"].Value = "Number";
- ws.Cells["E1"].Value = "Formula";
- ws.View.FreezePanes(2, 1);
-
- using (var rng = ws.Cells["A1:E1"])
- {
- rng.Style.Font.Bold = true;
- rng.Style.Font.Color.SetColor(Color.White);
- rng.Style.WrapText = true;
- rng.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
- rng.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
- rng.Style.Fill.PatternType = ExcelFillStyle.Solid;
- rng.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
- }
-
- //Calculate (Commented away thisk, it was a bit time consuming... /MA)
- // Console.WriteLine("{0:HH.mm.ss}\tCalculate formulas...", DateTime.Now);
- // ws.Calculate();
-
- Console.WriteLine("{0:HH.mm.ss}\tAutofit columns and lock and format cells...", DateTime.Now);
- ws.Cells[Rows - 100, 1, Rows, 5].AutoFitColumns(5); //Auto fit using the last 100 rows with minimum width 5
- ws.Column(5).Width = 15; //We need to set the width for column F manually since the end sum formula is the widest cell in the column (EPPlus don't calculate any forumlas, so no output text is avalible).
-
- //Now we set the sheetprotection and a password.
- ws.Cells[2, 3, Rows + 1, 4].Style.Locked = false;
- ws.Cells[2, 3, Rows + 1, 4].Style.Fill.PatternType = ExcelFillStyle.Solid;
- ws.Cells[2, 3, Rows + 1, 4].Style.Fill.BackgroundColor.SetColor(Color.White);
- ws.Cells[1, 5, Rows + 2, 5].Style.Hidden = true; //Hide the formula
-
- ws.Protection.SetPassword("EPPlus");
-
- ws.Select("C2");
- Console.WriteLine("{0:HH.mm.ss}\tSaving...", DateTime.Now);
- package.Compression = CompressionLevel.BestSpeed;
- package.SaveAs(newFile);
- }
- Console.WriteLine("{0:HH.mm.ss}\tDone!!", DateTime.Now);
- return newFile.FullName;
- }
- }
-}
diff --git a/SampleApp/Sample8.cs b/SampleApp/Sample8.cs
deleted file mode 100644
index e898922..0000000
--- a/SampleApp/Sample8.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 21 Mar 2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using OfficeOpenXml;
-using System.Xml;
-using System.Drawing;
-using OfficeOpenXml.Style;
-using System.Linq;
-namespace EPPlusSamples
-{
- public static class LinqSample
- {
- /// <summary>
- /// This sample shows how to use Linq with the Cells collection
- /// </summary>
- /// <param name="outputDir">The path where sample7.xlsx is</param>
- public static void RunLinqSample(DirectoryInfo outputDir)
- {
- Console.WriteLine("Now open sample 7 again and perform some Linq queries...");
- Console.WriteLine();
-
- FileInfo existingFile = new FileInfo(outputDir.FullName + @"\sample7.xlsx");
- using (ExcelPackage package = new ExcelPackage(existingFile))
- {
- ExcelWorksheet sheet = package.Workbook.Worksheets[1];
-
- //Select all cells in column d between 9990 and 10000
- var query1= (from cell in sheet.Cells["d:d"] where cell.Value is double && (double)cell.Value >= 9990 && (double)cell.Value <= 10000 select cell);
-
- Console.WriteLine("Print all cells with value between 9990 and 10000 in column D ...");
- Console.WriteLine();
-
- int count = 0;
- foreach (var cell in query1)
- {
- Console.WriteLine("Cell {0} has value {1:N0}", cell.Address, cell.Value);
- count++;
- }
-
- Console.WriteLine("{0} cells found ...",count);
- Console.WriteLine();
-
- //Select all bold cells
- Console.WriteLine("Now get all bold cells from the entire sheet...");
- var query2 = (from cell in sheet.Cells[sheet.Dimension.Address] where cell.Style.Font.Bold select cell);
- //If you have a clue where the data is, specify a smaller range in the cells indexer to get better performance (for example "1:1,65536:65536" here)
- count = 0;
- foreach (var cell in query2)
- {
- if (!string.IsNullOrEmpty(cell.Formula))
- {
- Console.WriteLine("Cell {0} is bold and has a formula of {1:N0}", cell.Address, cell.Formula);
- }
- else
- {
- Console.WriteLine("Cell {0} is bold and has a value of {1:N0}", cell.Address, cell.Value);
- }
- count++;
- }
-
- //Here we use more than one column in the where clause. We start by searching column D, then use the Offset method to check the value of column C.
- var query3 = (from cell in sheet.Cells["d:d"]
- where cell.Value is double &&
- (double)cell.Value >= 9500 && (double)cell.Value <= 10000 &&
- cell.Offset(0, -1).GetValue<DateTime>().Year == DateTime.Today.Year+1
- select cell);
-
- Console.WriteLine();
- Console.WriteLine("Print all cells with a value between 9500 and 10000 in column D and the year of Column C is {0} ...", DateTime.Today.Year + 1);
- Console.WriteLine();
-
- count = 0;
- foreach (var cell in query3) //The cells returned here will all be in column D, since that is the address in the indexer. Use the Offset method to print any other cells from the same row.
- {
- Console.WriteLine("Cell {0} has value {1:N0} Date is {2:d}", cell.Address, cell.Value, cell.Offset(0, -1).GetValue<DateTime>());
- count++;
- }
- }
- }
- }
-}
diff --git a/SampleApp/Sample9.cs b/SampleApp/Sample9.cs
deleted file mode 100644
index 2ccc5ca..0000000
--- a/SampleApp/Sample9.cs
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 28 Oct 2010
- *******************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using OfficeOpenXml;
-using System.IO;
-using OfficeOpenXml.Table;
-using OfficeOpenXml.Drawing.Chart;
-using System.Globalization;
-namespace EPPlusSamples
-{
- /// <summary>
- /// This sample shows how to load CSV files using the LoadFromText method, how to use tables and
- /// how to use charts with more than one charttype and secondary axis
- /// </summary>
- public static class Sample9
- {
- /// <summary>
- /// Loads two CSV files into tables and adds a chart to each sheet.
- /// </summary>
- /// <param name="outputDir"></param>
- /// <returns></returns>
- public static string RunSample9(DirectoryInfo outputDir)
- {
- FileInfo newFile = new FileInfo(outputDir.FullName + @"\sample9.xlsx");
- if (newFile.Exists)
- {
- newFile.Delete(); // ensures we create a new workbook
- newFile = new FileInfo(outputDir.FullName + @"\sample9.xlsx");
- }
-
- using (ExcelPackage package = new ExcelPackage())
- {
- LoadFile1(package);
- LoadFile2(package);
-
- package.SaveAs(newFile);
- }
- return newFile.FullName;
- }
- private static void LoadFile1(ExcelPackage package)
- {
- //Create the Worksheet
- var sheet = package.Workbook.Worksheets.Add("Csv1");
-
- //Create the format object to describe the text file
- var format = new ExcelTextFormat();
- format.TextQualifier = '"';
- format.SkipLinesBeginning = 2;
- format.SkipLinesEnd = 1;
-
- //Now read the file into the sheet. Start from cell A1. Create a table with style 27. First row contains the header.
- Console.WriteLine("Load the text file...");
- var range = sheet.Cells["A1"].LoadFromText(new FileInfo("..\\..\\csv\\Sample9-1.txt"), format, TableStyles.Medium27, true);
-
- Console.WriteLine("Format the table...");
- //Tables don't support custom styling at this stage(you can of course format the cells), but we can create a Namedstyle for a column...
- var dateStyle = package.Workbook.Styles.CreateNamedStyle("TableDate");
- dateStyle.Style.Numberformat.Format = "YYYY-MM";
-
- var numStyle = package.Workbook.Styles.CreateNamedStyle("TableNumber");
- numStyle.Style.Numberformat.Format = "#,##0.0";
-
- //Now format the table...
- var tbl = sheet.Tables[0];
- tbl.ShowTotal = true;
- tbl.Columns[0].TotalsRowLabel = "Total";
- tbl.Columns[0].DataCellStyleName = "TableDate";
- tbl.Columns[1].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[1].DataCellStyleName = "TableNumber";
- tbl.Columns[2].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[2].DataCellStyleName = "TableNumber";
- tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[3].DataCellStyleName = "TableNumber";
- tbl.Columns[4].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[4].DataCellStyleName = "TableNumber";
- tbl.Columns[5].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[5].DataCellStyleName = "TableNumber";
- tbl.Columns[6].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[6].DataCellStyleName = "TableNumber";
-
- Console.WriteLine("Create the chart...");
- //Now add a stacked areachart...
- var chart = sheet.Drawings.AddChart("chart1", eChartType.AreaStacked);
- chart.SetPosition(0, 630);
- chart.SetSize(800, 600);
-
- //Create one series for each column...
- for (int col = 1; col < 7; col++)
- {
- var ser = chart.Series.Add(range.Offset(1, col, range.End.Row - 1, 1), range.Offset(1, 0, range.End.Row - 1, 1));
- ser.HeaderAddress = range.Offset(0, col, 1, 1);
- }
-
- //Set the style to 27.
- chart.Style = eChartStyle.Style27;
-
- sheet.View.ShowGridLines = false;
- sheet.Calculate();
- sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
- }
-
- private static void LoadFile2(ExcelPackage package)
- {
- //Create the Worksheet
- var sheet = package.Workbook.Worksheets.Add("Csv2");
-
- //Create the format object to describe the text file
- var format = new ExcelTextFormat();
- format.Delimiter='\t'; //Tab
- format.SkipLinesBeginning = 1;
- CultureInfo ci = new CultureInfo("sv-SE"); //Use your choice of Culture
- ci.NumberFormat.NumberDecimalSeparator = ","; //Decimal is comma
- format.Culture = ci;
-
- //Now read the file into the sheet.
- Console.WriteLine("Load the text file...");
- var range = sheet.Cells["A1"].LoadFromText(new FileInfo("..\\..\\csv\\Sample9-2.txt"), format);
-
- //Add a formula
- range.Offset(1, range.End.Column, range.End.Row - range.Start.Row, 1).FormulaR1C1 = "RC[-1]-RC[-2]";
-
- //Add a table...
- var tbl = sheet.Tables.Add(range.Offset(0,0,range.End.Row-range.Start.Row+1, range.End.Column-range.Start.Column+2),"Table");
- tbl.ShowTotal = true;
- tbl.Columns[0].TotalsRowLabel = "Total";
- tbl.Columns[1].TotalsRowFormula = "COUNT(3,Table[Product])"; //Add a custom formula
- tbl.Columns[2].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[4].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[5].TotalsRowFunction = RowFunctions.Sum;
- tbl.Columns[5].Name = "Profit";
- tbl.TableStyle = TableStyles.Medium10;
-
- sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
-
- //Add a chart with two charttypes (Column and Line) and a secondary axis...
- var chart = sheet.Drawings.AddChart("chart2", eChartType.ColumnStacked);
- chart.SetPosition(0, 540);
- chart.SetSize(800, 600);
-
- var serie1= chart.Series.Add(range.Offset(1, 3, range.End.Row - 1, 1), range.Offset(1, 1, range.End.Row - 1, 1));
- serie1.Header = "Purchase Price";
- var serie2 = chart.Series.Add(range.Offset(1, 5, range.End.Row - 1, 1), range.Offset(1, 1, range.End.Row - 1, 1));
- serie2.Header = "Profit";
-
- //Add a Line series
- var chartType2 = chart.PlotArea.ChartTypes.Add(eChartType.LineStacked);
- chartType2.UseSecondaryAxis = true;
- var serie3 = chartType2.Series.Add(range.Offset(1, 2, range.End.Row - 1, 1), range.Offset(1, 0, range.End.Row - 1, 1));
- serie3.Header = "Items in stock";
-
- //By default the secondary XAxis is not visible, but we want to show it...
- chartType2.XAxis.Deleted = false;
- chartType2.XAxis.TickLabelPosition = eTickLabelPosition.High;
-
- //Set the max value for the Y axis...
- chartType2.YAxis.MaxValue = 50;
-
- chart.Style = eChartStyle.Style26;
- sheet.View.ShowGridLines = false;
- sheet.Calculate();
- }
- }
-}
diff --git a/SampleApp/Sample_AddFormulaFunction.cs b/SampleApp/Sample_AddFormulaFunction.cs
deleted file mode 100644
index 112e30e..0000000
--- a/SampleApp/Sample_AddFormulaFunction.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using OfficeOpenXml;
-using OfficeOpenXml.FormulaParsing;
-using OfficeOpenXml.FormulaParsing.Excel.Functions;
-using OfficeOpenXml.FormulaParsing.ExpressionGraph;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
-
-namespace EPPlusSamples
-{
- /// <summary>
- /// This sample shows how to add functions to the FormulaParser of EPPlus.
- ///
- /// For further details on how to build functions, have a look in the EPPlus.FormulaParsing.Excel.Functions namespace
- /// </summary>
- class Sample_AddFormulaFunction
- {
- public static void RunSample_AddFormulaFunction()
- {
- using (var package = new ExcelPackage(new MemoryStream()))
- {
- // add your function module to the parser
- package.Workbook.FormulaParserManager.LoadFunctionModule(new MyFunctionModule());
-
- // Note that if you dont want to write a module, you can also
- // add new functions to the parser this way:
- // package.Workbook.FormulaParserManager.AddOrReplaceFunction("sum.addtwo", new SumAddTwo());-
- // package.Workbook.FormulaParserManager.AddOrReplaceFunction("seanconneryfy", new SeanConneryfy());
-
-
- //Override the buildin Text function to handle swedish date formatting strings. Excel has localized date format strings with is now supported by EPPlus.
- package.Workbook.FormulaParserManager.AddOrReplaceFunction("text", new TextSwedish());
-
- // add a worksheet with some dummy data
- var ws = package.Workbook.Worksheets.Add("Test");
- ws.Cells["A1"].Value = 1;
- ws.Cells["A2"].Value = 2;
- ws.Cells["P3"].Formula = "SUM(A1:A2)";
- ws.Cells["B1"].Value = "Hello";
- ws.Cells["C1"].Value = new DateTime(2013,12,31);
- ws.Cells["C2"].Formula="Text(C1,\"åååå-MM-dd\")"; //Swedish formatting
- // use the added "sum.addtwo" function
- ws.Cells["A4"].Formula = "SUM.ADDTWO(A1:A2,P3)";
- // use the other function "seanconneryfy"
- ws.Cells["B2"].Formula = "seanconneryfy(B1)";
-
- // calculate
- ws.Calculate();
-
- // show result
- Console.WriteLine("sum.addtwo(A1:A2,P3) evaluated to {0}", ws.Cells["A4"].Value);
- Console.WriteLine("seanconneryfy(B1) evaluated to {0}", ws.Cells["B2"].Value);
- }
- }
- }
-
- class MyFunctionModule : IFunctionModule
- {
- public MyFunctionModule()
- {
- Functions = new Dictionary<string, ExcelFunction>()
- {
- {"sum.addtwo", new SumAddTwo()},
- {"seanconneryfy", new SeanConneryfy()}
- };
- }
-
- public IDictionary<string, ExcelFunction> Functions { get; private set; }
- }
-
- /// <summary>
- /// A really unnecessary function. Adds two to all numbers in the supplied range and calculates the sum.
- /// </summary>
- class SumAddTwo : ExcelFunction
- {
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- // Sanity check, will set excel VALUE error if min length is not met
- ValidateArguments(arguments, 1);
-
- // Helper method that converts function arguments to an enumerable of doubles
- var numbers = ArgsToDoubleEnumerable(arguments, context);
-
- // Do the work
- var result = 0d;
- numbers.ToList().ForEach(x => result += (x + 2));
-
- // return the result
- return CreateResult(result, DataType.Decimal);
- }
- }
- /// <summary>
- /// This function handles Swedish formatting strings.
- /// </summary>
- class TextSwedish : ExcelFunction
- {
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- // Sanity check, will set excel VALUE error if min length is not met
- ValidateArguments(arguments, 2);
-
- //Replace swedish year format with invariant for parameter 2.
- var format = arguments.ElementAt(1).Value.ToString().Replace("åååå", "yyyy");
- var newArgs = new List<FunctionArgument> { arguments.ElementAt(0) };
- newArgs.Add(new FunctionArgument(format));
-
- //Use the build-in Text function.
- var func = new Text();
- return func.Execute(newArgs, context);
- }
- }
-
- /// <summary>
- /// An even more unnecessary function, inspired by the Sean Connery keyboard;) Will add 'sh' at the end of the supplied string.
- /// </summary>
- class SeanConneryfy : ExcelFunction
- {
- public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
- {
- // Sanity check, will set excel VALUE error if min length is not met
- ValidateArguments(arguments, 1);
- // Get the first arg
- var input = ArgToString(arguments, 0);
-
- // return the result
- return CreateResult(input + "sh", DataType.String);
- }
- }
-}
diff --git a/SampleApp/Sample_FormulaCalc.cs b/SampleApp/Sample_FormulaCalc.cs
deleted file mode 100644
index 73ad33c..0000000
--- a/SampleApp/Sample_FormulaCalc.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using OfficeOpenXml;
-
-namespace EPPlusSamples
-{
- class Sample_FormulaCalc
- {
- public static void RunSampleFormulaCalc()
- {
- using (var package = new ExcelPackage(new MemoryStream()))
- {
- var ws1 = package.Workbook.Worksheets.Add("ws1");
- // Add some values to sum
- ws1.Cells["A1"].Formula = "(2*2)/2";
- ws1.Cells["A2"].Value = 4;
- ws1.Cells["A3"].Value = 6;
- ws1.Cells["A4"].Formula = "SUM(A1:A3)";
-
- // calculate all formulas on the worksheet
- ws1.Calculate();
-
- // Print the calculated value
- Console.WriteLine("SUM(A1:A3) evaluated to {0}", ws1.Cells["A4"].Value);
-
- // Add another worksheet
- var ws2 = package.Workbook.Worksheets.Add("ws2");
- ws2.Cells["A1"].Value = 3;
- ws2.Cells["A2"].Formula = "SUM(A1,ws1!A4)";
-
- // calculate all formulas in the entire workbook
- package.Workbook.Calculate();
-
- // Print the calculated value
- Console.WriteLine("SUM(A1,ws1!A4) evaluated to {0}", ws2.Cells["A2"].Value);
-
- // Calculate a range
- ws1.Cells["B1"].Formula = "IF(TODAY()<DATE(2014,6,1),\"BEFORE\" &\" FIRST\",CONCATENATE(\"FIRST\",\" OF\",\" JUNE 2014 OR LATER\"))";
- ws1.Cells["B1"].Calculate();
-
- // Print the calculated value
- Console.WriteLine("IF(TODAY()<DATE(2014,6,1),\"BEFORE\" &\" FIRST\",CONCATENATE(\"FIRST\",\" OF\",\" JUNE 2014 OR LATER\")) evaluated to {0}", ws1.Cells["B1"].Value);
-
- // Evaluate a formula string (without calculate depending cells).
- // That means that if A1 contains a formula that hasn't been calculated it take the value from a1, blank or zero if it's a new formula.
- // In this case A1 has been calculated (2), so everything should be ok!
- const string formula = "(2+4)*ws1!A1";
- var result = package.Workbook.FormulaParserManager.Parse(formula);
-
- // Print the calculated value
- Console.WriteLine("(2+4)*ws1!A2 evaluated to {0}", result);
-
- // Evaluate a formula string (Calculate depending cells)
- // A1 will be recalculated.
- var result2 = ws1.Calculate("(2+4)*A1");
-
- }
- }
- }
-}
diff --git a/SampleApp/Sample_Main.cs b/SampleApp/Sample_Main.cs
deleted file mode 100644
index 0c3ebf8..0000000
--- a/SampleApp/Sample_Main.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * You may amend and distribute as you like, but don't remove this header!
- *
- * All rights reserved.
- *
- * EPPlus is an Open Source project provided under the
- * GNU General Public License (GPL) as published by the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * EPPlus provides server-side generation of Excel 2007 spreadsheets.
- * See http://www.codeplex.com/EPPlus for details.
- *
- *
- *
- * The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
- * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
- *
- * The code for this project may be used and redistributed by any means PROVIDING it is
- * not sold for profit without the author's written consent, and providing that this notice
- * and the author's name and all copyright notices remain intact.
- *
- * All code and executables are provided "as is" with no warranty either express or implied.
- * The author accepts no liability for any damage or loss of business that this product may cause.
- *
- *
- * Code change notes:
- *
- * Author Change Date
- *******************************************************************************
- * Jan Källman Added 10-SEP-2009
- *******************************************************************************/
-using System;
-using System.IO;
-using OfficeOpenXml;
-
-namespace EPPlusSamples
-{
- class Sample_Main
- {
- static void Main(string[] args)
- {
- try
- {
- //Sample 3, 4 and 12 uses the Adventureworks database. Enter then name of your SQL server into the variable below...
- //Leave this blank if you don't have access to the Adventureworks database
- string SqlServerName = "";
-
- // change this line to contain the path to the output folder
- DirectoryInfo outputDir = new DirectoryInfo(@"c:\temp\SampleApp");
- if (!outputDir.Exists) throw new Exception("outputDir does not exist!");
-
- // Sample 1 - simply creates a new workbook from scratch
- // containing a worksheet that adds a few numbers together
- Console.WriteLine("Running sample 1");
- string output = Sample1.RunSample1(outputDir);
- Console.WriteLine("Sample 1 created: {0}", output);
- Console.WriteLine();
-
- // Sample 2 - simply reads some values from the file generated by sample 1
- // and outputs them to the console
- Console.WriteLine("Running sample 2");
- Sample2.RunSample2(output);
- Console.WriteLine();
- output = "";
-
- if (SqlServerName != "")
- {
- string connectionStr = string.Format(@"server={0};database=AdventureWorks;Integrated Security=true;", SqlServerName);
- // Sample 3 - creates a workbook from scratch
- // This is the same sample as the original Excelpackage, sample 4, but without the template
- // This sample requires the AdventureWorks database.
- //Shows how to use Ranges, Styling, Namedstyles and Hyperlinks
- Console.WriteLine("Running sample 3");
- output = Sample3.RunSample3(outputDir, connectionStr);
- Console.WriteLine("Sample 3 created: {0}", output);
- Console.WriteLine();
-
- // Sample 4 - creates a workbook based on a template.
- // Populates a range with data and set the series of a linechart.
- // This sample requires the AdventureWorks database.
- Console.WriteLine("Running sample 4");
- output = Sample4.RunSample4(connectionStr, new FileInfo("..\\..\\GraphTemplate.xlsx"), outputDir); //Template path from /bin/debug or /bin/release
- Console.WriteLine("Sample 4 created: {0}", output);
- Console.WriteLine();
- }
-
- //Sample 5
- //Open sample 1 and add a pie chart.
- Console.WriteLine("Running sample 5");
- output = Sample5.RunSample5(outputDir);
- Console.WriteLine("Sample 5 created:", output);
- Console.WriteLine();
-
- //Sample 6
- //Creates an advanced report on a directory in the filesystem.
- //Parameter 2 is the directory to report. Paramter 3 is how deep the scan will go. Parameter 4 Skips Icons if set to true (The icon handling is slow)
- //This example demonstrates how to use outlines, tables,comments, shapes, pictures and charts.
- Console.WriteLine("Running sample 6");
- output = Sample6.RunSample6(outputDir, new DirectoryInfo("..\\.."), 5, false);
- Console.WriteLine("Sample 6 created:", output);
- Console.WriteLine();
-
- //Sample 7
- //This sample shows the performance capabilities of the component and shows sheet protection.
- //Load X(param 2) rows with five columns
- Console.WriteLine("Running sample 7");
- output = Sample7.RunSample7(outputDir, 65534);
- Console.WriteLine("Sample 7 created:", output);
- Console.WriteLine();
-
- //Sample 8 - Linq
- //Opens Sample 7 and perform some Linq queries
- Console.WriteLine("Running sample 8-Linq");
- LinqSample.RunLinqSample(outputDir);
- Console.WriteLine();
-
- //Sample 9 Loads two csv files into tables and creates an area chart and a Column/Line chart on the data.
- //This sample also shows how to use a secondary axis.
- Console.WriteLine("Running sample 9");
- output = Sample9.RunSample9(outputDir);
- Console.WriteLine("Sample 9 created: {0}", output);
- Console.WriteLine();
-
- //Sample 10 Swedish Quiz : Shows Encryption and workbook and sheet protection.
- Console.WriteLine("Running sample 10");
- Sample10.RunSample10(outputDir);
- Console.WriteLine("Sample 10 created: {0}", outputDir.FullName);
- Console.WriteLine();
-
- //Sample 11 - Data validation
- Console.WriteLine("Running sample 11");
- output = Sample11.RunSample11(outputDir);
- Console.WriteLine("Sample 11 created {0}", output);
- Console.WriteLine();
-
- //Sample 12 - Pivottables
- Console.WriteLine("Running sample 12");
- output = Sample12.RunSample12(SqlServerName, outputDir);
- Console.WriteLine("Sample 12 created {0}", output);
- Console.WriteLine();
-
- //Sample 13 - Shows a few ways to load data (Datatable, IEnumerable and more).
- Console.WriteLine("Running sample 13");
- Sample13.RunSample13(outputDir);
- Console.WriteLine("Sample 13 created {0}", outputDir.Name);
- Console.WriteLine();
-
- //Sample 14 - Conditional Formatting
- Console.WriteLine("Running sample 14");
- Sample14.RunSample14(outputDir);
- Console.WriteLine("Sample 14 created {0}", outputDir.Name);
- Console.WriteLine();
-
- //Sample 15 - Shows how to work with macro-enabled workbooks(VBA).
- Console.WriteLine("Running sample 15-VBA");
- Sample15.VBASample(outputDir);
- Console.WriteLine("Sample 15 created {0}", outputDir.Name);
- Console.WriteLine();
-
- //Sample FormulaCalc - Shows how to calculate formulas in the workbook.
- Console.WriteLine("Running Sample_FormulaCalc");
- Sample_FormulaCalc.RunSampleFormulaCalc();
- Console.WriteLine();
-
- //Sample AddFormulaFunction - Shows how to add your own implementations of excel functions to EPPlus.
- Console.WriteLine("Running Sample_AddFormulaFunction");
- Sample_AddFormulaFunction.RunSample_AddFormulaFunction();
- Console.WriteLine();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error: {0}", ex.Message);
- }
- Console.WriteLine();
- Console.WriteLine("Press the return key to exit...");
- Console.Read();
- }
- }
-}
diff --git a/SampleApp/VBA-Code/BattleshipSheet.txt b/SampleApp/VBA-Code/BattleshipSheet.txt
deleted file mode 100644
index 9c1aca5..0000000
--- a/SampleApp/VBA-Code/BattleshipSheet.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
- Dim sheet As Worksheet
- If g_gameEnded = True Then
- Exit Sub
- End If
-
- Set sheet = ThisWorkbook.ActiveSheet
- If g_Ships Is Nothing Then Code.AddShips Battleship.Range(board1)
- If Collide(Target, Battleship.Range(board1)) Then
- If Target.Borders(xlDiagonalUp).Weight <> xlMedium Then
- SetHit Target
- Dim Ship
- Dim isHit As Boolean
- isHit = False
- For Each Ship In g_Ships
- If Ship.isHit(Target.Cells(1, 1), True) Then
- If CheckWinner(g_Ships) Then
- MsgBox "You win!", vbOKOnly + vbExclamation, "Battleships"
- g_gameEnded = True
- Cancel = True
- Exit Sub
- End If
- isHit = True
- Exit For
- End If
- Next
- If isHit = False Then
- Unprotect
- Battleship.Cells(g_logRow, 2).value = "You get a miss on " & Target.Address
- Battleship.Names("PlayerMisses").RefersToRange.value = Battleship.Names("PlayerMisses").RefersToRange.value + 1
- g_logRow = g_logRow + 1
- Protect ""
- End If
- ComputerPlay.Move
-
- End If
- End If
- Cancel = True
-End Sub
-Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Target.Cells(1, 1).Select
-End Sub
diff --git a/SampleApp/VBA-Code/CodeModule.txt b/SampleApp/VBA-Code/CodeModule.txt
deleted file mode 100644
index a54de58..0000000
--- a/SampleApp/VBA-Code/CodeModule.txt
+++ /dev/null
@@ -1,154 +0,0 @@
-Public Const board1 = "{5}"
-Public Const board2 = "{6}"
-
-Public Const userShip1 = "{0}"
-Public Const userShip2 = "{1}"
-Public Const userShip3 = "{2}"
-Public Const userShip4 = "{3}"
-Public Const userShip5 = "{4}"
-
-Global g_logRow As Integer
-Global g_gameEnded As Boolean
-Global g_Ships As Collection
-Global g_userShips As Collection
-Public Function Collide(r1 As Range, r2 As Range) As Boolean
-If r1.row + r1.Rows.Count > r2.row And r1.row < r2.row + r2.Rows.Count And _
- r1.column + r1.Columns.Count > r2.column And r1.column < r2.column + r2.Columns.Count Then
- Collide = True
-Else
- Collide = False
-End If
-End Function
-Public Sub AddShips(board As Range)
- Set g_Ships = New Collection
-
- Dim s1 As New Ship
-
- s1.Size = 5
- Set s1.Position = GetShipPos(board, s1.Size)
- g_Ships.Add s1, "carrier"
-
- Dim s2 As New Ship
- s2.Size = 4
- Set s2.Position = GetShipPos(board, s2.Size)
- g_Ships.Add s2, "battleship"
-
- Dim s3 As New Ship
- s3.Size = 3
- Set s3.Position = GetShipPos(board, s3.Size)
- g_Ships.Add s3, "sub"
-
- Dim s4 As New Ship
- s4.Size = 3
- Set s4.Position = GetShipPos(board, s4.Size)
- g_Ships.Add s4, "cruiser"
-
- Dim s5 As New Ship
- s5.Size = 2
- Set s5.Position = GetShipPos(board, s5.Size)
- g_Ships.Add s5, "destroyer"
-End Sub
-Public Sub AddUserShips(board As Range)
- Set g_userShips = New Collection
-
- Dim s1 As New Ship
-
- s1.Size = 5
- Set s1.Position = Battleship.Range(userShip1)
- g_userShips.Add s1, "carrier"
-
- Dim s2 As New Ship
- s2.Size = 4
- Set s2.Position = Battleship.Range(userShip2)
- g_userShips.Add s2, "battleship"
-
- Dim s3 As New Ship
- s3.Size = 3
- Set s3.Position = Battleship.Range(userShip3)
- g_userShips.Add s3, "sub"
-
- Dim s4 As New Ship
- s4.Size = 3
- Set s4.Position = Battleship.Range(userShip4)
- g_userShips.Add s4, "cruiser"
-
- Dim s5 As New Ship
- s5.Size = 2
- Set s5.Position = Battleship.Range(userShip5)
- g_userShips.Add s5, "destroyer"
-End Sub
-Public Function GetShipPos(board As Range, ByVal Size As Integer) As Range
- Dim row As Integer, column As Integer
- Dim Horizontal As Integer
-
- Do
- Randomize
- row = (Rnd * (board.Rows.Count - 1)) + 1
- column = (Rnd * (board.Rows.Count - 1)) + 1
- Horizontal = Rnd
-
- If Horizontal = 1 Then
- If column - Size > 0 And column + Size < 10 Then
- If Rnd = 0 Then
- Set GetShipPos = board.Range(Cells(row, column), Cells(row, column + Size - 1))
- Else
- Set GetShipPos = board.Range(Cells(row, column - Size + 1), Cells(row, column))
- End If
- ElseIf column - Size > 0 Then
- Set GetShipPos = board.Range(Cells(row, column - Size + 1), Cells(row, column))
- Else
- Set GetShipPos = board.Range(Cells(row, column), Cells(row, column + Size - 1))
- End If
- Else
- If row - Size > 0 And row + Size < 10 Then
- If Rnd = 0 Then
- Set GetShipPos = board.Range(Cells(row, column), Cells(row + Size - 1, column))
- Else
- Set GetShipPos = board.Range(Cells(row - Size + 1, column), Cells(row, column))
- End If
- ElseIf row - Size > 0 Then
- Set GetShipPos = board.Range(Cells(row - Size + 1, column), Cells(row, column))
- Else
- Set GetShipPos = board.Range(Cells(row, column), Cells(row + Size - 1, column))
- End If
- End If
- Loop Until ValidSpot(GetShipPos)
-End Function
-'Make sure the spot isn't occupied
-Private Function ValidSpot(r As Range) As Boolean
- Dim oShip As Ship
- For Each oShip In g_Ships
- If Code.Collide(r, oShip.Position) Then
- ValidSpot = False
- Exit Function
- End If
- Next
- ValidSpot = True
-End Function
-
-Public Sub SetHit(Target As Range)
- Target.Worksheet.Unprotect
- With Target.Borders(xlDiagonalDown)
- .LineStyle = xlContinuous
- .Color = ColorConstants.vbBlack
- .TintAndShade = 0
- .Weight = xlMedium
- End With
- With Target.Borders(xlDiagonalUp)
- .LineStyle = xlContinuous
- .Color = ColorConstants.vbBlack
- .TintAndShade = 0
- .Weight = xlMedium
- End With
- Target.Worksheet.Protect ""
-End Sub
-Public Function CheckWinner(ships As Collection) As Boolean
- Dim oShip As Ship
- For Each oShip In ships
- If oShip.Hits.Count < oShip.Position.Cells.Count Then
- CheckWinner = False
- Exit Function
- End If
- Next
- CheckWinner = True
-End Function
diff --git a/SampleApp/VBA-Code/ComputerPlayModule.txt b/SampleApp/VBA-Code/ComputerPlayModule.txt
deleted file mode 100644
index 751fe05..0000000
--- a/SampleApp/VBA-Code/ComputerPlayModule.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-Dim possibleCells As Collection
-Dim Hits As Range
-Public Sub Init()
- Dim b As Range
- Dim col As Integer, row As Integer
-
- Set possibleCells = New Collection
- Set b = Battleship.Range(board2)
- For col = 1 To b.Columns.Count
- For row = 1 To b.Rows.Count
- possibleCells.Add (b.Cells(row, col).Address)
- Next
- Next
-End Sub
-Public Sub Move()
- Dim index As Integer
- index = -1
- Dim oShip As Ship
- Dim isHit As Boolean
- For Each oShip In g_userShips
- If oShip.Hits.Count > 0 And oShip.Hits.Count < oShip.Position.Cells.Count Then
- index = GetHit(oShip)
- Exit For
- End If
- Next
-
- If index < 0 Then
- index = (Rnd * (possibleCells.Count - 1)) + 1
- End If
- Dim cell As Range
- Set cell = Battleship.Range(possibleCells(index))
- isHit = False
- SetHit cell
- For Each oShip In g_userShips
- If oShip.isHit(cell, False) Then
- If CheckWinner(g_userShips) Then
- SetShipsVisible
- MsgBox "Computer wins!"
- Exit Sub
- End If
- isHit = True
- Exit For
- End If
- Next
-
- If IsHit = False Then
- Battleship.Unprotect
- Battleship.Cells(g_logRow, 2).value = "The Computer gets a miss on " & cell.Address
- Battleship.Names("ComputerMisses").RefersToRange.value = Battleship.Names("ComputerMisses").RefersToRange.value + 1
- g_logRow = g_logRow + 1
- Battleship.Protect ""
- End If
- possibleCells.Remove index
-End Sub
-
-Private Sub SetShipsVisible()
- Battleship.Unprotect
- Dim oShip As Ship
- For Each oShip In g_Ships
- Dim cell As Range
- For Each cell In oShip.Position.Cells
- If cell.Interior.Color <> ColorConstants.vbRed Then
- cell.Interior.Color = ColorConstants.vbBlack
- End If
- Next
- Next
- Battleship.Protect ""
-End Sub
-Private Function GetHit(oShip As Ship) As Integer
- Dim isHorizontal As Boolean
- If oShip.Hits.Count = 1 Then
- isHorizontal = Int((Rnd * 2)) = 1
- Else
- If oShip.Hits(1).row = oShip.Hits(2).row Then
- isHorizontal = True
- Else
- isHorizontal = False
- End If
- End If
-
- Dim index As Integer
- index = -1
- While index = -1
- If isHorizontal Then
- For Each Hit In oShip.Hits
- index = FindPossible(Hit.Offset(0, -1))
- If index = -1 Then
- index = FindPossible(Hit.Offset(0, 1))
- If index <> -1 Then
- Exit For
- End If
- Else
- Exit For
- End If
- Next
- If index = -1 Then
- isHorizontal = False
- End If
- Else
- For Each Hit In oShip.Hits
- index = FindPossible(Hit.Offset(-1, 0))
- If index = -1 Then
- index = FindPossible(Hit.Offset(1, 0))
- If index > -1 Then
- Exit For
- End If
- Else
- Exit For
- End If
- Next
- If index = -1 Then
- isHorizontal = True
- End If
- End If
- Wend
- GetHit = index
-End Function
-Private Function FindPossible(r As Range)
-Dim index As Integer
-Dim cell As Range
-For index = 1 To possibleCells.Count
- If possibleCells(index) = r.Address Then
- FindPossible = index
- Exit Function
- End If
-Next
-FindPossible = -1
-End Function
diff --git a/SampleApp/VBA-Code/ShipClass.txt b/SampleApp/VBA-Code/ShipClass.txt
deleted file mode 100644
index b311446..0000000
--- a/SampleApp/VBA-Code/ShipClass.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-Dim rPosition As Range
-Public HitCount As Integer
-Dim oSize As Integer
-Dim m_hits As Collection
-
-Public Property Get Position() As Range
- Set Position = rPosition
-End Property
-Public Property Set Position(ByVal value As Range)
- Set rPosition = value
-End Property
-
-Public Function IsHit(cell As Range, isPlayer As Boolean) As Boolean
-Attribute IsHit.VB_Description = "Checks if the current move is a hit"
-Attribute IsHit.VB_HelpID = 1
-'Sample of attribute use on function level (show up in the objectbrowser(F2) --> Method --> Properties
- If Code.Collide(cell, Position) Then
- cell.Worksheet.Unprotect
- cell.Interior.Color = vbRed
- isHit = True
- Hits.Add cell
- If Hits.Count = Size Then
- Position.BorderAround Weight:=xlMedium
- End If
-
- If isPlayer Then
- Battleship.Cells(g_logRow, 2).value = "You get a hit on " & cell.Address & "!"
- Battleship.Names("PlayerHits").RefersToRange.value = Battleship.Names("PlayerHits").RefersToRange.value + 1
- Else
- Battleship.Cells(g_logRow, 2).value = "The Computer gets a hit on " & cell.Address
- Battleship.Names("ComputerHits").RefersToRange.value = Battleship.Names("ComputerHits").RefersToRange.value + 1
- End If
- g_logRow = g_logRow + 1
- cell.Worksheet.Protect ""
- isHit = True
- Else
- isHit = False
- End If
-End Function
-Public Property Get Hits() As Collection
- Set Hits = m_hits
-End Property
-Public Property Set Hits(ByVal value As Collection)
- Set m_hits = value
-End Property
-Private Sub Class_Initialize()
- HitCount = 0
- Set Hits = New Collection
-End Sub
-Public Property Get Size() As Integer
-Size = oSize
-End Property
-Public Property Let Size(ByVal vNewValue As Integer)
-oSize = vNewValue
-End Property
diff --git a/SampleApp/VBA-Code/ThisWorkbook.txt b/SampleApp/VBA-Code/ThisWorkbook.txt
deleted file mode 100644
index 3cac905..0000000
--- a/SampleApp/VBA-Code/ThisWorkbook.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Private Sub Workbook_Open()
- Code.AddShips Battleship.Range(board1)
- Code.AddUserShips Battleship.Range(board2)
- ComputerPlay.Init
- g_gameEnded=false
- g_logRow = Battleship.Names("LogStart").RefersToRange.row+1
-End Sub
diff --git a/SampleApp/app.config b/SampleApp/app.config
deleted file mode 100644
index e91dbe0..0000000
--- a/SampleApp/app.config
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0"?>
-<configuration>
-<startup><supportedRuntime version="v2.0.50727" sku="Client"/></startup></configuration>
diff --git a/SampleApp/csv/Sample9-1.txt b/SampleApp/csv/Sample9-1.txt
deleted file mode 100644
index ce6134b..0000000
--- a/SampleApp/csv/Sample9-1.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-This file is used in sample 9
-Sales per region
-"Period","Europe","Africa","Asia","North America","South America","Austraila"
-2010-01,12.3,8,55.1,35,14.1,12.1
-2010-02,13.9,9.1,51.1,35.3,14.4,11.1
-2010-03,11.4,8.7,54.7,32.1,13.1,12.3
-2010-04,12.1,9.2,53.3,35,11.2,10.4
-2010-05,9.4,10,45.3,25.8,12.4,13.1
-2010-06,14.3,9.8,49.4,29.2,14.1,14.2
-2010-07,7.3,11,50.0,31.2,14.9,12.3
-2010-08,19.3,10.1,49.6,35,13.3,10.1
-2010-09,21.0,8.5,41.1,35,14.5,9.3
-2010-10,23.8,9.1,45,32,16.1,11.1
-2010-11,25.6,10.8,49,33.6,14.4,13.4
-2010-12,17.2,12.1,43.2,35.1,15.1,15.1
-EOF
\ No newline at end of file
diff --git a/SampleApp/csv/Sample9-2.txt b/SampleApp/csv/Sample9-2.txt
deleted file mode 100644
index 1895660..0000000
--- a/SampleApp/csv/Sample9-2.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-This file is used in sample 9
-ID Product Items In Stock Purchase Price Price
-12001 Nails 37 1,3 3,99
-12002 Hammer 5 5,33 12,10
-12003 Saw 12 8,99 15,37
-12010 Drill 20 4,3 8,00
-12011 Crowbar 7 13,77 23,48
\ No newline at end of file