epplus

EPPlus throwing Argument Exception (Negative row and column numbers are not allowed)

被刻印的时光 ゝ 提交于 2019-12-11 04:37:10
问题 I'm using EPPlus 2.9.0.1 with Visual Basic. I have a DataTable with 35 Rows and 4 Columns and the code below: Dim FullFilePath As String = "c:\Report.xlxs" Dim newFile As FileInfo = New FileInfo(FullFilePath) Using package As ExcelPackage = New ExcelPackage(newFile) Dim worksheet As ExcelWorksheet = package.Workbook.Worksheets.Add("Relatório") worksheet.Cells.LoadFromDataTable(gSystemTable, False) package.Save() End Using When method 'LoadFromDataTable' is called, I get an ArgumentException

EPPlus - saving an excel created in memory and opening it on excel gives an error

断了今生、忘了曾经 提交于 2019-12-11 04:12:10
问题 The objective is to create an excel file in memory and download it in the browser by using an API built in ASP.Net Core, however saving the excel as a stream and converting it to a byte array and then opening it on excel (Office 365 version 1803) gives the error: Code Byte Array: public IActionResult Export() { byte[] bytes; MemoryStream stream = new MemoryStream(); using (ExcelPackage package = new ExcelPackage(stream)) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Employee")

EPPlus Conditional Formatting

冷暖自知 提交于 2019-12-11 02:08:13
问题 I've tried to follow this one: Conditional Formatting by Expression using EPPlus But in my case, the excel file was corrupted and give me option to recover with rule removed. I want to achieve this (simplified): screenshot Here's my codes (for column A): ExcelWorksheet ew = ep.Workbook.Worksheets.Add("Sheet1"); var cells = new ExcelAddress("A2:A5"); string formula = "ISNUMBER(SEARCH($A$1;C2))"; var condition = ew.ConditionalFormatting.AddExpression(cells); condition.Formula = formula;

Clear data in column

时光毁灭记忆、已成空白 提交于 2019-12-11 01:59:03
问题 I'm trying to use the standard .Clear() method for an EPPlus spreadsheet without any luck. Anyone know how to clear all the data in a column using the EPPlus plugin? Below is what i have so far. Does not throw an exception but doesn't work at all. if (File.Exists(path)) { //Connect to spreadsheet FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read); FileInfo file = new FileInfo(path); _package = new ExcelPackage(); //Pull data into EPPlus object _package.Load(stream); _sheet =

How to create a chart with EPPlus with multiple series?

て烟熏妆下的殇ゞ 提交于 2019-12-11 01:46:49
问题 I'm trying to create this chart using EPPlus: Area Imports Exports North America 9.00010837 14.54751448 South America 7.878137347 4.878011063 Europe 32.41924303 39.37317481 Middle East 6.859031587 12.94288951 Africa 7.611513341 2.938054884 Asia 36.23196633 25.32035526 The result should look like: Here's my code: dataSheet.Cells["A1"].Value = "Area"; dataSheet.Cells["B1"].Value = "Imports"; dataSheet.Cells["C1"].Value = "Exports"; var row = 2; foreach (var item in items) { dataSheet.Cells["A"

Generating a HTML table from an Excel file using EPPlus?

末鹿安然 提交于 2019-12-11 01:31:32
问题 I would like to generate a HTML table from an excel file. The EPPlus package provides a .net API for manipulating excel file. I would be happy to know whether it is possible to generate a HTML table code from an Excel file using EPPlus? I couldn't find anything on the documentation, but intuition tells me that there should be a way to do it Thank you! 回答1: If you are looking for something built into EPPlus, I havent seen anything that will export directly HTML. Best thing would be to bring in

EPPLUS - Rename Cell

旧时模样 提交于 2019-12-11 01:22:01
问题 I'm using EPPLUS to build custom Excel spread sheets. One functionality that I'm missing is to change the name of a cell. Is this somehow possible with EPPLUS? If not are there any other ways of doing it? 回答1: Suppose that book is your workbook and sheet is your worksheet. Let try this code snippet var cell = sheet.Cells["C2"]; // Cell or Range you want to name sheet.Names.Add("The_Name_Here", cell); The name will be added to sheet. If you want to access the name in the whole workbook, try:

Get a cell value from excel using EPPlus and Linq

泄露秘密 提交于 2019-12-10 23:52:54
问题 Is it possible to get a cell value from excel sheet using EPPlus and Linq? Example: I have an excel sheet with 3 columns Column 1 = Userid Column 2 = Email address Column 3 = Full name Now i would like to return the email address where userid = x I hope it's more clear now. 回答1: Suppose Column 1 is a , Column 2 is b : var sheet = excelPackage.Workbook.Worksheets[sheetname_orSheetIndex]; var objs = from cell in sheet.Cells["a:a"] // a:a is the column a, Userid where cell.Value.ToString()

Copy/clone an Excel shape with EPPlus?

筅森魡賤 提交于 2019-12-10 19:38:18
问题 Is it possible to create a copy/clone of a shape in an Excel worksheet using the EPPlus library? I know I can get an existing object with var shapeExisting = ws.Drawings["ShapeName"]; ( ws being the Worksheet object) and a create new shape with var shapeNew = ws.Drawings.AddShape("NewName", eShapeStyle.RtTriangle); However, I'm unable to find a way to clone shapeExisting . 回答1: Seems like there's no built-in functionality, so until I find a better solution, I added the following method to

Unable to delete a worksheet using EPPlus

本小妞迷上赌 提交于 2019-12-10 19:27:10
问题 I am using this code: ExcelPackage pck = new ExcelPackage(newFile); var wk = pck.Workbook.Worksheets.SingleOrDefault(x => x.Name == "Content"); pck.Workbook.Worksheets.Delete(wk); But in delete it gives me "IndexOutOfRangeException", but I am trying to delete from object, I have tried to delete by index "1", I just have two worksheets, and the same exception. The file and worksheet is not null, but when I execute delete in anyway I receive the "IndexOutOfRangeException". What's happening?