epplus

EPPlus - LoadFromCollection - Text converted to number

强颜欢笑 提交于 2019-12-29 01:40:21
问题 I am writing a program in C# that needs to export a List<MyObject> into Excel and I'm using EPPlus for doing so. My challenge is that my object has a property: string Prop1 { get; set; } And, one of the values I need to export has a value that, for example, is of the form of Prop1 = "123E4" . The challenge is that the EPPlus LoadFromCollection method exports this to Excel, but Excel converts it into a number using scientific notation (Outputted value = 1.23E+06 or 1230000 ). I've tried

Reading Excel spreasheet using EPPlus

荒凉一梦 提交于 2019-12-28 13:47:14
问题 Could someone point me in the right direction on how to read a Excel spreasheet, loop through all the rows and columns to retreive value using EPPlus and MVC? So fare I see examples to create a spreasheet, but did not find any on opening an excel file and read values from it. Any help would be appreciated. TIA Sue.. 回答1: Simple example // Get the file we are going to process var existingFile = new FileInfo(filePath); // Open and read the XlSX file. using (var package = new ExcelPackage

How to parse excel rows back to types using EPPlus

左心房为你撑大大i 提交于 2019-12-28 05:59:07
问题 EPPlus has a convenient LoadFromCollection<T> 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 Surname { get; set; } public DateTime Birthdate { get; set; } } Then the following code: var package = new ExcelPackage(); var sheet = package.Workbook.Worksheets.Add("Customers"); var customers = new List<Customer>{ new Customer{ Id = 1, Firstname = "John",

EPPlus 'System.OutOfMemoryException'

半世苍凉 提交于 2019-12-25 14:26:43
问题 I am trying to open a 38MB Excel File using EPPlus v4.0 , I am able to pass it to the ExcelPackage variable but when I'm trying to get the workbook from that variable, it causes me a ' System.OutOfMemoryException '. Here's my code: Dim temppath = Path.GetTempPath() Dim filenamestr As String = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) Dim tempfilename As String = Path.Combine(temppath, filenamestr + ".xlsx") fileUploadExcel.SaveAs(tempfilename) Dim XLPack = New ExcelPackage

EPPlus 'System.OutOfMemoryException'

僤鯓⒐⒋嵵緔 提交于 2019-12-25 14:26:10
问题 I am trying to open a 38MB Excel File using EPPlus v4.0 , I am able to pass it to the ExcelPackage variable but when I'm trying to get the workbook from that variable, it causes me a ' System.OutOfMemoryException '. Here's my code: Dim temppath = Path.GetTempPath() Dim filenamestr As String = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) Dim tempfilename As String = Path.Combine(temppath, filenamestr + ".xlsx") fileUploadExcel.SaveAs(tempfilename) Dim XLPack = New ExcelPackage

Partial Load Excel EPPlus C#

风流意气都作罢 提交于 2019-12-25 12:42:08
问题 It is to my understanding that EPPlus loads the entire Excel file into memory which is creating a performance hit. I was wondering if there is a way to partially load Excel into EPPlus to read a small range of rows? I'm using EPPlus version 4.0.4. For instance, I can open a CSV file and read just a small range of rows/lines and performance is good. The CSV file could contain way more then a million rows/lines. IEnumerable<string> lines = System.IO.File.ReadLines(filePath).Skip(0).Take(20)

EPPLus - export to Excel returns failed-network error

我的梦境 提交于 2019-12-25 11:53:18
问题 In my ASP.NET Core 1.1 app, I am exporting data to Excel using EPPLus.Core. But at the time of File download I get the error: Failed- network error Controller public async Task<FileStreamResult> CPT_RC_Excel(int FiscalYear) { var custlist = _Context.Customers.Where(c => c.Region=="NW").ToList(); MemoryStream ms = new MemoryStream(); using (ExcelPackage pck = new ExcelPackage(ms)) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Clients"); ws.Cells["A1"].LoadFromCollection(custlist);

Write large amount of data to excel c#

两盒软妹~` 提交于 2019-12-25 07:26:08
问题 I need to export lots of data from database table to excel (xls/xlsx) file. It could be easily 10million rows and more. I need open source solution which does not require Office to be installed (SpreadsheetGear and interop solutions will not work for me). I am checking two libraries: OpenXML SDK and EPPlus. For OpenXML SDK I found this method: private static void Write(string fileName, int numRows, int numCols) { using (var spreadsheetDocument = SpreadsheetDocument.Open(fileName, true)) {

Implementing Dynamic LINQ querying in MVC5/EF Application?

孤人 提交于 2019-12-25 04:50:31
问题 As an overview I am attempting to add Export() functionality to my application -- allowing the user to specify certain model fields and only export the values in those fields by querying with LINQ and using the EPPlus library to Export. I am attempting to implement Dynamic LINQ functionality in my MVC5/EF Code-First application based on THIS example, but seem to be missing some things to get it working or not understanding something. First I added a new class file to my main project folder