Questions tagged [epplus]

EPPlus is a .NET library that reads and writes Excel files using the Office Open XML format (xlsx) without the need of interop. EPPlus has no dependencies other than .NET.

EPPlus (now migrated to GitHub) supports:

  • Cell Ranges
  • Cell Styling (Border, Color, Fill, Font, Number, Alignments, Merge)
  • Charts
  • Pictures
  • Shapes
  • Comments
  • Tables
  • Protection
  • Encryption
  • Pivot Tables
  • Pivot Charts
  • Data Validation
  • Format Condition
  • Formula calculation
  • VBA

Support for .NET Core 2.0 was added in EPPlus 4.5.

1906 questions
36
votes
2 answers

How to parse excel rows back to types using EPPlus

EPPlus has a convenient LoadFromCollection method to get data of my own type into a worksheet. For example if I have a class: public class Customer { public int Id { get; set; } public string Firstname { get; set; } public string…
Philip Bijker
  • 4,955
  • 2
  • 36
  • 44
36
votes
9 answers

Excel to DataTable using EPPlus - excel locked for editing

I'm using the following code to convert an Excel to a datatable using EPPlus: public DataTable ExcelToDataTable(string path) { var pck = new OfficeOpenXml.ExcelPackage(); pck.Load(File.OpenRead(path)); var ws =…
Fahad
  • 1,364
  • 3
  • 20
  • 40
34
votes
2 answers

How to Horizontalalign Center merged cells in EPPlus

I am having an issue getting a range of merged cells to horizontal align centered. The alignment stays as left. Here's my code. ws.Cells[lStartColumn + lStartRow].Value = gPortfolioName + " - " + lTypeOfPortfolioPerf + " Performance…
David Choi
  • 6,131
  • 10
  • 28
  • 28
32
votes
1 answer

Why is EPPlus telling me that I "Can't set color when patterntype is not set" when I have set PatternType?

I've got this code to try to style a header row: worksheet.Cells["A32:D32"].Style.Font.Name = "Georgia"; worksheet.Cells["A32:D32"].Style.Font.Bold = true; worksheet.Cells["A32:D32"].Style.Font.Size =…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
32
votes
5 answers

Excel Date column returning INT using EPPlus

So i'm using EPPlus to read and write excel documents. Workflow User generates populated excel document Opens document and adds a row Uploaded and read The dates that are generated when I create the document using EPPlus show correctly when I'm…
Tsukasa
  • 6,342
  • 16
  • 64
  • 96
32
votes
6 answers

Adding images into Excel using EPPlus

I am trying to add the same image multiple times into an excel file using EPPlus. I am using the following code to do so: Image logo = Image.FromFile(path); ExcelPackage package = new ExcelPackage(info); var ws =…
matthewr
  • 4,679
  • 5
  • 30
  • 40
30
votes
2 answers

How can I assign a color to a font in EPPlus?

I can set the background color of a cell or range of cells like so: rowRngprogramParamsRange.Style.Fill.PatternType = ExcelFillStyle.Solid; rowRngprogramParamsRange.Style.Fill.BackgroundColor.SetColor(Color.DarkRed); I have not been able to set the…
30
votes
3 answers

How to set cell color programmatically epplus?

I was wondering if it is possible to set cell color programmatically using epplus? I load my data from a sql stored procedure and it works well, but my users want cells that contain the words 'Annual Leave' to have a background color of light yellow…
wubblyjuggly
  • 919
  • 3
  • 13
  • 33
29
votes
3 answers

Epplus not reading excel file

Below is my code to read excel file. Code. FileInfo newFile = new FileInfo("C:\\Excel\\SampleStockTakeExceptionReport.xls"); ExcelPackage pck = new ExcelPackage(newFile); var ws = pck.Workbook.Worksheets.Add("Content"); ws.View.ShowGridLines =…
chinna_82
  • 6,353
  • 17
  • 79
  • 134
26
votes
3 answers

Writing an Excel file in EPPlus

I have been stuck on this for days and despite all of the help out there, none of these solutions have been working for me. What I want to do is create an excel file using the EPPlus library with some basic data in it that I am pulling from a stored…
Rahlord
  • 271
  • 1
  • 3
  • 4
24
votes
4 answers

EPPlus autofilter only working on last cell

I would like each cell in the header to contain an autofilter. Below is the code I'm trying to use however the autofilter only gets set on the last cell specified. For example, if I comment out the autofilter command for K1, the spreadsheet will be…
NealR
  • 10,189
  • 61
  • 159
  • 299
24
votes
1 answer

Hide excel gridlines using EPPLUS

What is the method/command for hiding excel spreadsheet gridlines in EPPLUS?
StephenT
  • 475
  • 5
  • 25
24
votes
2 answers

Opening Excel Document using EPPlus

I am trying to open an Excel document using EPPlus reference/package. I can't get the Excel application to open. What code am I missing? protected void BtnTest_Click(object sender, EventArgs e) { FileInfo newFile = new…
Code Ratchet
  • 5,758
  • 18
  • 77
  • 141
23
votes
7 answers

Make column or cells readonly with EPPlus

Is there a way to make a column or group of cells locked or read only using EPPlus? I've tried the code below both separate and together however neither seems to have the desired effect. Either the entire worksheet is locked (if I include the…
NealR
  • 10,189
  • 61
  • 159
  • 299
23
votes
6 answers

How to access worksheets in EPPlus?

I'm using the 3.1 release of EPPlus library to try to access a worksheet in an Excel file. When I try either of the following methods I get a System.ArgumentException : An item with the same key has already been added. using (ExcelPackage package =…
Shane Courtrille
  • 13,960
  • 22
  • 76
  • 113