Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 303
EPPlus supports .NET Framework 3.5 or higher and .NET standard 2.0 and higher.
To use EPPlus 5 with .NET Core on non-Windows systems, libgdiplus is required.
Homebrew on MacOS:brew install mono-libgdiplus
apt-get:apt-get install libgdiplus
These versions works without calling System.Drawing.Common on non-Windows platforms and libgdiplus is not required.
See the features list on this page
Use Nuget, either from Visual studio or from the console. See our Getting Started page for details.
Clone or Download the sample project and explore the different samples in the console application. The samples show most things you can use the library for. The sample project is created in Visual Studio 2019.
Also see our getting started wiki page
Right click the config file in Visual Studio and change Build Action to Content.
This works pretty much as it works in Excel. Here are a few samples...
worksheet.Cells["A1"].Value=1;//Set the value of cell A1 to 1worksheet.Cells[1,1].Value=1;//Set the value of cell A1 to 1worksheet.Cells["A1:B3"].Style.NumberFormat.Format="#,##0";//Sets the numberformat for a rangeworksheet.Cells[1,1,3,2].Style.NumberFormat.Format="#,##0";//Same as above,A1:B3worksheet.Cells["A1:B3,D1:E57"].Style.NumberFormat.Format="#,##0";//Sets the numberformat for a range containing two addresses.worksheet.Cells["A:B"].Style.Font.Bold=true;//Sets font-bold to true for column A & Bworksheet.Cells["1:1,A:A,C3"].Style.Font.Bold=true;//Sets font-bold to true for row 1,column A and cell C3worksheet.Cells["A:XFD"].Style.Font.Name="Arial";//Sets font to Arial for all cells in a worksheet.//Sets the background color for the selected range (default is A1). //A range is selected using the by using the worksheet.Select methodworksheet.Cells.Style.Fill.PatternType=ExcelFillStyle.Solid;worksheet.Cells.Style.Fill.BackgroundColor.SetColor(Color.LightGreen);Make sure you add your numeric data using numeric datatypes.
strings="1000"inti=1000;worksheet.Cells["A1"].Value=s;//Will not be formattedworksheet.Cells["A2"].Value=i;//Will be formattedworksheet.Cells["A1:A2"].Style.NumberFormat.Format="#,##0";Check your Formulas and Numberformats. Formulas and numberformats are not validated by the library so if you enter anything wrong the package will be corrupt. Use the English formula names. Formula parameters are separated by commas (,), string parameters use double quotes (").
worksheet.Cells["A1"].Formula="CONCATENATE(\"string1_\",\"test\")";** Numberformats: ** Use culture independent number formats: dot (.) for decimal, comma (thousand).
The easiest way to check a format or a formula is to create an Excel file --> Do the formatting / Add the formulas --> Save it as XLSX ---> Rename the file *.zip. Extract the file and have a look at the number formats in the \xl\styles.xml file and formulas in \xl\worksheets\sheet#.xml.
Do the same procedure as above and look at the formats in the styles.xml file
Use the drawings collection...
varchart=sheet.Drawings.AddAreaChart("chart1",eAreaChartType.AreaStacked);//Set position and sizechart.SetPosition(0,630);chart.SetSize(800,600);//Add one serie. varserie=chart.Series.Add(Worksheet.Cells["A1:A4"],Worksheet.Cells["B1:B4"]);For more details on charts, see our Charts wiki page.
Here's how you do...
ExcelChartchart=worksheet.Drawings.AddLineChart("chtLine",eLineChartType.LineMarkers);varserie1=chart.Series.Add(Worksheet.Cells["B1:B4"],Worksheet.Cells["A1:A4"]);//Now for the second chart type we use the chart.PlotArea.ChartTypes collection...varchartType2=chart.PlotArea.ChartTypes.AddBarChart(eBarChartType.ColumnClustered);varserie2=chartType2.Series.Add(Worksheet.Cells["C1:C4"],Worksheet.Cells["A1:A4"]);If you want to have a secondary axis on your chart you have to add a new charttype to the chart. Something like this...
ExcelChartchart=worksheet.Drawings.AddLineChart("chtLine",eLineChartType.LineMarkers);varserie1=chart.Series.Add(Worksheet.Cells["B1:B4"],Worksheet.Cells["A1:A4"]);varchartType2=chart.PlotArea.ChartTypes.AddLineChart(eLineChartType.LineMarkers);varserie2=chartSerie2.Series.Add(Worksheet.Cells["C1:C4"],Worksheet.Cells["A1:A4"]);chartType2.UseSecondaryAxis=true;//By default the secondary X axis is hidden. If you what to show it, try this...chartType2.XAxis.Deleted=false;chartType2.XAxis.TickLabelPosition=eTickLabelPosition.High;EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles