Skip to content

Commit

Permalink
A few fixes related to numberparsing. Some work on the sampleproject.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKallman committed Mar 25, 2018
1 parent 7eb6f29 commit aa7368b
Show file tree
Hide file tree
Showing 23 changed files with 202 additions and 132 deletions.
10 changes: 9 additions & 1 deletion EPPlus.Core.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EPPlus.MultiTarget", "EPPlus\EPPlus.MultiTarget.csproj", "{219F673E-6115-4858-9E07-E33D24E795FE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EPPlusTest.Core", "EPPlusTest\EPPlusTest.Core.csproj", "{78F198E4-B502-425D-BCC7-BF7F93B1EED9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp.Core", "SampleApp.Core\SampleApp.Core.csproj", "{C2A2E62C-BDA3-4ABC-968F-82B51CA0BF0E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApp.Core", "SampleWebApp.Core\SampleWebApp.Core.csproj", "{8360994E-9BD1-4429-AFB6-B15AA96EB13B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,6 +36,12 @@ Global
{C2A2E62C-BDA3-4ABC-968F-82B51CA0BF0E}.Release 4.0|Any CPU.Build.0 = Release|Any CPU
{C2A2E62C-BDA3-4ABC-968F-82B51CA0BF0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2A2E62C-BDA3-4ABC-968F-82B51CA0BF0E}.Release|Any CPU.Build.0 = Release|Any CPU
{8360994E-9BD1-4429-AFB6-B15AA96EB13B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8360994E-9BD1-4429-AFB6-B15AA96EB13B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8360994E-9BD1-4429-AFB6-B15AA96EB13B}.Release 4.0|Any CPU.ActiveCfg = Release|Any CPU
{8360994E-9BD1-4429-AFB6-B15AA96EB13B}.Release 4.0|Any CPU.Build.0 = Release|Any CPU
{8360994E-9BD1-4429-AFB6-B15AA96EB13B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8360994E-9BD1-4429-AFB6-B15AA96EB13B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ExcelDataValidationFormulaDateTime(XmlNamespaceManager namespaceManager,
if (!string.IsNullOrEmpty(value))
{
double oADate = default(double);
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out oADate))
if (double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out oADate))
{
Value = DateTime.FromOADate(oADate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ExcelDataValidationFormulaDecimal(XmlNamespaceManager namespaceManager, X
if (!string.IsNullOrEmpty(value))
{
double dValue = default(double);
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out dValue))
if (double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out dValue))
{
Value = dValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ExcelDataValidationFormulaInt(XmlNamespaceManager namespaceManager, XmlNo
if (!string.IsNullOrEmpty(value))
{
int intValue = default(int);
if (int.TryParse(value, out intValue))
if (int.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out intValue))
{
Value = intValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ExcelDataValidationFormulaTime(XmlNamespaceManager namespaceManager, XmlN
if (!string.IsNullOrEmpty(value))
{
decimal time = default(decimal);
if (decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out time))
if (decimal.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out time))
{
Value = new ExcelTime(time);
}
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/Drawing/Chart/ExcelChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ public eChartStyle Style
else
{
int v;
if (int.TryParse(node.Value, out v))
if (int.TryParse(node.Value, NumberStyles.Number, CultureInfo.InvariantCulture, out v))
{
return (eChartStyle)v;
}
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/Drawing/Chart/ExcelScatterChartSerie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private int getAlphaChannel(string xPath)
if (s.Length > 0)
{
int i = 0;
if (int.TryParse(GetXmlNodeString(s), out i))
if (int.TryParse(GetXmlNodeString(s), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out i))
{
r = (i == 0) ? 0 : 100 - (i / 1000);
}
Expand Down
3 changes: 2 additions & 1 deletion EPPlus/Drawing/Vml/ExcelVmlDrawingCommentCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using System.Text;
using System.Xml;
using System.Collections;
using System.Globalization;

namespace OfficeOpenXml.Drawing.Vml
{
Expand Down Expand Up @@ -158,7 +159,7 @@ internal string GetNewId()
if (draw.Id.Length > 3 && draw.Id.StartsWith("vml"))
{
int id;
if (int.TryParse(draw.Id.Substring(3, draw.Id.Length - 3), out id))
if (int.TryParse(draw.Id.Substring(3, draw.Id.Length - 3), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out id))
{
if (id > _nextID)
{
Expand Down
4 changes: 2 additions & 2 deletions EPPlus/Drawing/Vml/ExcelVmlDrawingPicture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private double GetFracDT(string v, double def)
if (v.EndsWith("f"))
{
v = v.Substring(0, v.Length - 1);
if (double.TryParse(v, out d))
if (double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out d))
{
d /= 65535;
}
Expand All @@ -299,7 +299,7 @@ private double GetFracDT(string v, double def)
}
else
{
if (!double.TryParse(v, out d))
if (!double.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out d))
{
d = def;
}
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/Drawing/Vml/ExcelVmlDrawingPictureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ internal string GetNewId()
if (draw.Id.Length > 3 && draw.Id.StartsWith("vml"))
{
int id;
if (int.TryParse(draw.Id.Substring(3, draw.Id.Length - 3), out id))
if (int.TryParse(draw.Id.Substring(3, draw.Id.Length - 3), System.Globalization.NumberStyles.Number, CultureInfo.InvariantCulture, out id))
{
if (id > _nextID)
{
Expand Down
3 changes: 2 additions & 1 deletion EPPlus/Drawing/Vml/ExcelVmlDrawingPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Xml;
namespace OfficeOpenXml.Drawing.Vml
Expand Down Expand Up @@ -124,7 +125,7 @@ private int GetNumber(int pos)
if (numbers.Length == 8)
{
int ret;
if (int.TryParse(numbers[_startPos + pos], out ret))
if (int.TryParse(numbers[_startPos + pos], System.Globalization.NumberStyles.Number, CultureInfo.InvariantCulture, out ret))
{
return ret;
}
Expand Down
169 changes: 156 additions & 13 deletions EPPlus/EPPlus.MultiTarget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,62 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net35;net40</TargetFrameworks>
<AssemblyVersion>4.5.0.3</AssemblyVersion>
<FileVersion>4.5.0.3</FileVersion>
<Version>4.5.0.3-rc</Version>
<AssemblyVersion>4.5.1.0</AssemblyVersion>
<FileVersion>4.5.1.0</FileVersion>
<Version>4.5.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseUrl>https://www.gnu.org/licenses/lgpl-3.0.en.html</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/JanKallman/EPPlus</PackageProjectUrl>
<Authors>Jan Källman</Authors>
<Company></Company>
<Product>EPPlus</Product>
<Description>Create advanced Excel spreadsheets using .Net</Description>
<Description>Create advanced Excel spreadsheets using .NET</Description>
<AssemblyName>EPPlus</AssemblyName>
<RootNamespace>EPPlus</RootNamespace>
<RepositoryUrl></RepositoryUrl>
<PackageTags>Excel ooxml</PackageTags>
<Copyright>Jan Källman 2018</Copyright>
<PackageReleaseNotes>EPPlus 4.5.0.3 rc
<PackageReleaseNotes>EPPlus 4.5.1

This version fixes a bug in the compound document classes effecting VBA and Encryption.
New features in version 4.5:
* .NET Core support
* Sparklines
* Sort method added to ExcelRange
* Bug fixes and minor changes, see below and visit https://github.com/JanKallman/EPPlus for tutorials, samples and the latest information

NOTE: Breaking change in .Net Core. The indexer of the worksheets collection will be zero based. See remarks under 4.5.0.1 Beta 1 below.
Important Notes:
Breaking change in .NET Core: The Worksheets collection will be zero based as default.
This can be altered by setting the ExcelPackage.Compatibility.IsWorksheets1Based to true.
.NET Core will have this property set to false, and .Net 3.5 and .Net 4 version will have this property set to true for backward compatibility reasons.
This property can also be set via the appsettings.json file in .Net Core or the app.config file. See sample project for examples!

Visit https://github.com/JanKallman/EPPlus for the latest information
.NET Core uses a preview of System.Drawing.Common, so be aware of that. We will update it as Microsoft releases newer versions.
System.Drawing.Common requires libgdiplus to be installed on non-Windows operating systems.
Use your favorite package manager to install it.
For example:

EPPlus-Create advanced Excel spreadsheet.
Homebrew on MacOS:
brew install mono-libgdiplus

apt-get:
apt-get install libgdiplus

EPPlus-A .NET Spreadsheet API

Changes
4.5.1
* Added web sample for .NET Core from Vahid Nasiri
* Added sample sparkline sample to sample project
* Fixed a few problems related to .NET Core on Mac

4.5.0.3
* Fix for compund documents (VBA and Encryption).
* Fix for compound documents (VBA and Encryption).
* Fix for Excel 2010 sha1 hashed agile encryption.
* Upgraded System.Drawing.Common to 4.5.0-preview1-26216-02
* Also se https://github.com/JanKallman/EPPlus/commits/master
* Also see https://github.com/JanKallman/EPPlus/commits/master

4.5.0.2 rc
* Merged in a few pull requests and fixed some issues. See https://github.com/JanKallman/EPPlus/commits/master
* Merge in e few pull requests and fixed a few issues. See https://github.com/JanKallman/EPPlus/commits/master


4.5.0.1 Beta 2
Expand All @@ -52,7 +75,127 @@ EPPlus-Create advanced Excel spreadsheet.
* DataTable propery Added to ExcelPlotArea for charts
* Sort method added on ExcelRange
* Added functions NETWORKDAYS.INTL and NETWORKDAYS.
* And a lot of bug fixes. See https://github.com/JanKallman/EPPlus/commits/master</PackageReleaseNotes>
* And a lot of bug fixes. See https://github.com/JanKallman/EPPlus/commits/master

4.1.1
* Fix VBA bug in Excel 2016 - 1708 and later

4.1
* Added functions Rank, Rank.eq, Rank.avg and Search
* Applied a whole bunch of pull requests...
* Performance and memory usage tweaks
* Ability to set and retrieve 'custom' extended application properties.
* Added style QuotePrefix
* Added support for MajorTimeUnit and MinorTimeUnit to chart axes
* Added GapWidth Property to BarChart and Gapwidth.
* Added Fill and Border properties to ChartSerie.
* Added support for MajorTimeUnit and MinorTimeUnit to chart axes
* Insert/delete row/column now shifts named ranges, comments, tables and pivottables.
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details

4.0.5 Fixes
* Switched to Visual Studio 2015 for code and sample projects.
* Added LineColor, MarkerSize, LineWidth and MarkerLineColor properties to line charts
* Added LineEnd properties to shapes
* Added functions Value, DateValue, TimeValue
* Removed WPF depedency.
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details

4.0.4 Fixes
* Added functions Daverage, Dvar Dvarp, DMax, DMin DSum, DGet, DCount and DCountA
* Exposed the formula parser logging functionality via FormulaParserManager.
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details

4.0.3 Fixes
* Added compilation directive for MONO (Thanks Danny)
* Added functions IfError, Char, Error.Type, Degrees, Fixed, IsNonText, IfNa and SumIfs
* And fixed a lot of issues. See http://epplus.codeplex.com/SourceControl/list/changesets for more details

4.0.2 Fixes
* Fixes a whole bunch of bugs related to the cell store (Worksheet.InsertColumn, Worksheet.InsertRow, Worksheet.DeleteColumn, Worksheet.DeleteRow, Range.Copy, Range.Clear)
* Added functions Acos, Acosh, Asinh, Atanh, Atan, CountBlank, CountIfs, Mina, Offset, Median, Hyperlink, Rept
* Fix for reading Excel comment content from the t-element.
* Fix to make Range.LoadFromCollection work better with inheritance
* And alot of other small fixes

4.0.1 Fixes
* VBA unreadable content
* Fixed a few issues with InsertRow and DeleteRow
* Fixed bug in Average and AverageA
* Handling of Div/0 in functions
* Fixed VBA CodeModule error when copying a worksheet.
* Value decoding when reading str element for cell value.
* Better exception when accessing a worksheet out of range in the Excelworksheets indexer.
* Added Small and Large function to formula parser. Performance fix when encountering an unknown function.
* Fixed handling strings in formulas
* Calculate hangs if formula start with a parenthesis.
* Worksheet.Dimension returned an invalid range in some cases.
* Rowheight was wrong in some cases.
* ExcelSeries.Header had an incorrect validation check.

New features 4.0

Replaced Packaging API with DotNetZip
* This will remove any problems with Isolated Storage and enable multithreading


New Cell store
* Less memory consumption
* Insert columns (not on the range level)
* Faster row inserts,

Formula Parser
* Calculates all formulas in a workbook, a worksheet or in a specified range
* 100+ functions implemented
* Access via Calculate methods on Workbook, Worksheet and Range objects.
* Add custom/missing Excel functions via Workbook. FormulaParserManager.
* Samples added to the EPPlusSamples project.

The formula parser does not support Array Formulas
* Intersect operator (Space)
* References to external workbooks
* And probably a whole lot of other stuff as well :)

Performance
*Of course the performance of the formula parser is nowhere near Excels. Our focus has been functionality.

Agile Encryption (Office 2012-)
* Support for newer type of encryption.

Minor new features
* Chart worksheets
* New Chart Types Bubblecharts
* Radar Charts
* Area Charts
* And lots of bug fixes...

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.
</PackageReleaseNotes>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>OpenOfficeXml.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions EPPlus/ExcelCellBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private static int GetRC(string value, int OffsetValue, out bool fixedAddr)
if (value[0] == '[' && value[value.Length - 1] == ']') //Offset?
{
fixedAddr = false;
if (int.TryParse(value.Substring(1, value.Length - 2), out num))
if (int.TryParse(value.Substring(1, value.Length - 2), NumberStyles.Any, CultureInfo.InvariantCulture, out num))
{
return (OffsetValue + num);
}
Expand All @@ -385,7 +385,7 @@ private static int GetRC(string value, int OffsetValue, out bool fixedAddr)
else
{
fixedAddr = true;
if (int.TryParse(value, out num))
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
{
return num;
}
Expand Down
4 changes: 2 additions & 2 deletions EPPlus/ExcelRangeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ private object ConvertData(ExcelTextFormat Format, string v, int col, bool isTex
if (Format.DataTypes == null || Format.DataTypes.Length <= col || Format.DataTypes[col] == eDataTypes.Unknown)
{
string v2 = v.EndsWith("%") ? v.Substring(0, v.Length - 1) : v;
if (double.TryParse(v2, NumberStyles.Any, Format.Culture, out d))
if (double.TryParse(v2, NumberStyles.Number, Format.Culture, out d))
{
if (v2 == v)
{
Expand Down Expand Up @@ -1727,7 +1727,7 @@ private object ConvertData(ExcelTextFormat Format, string v, int col, bool isTex
}
case eDataTypes.Percent:
string v2 = v.EndsWith("%") ? v.Substring(0, v.Length - 1) : v;
if (double.TryParse(v2, NumberStyles.Any, Format.Culture, out d))
if (double.TryParse(v2, NumberStyles.Number, Format.Culture, out d))
{
return d / 100;
}
Expand Down
Loading

0 comments on commit aa7368b

Please sign in to comment.