Giter VIP home page Giter VIP logo

epplus's Introduction

Nuget Download EPPlus from nuget Build status

EPPlus 7

Announcement: new license model from version 5

EPPlus has from this new major version changed license from LGPL to Polyform Noncommercial 1.0.0.

With the new license EPPlus is still free to use in some cases, but will require a commercial license to be used in a commercial business.

This is explained in more detail here.

Commercial licenses, which includes support, can be purchased at (https://www.epplussoftware.com/).

The source code of EPPlus has moved to a new github repository

LicenseContext parameter must be set

With the license change EPPlus has a new parameter that needs to be configured. If the LicenseContext is not set, EPPlus will throw a LicenseException (only in debug mode).

This is a simple configuration that can be set in a few alternative ways:

1. Via code

// If you are a commercial business and have
// purchased commercial licenses use the static property
// LicenseContext of the ExcelPackage class :
ExcelPackage.LicenseContext = LicenseContext.Commercial;

// If you use EPPlus in a noncommercial context
// according to the Polyform Noncommercial license:
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
    
using(var package = new ExcelPackage(new FileInfo("MyWorkbook.xlsx")))
{

}

2. Via appSettings.json

{
    {
    "EPPlus": {
        "ExcelPackage": {
            "LicenseContext": "Commercial" //The license context used
            }
        }
    }
}

3. Via app/web.config

<appSettings>
    <!--The license context used-->
    <add key="EPPlus:ExcelPackage.LicenseContext" value="NonCommercial" />
</appSettings>

4. Set the environment variable 'EPPlusLicenseContext'

This might be the easiest way of configuring this. Just as above, set the variable to Commercial or NonCommercial depending on your usage.

Important! The environment variable should be set at the user or process level.

New features in EPPlus 7

  • Calculation engine update to support array formulas. https://epplussoftware.com/en/Developers/EPPlus7
    • Support for calculating legacy / dynamic array formulas.
    • Support for intersect operator.
    • Support for implicit intersection.
    • Support for array parameters in functions.
    • Better support for using the colon operator with functions.
    • Better handling of circular references
    • 90 new functions
    • Faster optimized calculation engine with configurable expression caching.
    • Breaking changes: Updated calculation engine, See Breaking Changes in EPPlus 7 for more information.
    • Conditional Formatting improvements
    • Improved performance, xml is now read and written on load and save.
    • Cross worksheet support formula support.
    • Extended styling options for color scales, data bars and icon sets.

Breaking Changes

See https://github.com/EPPlusSoftware/EPPlus/wiki/Breaking-Changes-in-EPPlus-7

Improved documentation

EPPlus 7 has a new web sample site available here: (https://samples.epplussoftware.com/) , Source code is available here: EPPlus.WebSamples There is also a new sample project for four different docker images, EPPlus.DockerSample.
EPPlus also has two separate sample projects for C# and Visual Basic respectively.
There is also an updated developer wiki. The work with improving the documentation will continue, feedback is highly appreciated!

epplus's People

Contributors

adaneam avatar adrianepplus avatar akorda avatar ariesy avatar aschey avatar aurelianus avatar bluetianx avatar colbybhearn avatar drcolombo avatar haalepplus avatar hedda231 avatar heddaepplus avatar jankallman avatar karlkallman avatar kidgb avatar kolthor avatar leecannon avatar leifjones avatar lifefreedom avatar luuminhsam avatar machuga14 avatar marodev avatar meigyoku-thmn avatar nickbarrett avatar ossianepplus avatar raboud avatar rdhasse avatar soarc avatar swmal avatar twaltari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

epplus's Issues

Row cannot be less than 1. Parameter name: value

I have an excel that has some formatting (merged cells, formulas...etc.). You can find a copy of this excel attached. Im restricted with this format as its provided by the client and cannot be changed. Im using the EPPlus (version 4.5.3.3) to populate rows starting from row 8 but Im trying to use the worksheet.InsertRow(8,recordCounter,8) to create a new row for each inserted record and copy all styles as well from the first row, however I keep getting the following exception:
Row cannot be less than 1. Parameter name: value
MyExcel.xlsx

Formula parser fixes

This issue will cover some bugs, features with the formula parser of EPPlus (tokenizing and calculation).

  • Handle double negators (--) correctly.
  • Value matcher should compare DateTime and double
  • CountIf does not work properly with multiple conditions.

InsertRow / DeleteRow / InsertColumn / DeleteColum do not update formulas on other sheets

To reproduce:

        [TestMethod]
        public void DeleteIssue()
        {
            using (var p = new ExcelPackage())
            {
                var ws1 = p.Workbook.Worksheets.Add("Sheet1");
                var ws2 = p.Workbook.Worksheets.Add("Sheet2");
                ws1.Cells["A10"].Value = 1;
                ws1.Cells["A11"].Formula = "A10*2";
                ws1.Cells["A12"].Value = 3;
                ws2.Cells["A1"].Formula = "SUM(Sheet1!A10:A12)";
                ws1.DeleteRow(1);
                Assert.AreEqual("A9*2",ws1.Cells["A10"].Formula);
                Assert.AreEqual("SUM(Sheet1!A9:A11)",ws2.Cells["A1"].Formula);
            }
        }

Add support for fileSharing tag to protect workbooks (set readonly).

Password protection for a readonly copy of a package can be added using the workbookXml - fileSharing tag
Example:
<fileSharing spinCount="100000" saltValue="Yvt/UWxzbiieUg7qdhlAng==" hashValue="os7WY7CE0OjFKJ4p2bDsl7O8R6JtlEE6tKrHjPEAYwxMB1YYz9MZ9Yj45loZ1sxEjiZ6yEk0iBnY8JvPEKpj8w==" algorithmName="SHA-512" userName="Jan Källman" readOnlyRecommended="1"/>
This can be set in the save dialog in Excel --> Tools --> General options.

TokenHandler uses static TokenSeparatorHandler which ignores custom ITokenSeparatorProvider

Original issue: JanKallman/EPPlus#628

The TokenHandler class calls the static TokenSeparatorHandler.Handle method inside its Handle method

        private void Handle()
        {
            var c = _context.FormulaChars[_tokenIndex];
            Token tokenSeparator;
            if (CharIsTokenSeparator(c, out tokenSeparator))
            {
                if (TokenSeparatorHandler.Handle(c, tokenSeparator, _context, this))
                {
                    return;
                }

The Handle method uses a static collection which contains a MultipleCharSeparatorHandler instance

        private static SeparatorHandler[] _handlers = new SeparatorHandler[]
        { 
            new StringHandler(),
            new BracketHandler(),
            new SheetnameHandler(),
            new MultipleCharSeparatorHandler()
        };

This causes the constructor of MultipleCharSeparatorHandler to use the default TokenSeparatorProvider anyway

        public MultipleCharSeparatorHandler()
            : this(new TokenSeparatorProvider())
        {

        }

This means that it does not use the ITokenSeparatorProvider that was provided initially to the TokenHandler. e.g.

   ITokenSeparatorProvider myTokenSeparatorProvider = new MyTokenSeparatorProvider();

   var tokenFactory = new TokenFactory(myTokenSeparatorProvider, NameValueProvider.Empty, 

   FunctionNameProvider.Empty, false);
   var tokenizer = new SourceCodeTokenizer(tokenFactory, myTokenSeparatorProvider);

Suggested solution:

TokenSeparatorHandler should be non-static and accept a ITokenSeparatorProvider in its constructor to pass on to MultipleCharSeparatorHandler.

TokenHandler should initialize it inside its constructor also passing the ITokenSeparatorProvider
e.g.

         public TokenSeparatorHandler(ITokenSeparatorProvider tokenSeparatorProvider)
	 {
		    _handlers = new SeparatorHandler[]
			{
				new StringHandler(),
				new BracketHandler(),
				new SheetnameHandler(),
				new MultipleCharSeparatorHandler(tokenSeparatorProvider)
			};
	 }

         public TokenHandler(TokenizerContext context, ITokenFactory tokenFactory, 
         ITokenSeparatorProvider tokenProvider)
        {
            _context = context;
            _tokenFactory = tokenFactory;
            _tokenProvider = tokenProvider;
            _tokenSeparatorHandler = new TokenSeparatorHandler(_tokenProvider);

Chart series validation

Chart series will from version 5 handles both addresses and arrays. Arrays are handled in the StringLiteralsX, NumberLiteralsX and NumberLiteralsY arrays when a series is set to an Array ( for example {1,2,3} ).

Handling of circular references

The handling of circular references needs a redesign for the following reasons:

  • Currently a CircularReferenceException is always thrown when the formula engine detects a circular reference during construction of the dependency chain. We want to move the logic for throwing this exception downstream to the compiler so that it only is thrown when Calculate is called.

  • Some functions should be able to ignore if a circular reference occurs.

Chart styles differ for single and multi series charts

Add a new enum ePresetMultiSeriesChartStyle for charts with more than one series. Preset Chart styles can differ depending if the chart has a single data serie or multiple data series.
Add a new overload to ChartStyleManager.SetChartStyle with the new enum

Formulas containing 'R' column cells being re-written with '$'

I have a worksheet that has been working perfectly for a few years. We just upgraded to 4.5.3.3 and now SUM formulas that contain a reference to a cell in column 'R' are being modified at some point in the writing of the spreadsheet.

I'm using Worksheet.Cells(Row, Column).Address to get the values for my SUM ranges. However, in testing, I'm just hard-coding the values and the same behavior occurs.

Examples:
sum(R16:R35) => sum($16:$35) when I write to the formula of the cell
sum(S16:S35) is correctly written
sum(R16:S16) => causes error and excel removes from spreadsheet. Assuming it is written as sum($16:S16)
sum(Q16:S16) is correctly written
Average(R16:R35) => Average($16:$35)

If I write my formulas to the value property of the cell it is written correctly.

What is so magical about the value of 'R'? Can I escape the value so it works? I cannot exclude that column because our data might required that we use that column.

Looks like our option at this time to roll back to the previous version?

RichText causes xml "corruption"

Its not exactly corrupt, but excel complains when opening.
"We found a problem with some content in yourfile.xlsx. Do you want us to try to recover as much as we can? if you trust the source of this workbook, click yes"
After repairing a window reports
"Repaired Records: String properties from /xl/sharedStrings.xml part (Strings)"
Version 5.0.3 (the current nuget)
It looks similar to 559 on the original git, and seen similar issues when googling but no solution.

I use this code to generate the spreadsheet, and it is when the richtext section is used that the problem occurs. (it generated 18 sections of rich text in that cell)

the two different sharedstring.xml files are attached
sharedstrings.zip

`var text = log.Text.Replace('\t', ' ');
var textCell = worksheet.Cells[rowindex, 4];

                    if (regexHighlight.Any(r => r.IsMatch(text)))
                    {
                        textCell.IsRichText = true;
                        foreach (var s in text.Split(' '))
                        {
                            var highlight = regexHighlight.Any(r => r.IsMatch(s));
                            var richText = textCell.RichText.Add(s);
                            richText.Bold = highlight;
                            richText.Color = highlight ? Color.Red : Color.Black;
                            textCell.RichText.Add(" ");
                        }
                    }
                    else
                    {
                        textCell.Value = log.Text.Replace('\t', ' ');
                    }`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.