epplus

How to read excel files row by row in c# using EPPlus

一笑奈何 提交于 2019-12-12 17:04:56
问题 In my MVC controller I am trying to read an excel line by line. But there is a catch. I want to be able to map it to a list . And the model class contains 29 fields. public class GroupMembershipUploadInput { public string chpt_cd {get;set;} public string cnst_mstr_id {get;set;} public string cnst_prefix_nm {get;set;} public string cnst_first_nm {get;set;} public string cnst_middle_nm {get;set;} public string cnst_last_nm {get;set;} public string cnst_addr1_street1 {get;set;} public string

Creating Excel worksheets using Parallel.For and EPPlus

[亡魂溺海] 提交于 2019-12-12 15:28:17
问题 I am using the EPPlus library to create an Excel workbook with many worksheets. I was wondering if it is safe to build the worksheets in parallel. I could not find a mention in the (limited) documentation if the library supports this kind of behavior: package = new ExcelPackage(); int start = 1; int end = 100; Parallel.For(start, end; s => { var worksheet = package.Workbook.Worksheets.Add("Worksheet" + s.ToString()); //routine to populate data here }); 回答1: Take a short look for the source

Epplus add values to a range of cells

随声附和 提交于 2019-12-12 12:32:07
问题 In C#, using Microsoft.Office.Interop.Excel , you can assign values to an entire row at once like this: string[] headings = { "Value1", "Value2", "Value3" }; excelSheet.get_Range("A1:C1", Type.Missing).Value2 = headings; Is there any similar functionality provided in the EPPlus library? 回答1: You could use the .LoadFromCollection method. So, for example: var vals = new string[] { "value1", "value2", "value3" }; var rng = sheet.Cells["A1:A3"]; rng.LoadFromCollection(vals); will produce this

Exception:The total length of a DataValidation list cannot exceed 255 characters

隐身守侯 提交于 2019-12-12 11:33:17
问题 Am trying to create a formula field dynamically in epplus. If formula field contains less than 255 character then it is creating properly. If it exceeds 255 then it is throwing a exception as Exception:The total length of a DataValidation list cannot exceed 255 characters. Can any one please help me to solve this issue? or please tell me some alternatives. 回答1: The problem is you are using the Formula container of that cell to store all of the available list options - basically a CSV list.

Allow leading zeros on a worksheet with EP Plus

时光怂恿深爱的人放手 提交于 2019-12-12 11:06:34
问题 Hi I am using Ep Plus with a web application. I am creating an Excel file that the user can fill out and upload back to the application. When I enter in a number with leading zeros, they are truncated. Is there away to allow leading Zeroes to be entered by the user? 回答1: The accepted answer for this question did not work for me. I found this article from Microsoft which solved my problem. https://support.microsoft.com/en-gb/help/81518/using-a-custom-number-format-to-display-leading-zeros I

epplus using LoadFromCollection with anonymous types

左心房为你撑大大i 提交于 2019-12-12 10:41:16
问题 I have a IEnumerable<object> dataSource which contains a collection anonymous types. The actual structure of the anonymous type won't be known at design time, so I'm trying to find a generic solution that can handle any anonymous type. How can I load them into epplus to create a spreadsheet? I have a worksheet called ws and I tried: ws.Cells["A1"].LoadFromCollection(dataSource, true); However when that runs it outputs all of the anonymous type's properties into a single cell: { Id = 10000,

Load large amount of excel data with EPPlus

旧巷老猫 提交于 2019-12-12 09:57:30
问题 I have a basic winforms app that a user can upload an excel file (.xlsx) and I want to read the contents of this file so I am using EPPlus. The problem is, I am trying to load the contents of a very large excel file, it has 7 tabs, with one tab haveing more then 200k rows, and another tab with 70k. The other 5 total to about 50k. These file will also only continue to get bigger.(The end goal) Since I want to import the data, read the data, and depending on the rules/data I have, I need to

Is it possible to copy row (with data, merging, style) in Excel using Epplus?

老子叫甜甜 提交于 2019-12-12 09:34:26
问题 The problem is that I need to insert data into Excel from the collection several times using a single template for the entire collection. using (var pckg = new ExcelPackage(new FileInfo(association.TemplatePath))) { var workSheet = pckg.Workbook.Worksheets[1]; var dataTable = WorksheetToDataTable(workSheet); /*Some stuff*/ FindAndReplaceValue(workSheet, dictionary, row); } private DataTable WorksheetToDataTable(ExcelWorksheet oSheet) { int totalRows = oSheet.Dimension.End.Row; int totalCols =

Failed - network error when downloading excel file made by EPPlus.dll

∥☆過路亽.° 提交于 2019-12-12 08:23:31
问题 I try to download an excel file made by EPPlus.dll from an asp.net c# web form application. but i get Failed - network error. It should be noted that mentioned error just occurs in chrome and the job can be done successfully in another browsers. by the way this error does not occure on my localhost and it happens only on the main server. It would be very helpful if someone could explain solution for this problem. http://www.irandnn.ir/blog/PostId/29/epplus 回答1: Try this: using (ExcelPackage p

EPPlus Saving file throws NULL reference exception

我只是一个虾纸丫 提交于 2019-12-12 05:14:44
问题 Saving Excel file that contains (even an empty) pivot table results in "Null Reference Exception" without any helpful message. The image that shows the exception message is here below. 回答1: If you create pivot tables with EPPlus, make sure all your columns have headers (naming of the column as first row ). Missing headers result in "null reference exception" when trying to save the file, even though all the rest of the application is perfectly functioning. What a devil. 来源: https:/