Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Add Net Core 2.2, 3.0, 3.1 and Net Standard 2.1 targets #610

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
354c844
REPAIRED METHOD - internal ExcelBorderItemXml Copy()
Sep 5, 2018
1ef3966
Add properties for image dimensions: Properties for a resized image's…
Jun 7, 2019
fb1f7e0
Prevent index out of array bounds exception
mason-mcglothlin Jun 7, 2019
1ddba00
Fixed issue in formula match
leonardopinho Jul 13, 2019
f1e36ae
Fix issue #152 Posibility to ignore Microsoft Excel cells warning err…
romcode Sep 3, 2019
03c8dca
Added async method one ExcelPackage
bhugot Dec 5, 2019
2e140bb
changed FileStream creation
bhugot Dec 5, 2019
aa9e9ca
Add Net Core 2.2, 3.0, 3.1 and Net Standard 2.1 targets
TheXDS Jan 15, 2020
c51ce64
Removal of net35 target
TheXDS Jan 15, 2020
1ff6e5d
Fixed problem with namespace prefix for sheetData tag in worksheet.
Michael-Greiner Jan 16, 2020
0d692a2
Merge branch 'master' into master
TheXDS Jan 30, 2020
4938e05
Removal of duplicate propertygroup for netstd2.1
TheXDS Jan 30, 2020
fe2a890
Merge pull request #1 from Michael-Greiner/master
TheXDS Jan 30, 2020
1422d3a
Merge pull request #2 from bhugot/Async_Methods
TheXDS Jan 30, 2020
ad573a5
Merge pull request #3 from romcode/manage-cells-warning-errors
TheXDS Jan 30, 2020
e6e79bc
Merge pull request #4 from leonardopinho/master
TheXDS Jan 30, 2020
7b48a5a
Merge pull request #5 from billgeek/MergeCellsFix
TheXDS Jan 30, 2020
d755ae1
Merge pull request #6 from mason-mcglothlin/master
TheXDS Jan 30, 2020
bf92ef1
Merge pull request #7 from PeterHevesi/ExcelBorderItemXml_Fix
TheXDS Jan 30, 2020
a277715
Minor compilation fixes
TheXDS Jan 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions EPPlus/CellStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using OfficeOpenXml;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;

internal class IndexBase : IComparable<IndexBase>
{
Expand All @@ -53,7 +50,7 @@ internal int IndexPointer
get;
set;
}
internal short Index;
internal int Index;
public int CompareTo(IndexItem other)
{
return Index - other.Index;
Expand Down Expand Up @@ -653,7 +650,7 @@ internal void SetValue(int Row, int Column, T Value)
pageItem = _columnIndex[col]._pages[pos];
}

short ix = (short)(Row - ((pageItem.Index << pageBits) + pageItem.Offset));
int ix = Row - ((pageItem.Index << pageBits) + pageItem.Offset);
_searchItem.Index = ix;
var cellPos = Array.BinarySearch(pageItem.Rows, 0, pageItem.RowCount, _searchItem);
if (cellPos < 0)
Expand All @@ -671,7 +668,7 @@ internal void SetValue(int Row, int Column, T Value)
col = ~col;
AddColumn(col, Column);
AddPage(_columnIndex[col], 0, page);
short ix = (short)(Row - (page << pageBits));
int ix = Row - (page << pageBits);
AddCell(_columnIndex[col], 0, 0, ix, Value);
}
}
Expand Down Expand Up @@ -742,7 +739,7 @@ internal void SetRangeValueSpecial(int fromRow, int fromColumn, int toRow, int t
pageItem = _columnIndex[col]._pages[pos];
}

short ix = (short)(rowIx - ((pageItem.Index << pageBits) + pageItem.Offset));
int ix = rowIx - ((pageItem.Index << pageBits) + pageItem.Offset);
_searchItem.Index = ix;
var cellPos = Array.BinarySearch(pageItem.Rows, 0, pageItem.RowCount, _searchItem);
if (cellPos < 0)
Expand All @@ -761,7 +758,7 @@ internal void SetRangeValueSpecial(int fromRow, int fromColumn, int toRow, int t
col = ~col;
AddColumn(col, colIx);
AddPage(_columnIndex[col], 0, page);
short ix = (short)(rowIx - (page << pageBits));
int ix = rowIx - (page << pageBits);
AddCell(_columnIndex[col], 0, 0, ix, default(T));
Updater(_values, _columnIndex[col]._pages[0].Rows[0].IndexPointer, rowIx, colIx, Value);
}
Expand Down Expand Up @@ -812,7 +809,7 @@ internal void SetValueSpecial(int Row, int Column, SetValueDelegate Updater, obj
pageItem = _columnIndex[col]._pages[pos];
}

short ix = (short)(Row - ((pageItem.Index << pageBits) + pageItem.Offset));
int ix = Row - ((pageItem.Index << pageBits) + pageItem.Offset);
_searchItem.Index = ix;
var cellPos = Array.BinarySearch(pageItem.Rows, 0, pageItem.RowCount, _searchItem);
if (cellPos < 0)
Expand All @@ -831,7 +828,7 @@ internal void SetValueSpecial(int Row, int Column, SetValueDelegate Updater, obj
col = ~col;
AddColumn(col, Column);
AddPage(_columnIndex[col], 0, page);
short ix = (short)(Row - (page << pageBits));
int ix = Row - (page << pageBits);
AddCell(_columnIndex[col], 0, 0, ix, default(T));
Updater(_values, _columnIndex[col]._pages[0].Rows[0].IndexPointer, Value);
}
Expand Down Expand Up @@ -1421,7 +1418,7 @@ internal static int GetSize(int size)
}
return newSize;
}
private void AddCell(ColumnIndex columnIndex, int pagePos, int pos, short ix, T value)
private void AddCell(ColumnIndex columnIndex, int pagePos, int pos, int ix, T value)
{
PageIndex pageItem = columnIndex._pages[pagePos];
if (pageItem.RowCount == pageItem.Rows.Length)
Expand Down
12 changes: 12 additions & 0 deletions EPPlus/Drawing/ExcelPicture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.Windows;
using OfficeOpenXml.Utils;
using OfficeOpenXml.Compatibility;
using Size = System.Drawing.Size;

namespace OfficeOpenXml.Drawing
{
Expand Down Expand Up @@ -353,6 +355,16 @@ internal string ContentType
get;
set;
}

//public Vector GetOffset()
//{
// return new Vector(_left, _top);
//}
public Size GetSize()
{
return new Size(_width, _height);
}

/// <summary>
/// Set the size of the image in percent from the orginal size
/// Note that resizing columns / rows after using this function will effect the size of the picture
Expand Down
116 changes: 76 additions & 40 deletions EPPlus/EPPlus.MultiTarget.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net35;net40</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp3.0;netstandard2.1;netcoreapp2.2;netcoreapp2.1;netstandard2.0;net40</TargetFrameworks>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you want to target netstandard2.1 and netstandard2.0? Wouldn't it just be better to keep the lower version?

Copy link
Author

@TheXDS TheXDS Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it, but ultimately decided to add several different targets because some projects I've seen or worked on do target them directly. For instance, I was unable to use any version of EPPlus on .Net Core 3.1 (the project required the use of .Net Core 3.1 because WPF and XAML Islands)

About netstandard2.1 and 2.0: Microsoft recommends that any new .Net project should target either the latest .Net Core release (3.1) or the latest .Net Standard release (2.1), and discourages targeting older frameworks, unless necessary. But still, I've found issues trying to make EPPlus (both .Net Core 2.1 and .Net Standard 2.0) work on newer targets. So, to properly cover as much platforms as possible, I decided to directly target them in the .csproj file, without sacrificing existing projects that may depend on a specific framework version.

Also, I think that nstd2.1 is basically nc3.0 without Microsoft-specific stuff, nstd2.0 was based of nc2.0, and nc2.2 and 3.0 are actually, really different. It was just to be sure that it would work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think multi-targeting the various net core versions makes a lot of sense. I had just not considered targeting multiple net standard versions before. But with netstandard likely going away with dotnet 5, this may be an unnecessary concern.

<AssemblyVersion>4.5.3.3</AssemblyVersion>
<FileVersion>4.5.3.3</FileVersion>
<Version>4.5.3.3</Version>
Expand Down Expand Up @@ -207,30 +207,30 @@

Beta 2 Changes
* Fixed bug when using RepeatColumns &amp; RepeatRows at the same time.
* VBA project will be left untouched if it’s not accessed.
* Fixed problem with strings on save.
* Added locks to the cell store for access by multiple threads.
* Implemented Indirect function
* Used DisplayNameAttribute to generate column headers from LoadFromCollection
* Rewrote ExcelRangeBase.Copy function.
* Added caching to Save ZipStream for Cells and shared strings to speed up the Save method.
* Added Missing InsertColumn and DeleteColumn
* Added pull request to support Date1904
* Added pull request ExcelWorksheet. LoadFromDataReader

Release Candidate changes
* Fixed some problems with Range.Copy Function
* InsertColumn and Delete column didn't work in some cases
* Chart.DisplayBlankAs had the wrong default type in Excel 2010+
* Datavalidation list overflow caused corruption of the package
* Fixed a few Calculation when referring ranges (for example If function)
* Added ChartAxis.DisplayUnit
* Fixed a bug related to shared formulas
* Named styles failed in some cases.
* Style.Indent got an invalid value in some cases.
* Fixed a problem with AutofitColumns method.
* Performance fix.
* A whole lot of other small fixes.
* VBA project will be left untouched if it’s not accessed.
* Fixed problem with strings on save.
* Added locks to the cell store for access by multiple threads.
* Implemented Indirect function
* Used DisplayNameAttribute to generate column headers from LoadFromCollection
* Rewrote ExcelRangeBase.Copy function.
* Added caching to Save ZipStream for Cells and shared strings to speed up the Save method.
* Added Missing InsertColumn and DeleteColumn
* Added pull request to support Date1904
* Added pull request ExcelWorksheet. LoadFromDataReader

Release Candidate changes
* Fixed some problems with Range.Copy Function
* InsertColumn and Delete column didn't work in some cases
* Chart.DisplayBlankAs had the wrong default type in Excel 2010+
* Datavalidation list overflow caused corruption of the package
* Fixed a few Calculation when referring ranges (for example If function)
* Added ChartAxis.DisplayUnit
* Fixed a bug related to shared formulas
* Named styles failed in some cases.
* Style.Indent got an invalid value in some cases.
* Fixed a problem with AutofitColumns method.
* Performance fix.
* A whole lot of other small fixes.
</PackageReleaseNotes>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>OpenOfficeXml.snk</AssemblyOriginatorKeyFile>
Expand All @@ -246,6 +246,23 @@ Release Candidate changes
<DefineConstants>Core</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>Core</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0'">
<DefineConstants>Core</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.2'">
<DefineConstants>Core</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1'">
<DefineConstants>Core</DefineConstants>
</PropertyGroup>


<PropertyGroup Condition=" '$(TargetFramework)' == 'net35'">
<DefineConstants>NET35;NETFULL</DefineConstants>
</PropertyGroup>
Expand Down Expand Up @@ -291,12 +308,10 @@ Release Candidate changes
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Drawing.Common">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
Expand All @@ -305,20 +320,41 @@ Release Candidate changes
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Drawing.Common">
<Version>4.7.0</Version>
</PackageReference>
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<None Update="readme.txt">
Expand All @@ -329,4 +365,4 @@ Release Candidate changes
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions EPPlus/EPPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
<Compile Include="ConditionalFormatting\Rules\ExcelConditionalFormattingUniqueValues.cs" />
<Compile Include="ConditionalFormatting\Rules\ExcelConditionalFormattingYesterday.cs" />
<Compile Include="Drawing\Chart\ExcelChartDataTable.cs" />
<Compile Include="ExcelIgnoredError.cs" />
<Compile Include="FontSize.cs" />
<Compile Include="DataValidation\Contracts\IExcelDataValidation.cs" />
<Compile Include="DataValidation\Contracts\IExcelDataValidationAny.cs" />
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/Encryption/EncryptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private HMAC GetHmacProvider(EncryptionInfoAgile.EncryptionKeyData ei, byte[] sa
{
switch (ei.HashAlgorithm)
{
#if (!Core)
#if !Core
case eHashAlogorithm.RIPEMD160:
return new HMACRIPEMD160(salt);
#endif
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/ExcelHeaderFooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public ExcelVmlDrawingPicture InsertPicture(FileInfo PictureFile, PictureAlignme

string contentType = ExcelPicture.GetContentType(PictureFile.Extension);
var uriPic = XmlHelper.GetNewUri(_ws._package.Package, "/xl/media/" + PictureFile.Name.Substring(0, PictureFile.Name.Length-PictureFile.Extension.Length) + "{0}" + PictureFile.Extension);
#if (Core)
#if Core
var imgBytes=ImageCompat.GetImageAsByteArray(Picture);
#else
var ic = new ImageConverter();
Expand Down
67 changes: 67 additions & 0 deletions EPPlus/ExcelIgnoredError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*******************************************************************************
* Implemented following briddums advise ( https://stackoverflow.com/users/260473/briddums ),
* as himself explained in https://stackoverflow.com/questions/11858109/using-epplus-excel-how-to-ignore-excel-error-checking-or-remove-green-tag-on-t/14483234#14483234
* The best way to address this issue is adding a whorksheet property that allows to ignore the warnings in a specified range.
*******************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace OfficeOpenXml
{
public class ExcelIgnoredError : XmlHelper
{
private ExcelWorksheet _worksheet;

/// <summary>
/// Constructor
/// </summary>
internal ExcelIgnoredError(XmlNamespaceManager ns, XmlNode node, ExcelWorksheet xlWorkSheet) :
base(ns, node)
{
_worksheet = xlWorkSheet;
}


public bool NumberStoredAsText
{
get
{
return GetXmlNodeBool("@numberStoredAsText");
}
set
{
SetXmlNodeBool("@numberStoredAsText", value);
}
}


public bool TwoDigitTextYear
{
get
{
return GetXmlNodeBool("@twoDigitTextYear");
}
set
{
SetXmlNodeBool("@twoDigitTextYear", value);
}
}


public string Range
{
get
{
return GetXmlNodeString("@sqref");
}
set
{
SetXmlNodeString("@sqref", value);
}
}
}
}
Loading