epplus

Opening a client-side Excel file using EPPlus

自闭症网瘾萝莉.ら 提交于 2019-12-04 15:29:16
I am the middle of writing a program which has to create an excel file on a client machine and then, after they have saved and updated it then I need to import it again and apply the changes to my database. The export bit of it works fine, however when I import from the web application I get zero worksheets in my workbook. If I run it on my development machine, i.e. the website is running on the same machine as the file is located then it works fine. My code is as follows: try { Productsfile = new FileInfo(PathandFileName); } catch (Exception ex) { lblStatus.Text = string.Format("Error getting

Get all the cell values from excel using EPPlus

本秂侑毒 提交于 2019-12-04 13:38:52
I want to use the ExcelWorksheet object from the EPPlus library and retrieve all the cells with values as well as their positions. At the end of the day, I want a dictionary similar to this. Dictionary<KeyValuePair<int, int>, object> values. I am looking for a nice and clean way to extract the cell values into this dictionary for use. I am quite aware that you can reference the cell values directly as below, but is there a nice clean way of extracting all the data ? worksheet.Cells[row, column]; There is no native function in EPPlus to convert a the cells collection to a another collection

Freezing columns in EPPlus (an Excel split function)

烂漫一生 提交于 2019-12-04 08:49:35
问题 I've been working a lot with EPPlus to generate Excel files for the number of exports that my project requires me to do. Most of the exports that they want tend to match up perfectly with exports that they have already in their legacy system. One of them, however, they want different. They want it to look exactly like one of the exports from the legacy system after they've done some typical and specific edits . Some of the edits that they do, though, make each row a lot longer than they want

Set cells merged and set its value, but it not work?

大憨熊 提交于 2019-12-04 08:19:18
//use EPPlus.dll using OfficeOpenXml string path = @"C:\Users\Superman\Desktop\recc\1996.xlsx"; ExcelPackage package = new ExcelPackage(new FileInfo(path)); var sheet3 = package.Workbook.Worksheets[3]; sheet3.Cells["A1:B5"].Merge = true; var mergedId = sheet3.MergedCells[1, 1]; sheet3.Cells[mergedId].First().Value = "123"; // error: System.InvalidOperationException : Sequence does not contain any elements package.Save(); What's wrong? How to do it? To answer why the exception from using the First() method - I would bet money that your sheet3 in excel is empty. Remember that the Cells object

Export Linq query result to excel EPPLUS

血红的双手。 提交于 2019-12-04 06:11:26
问题 I have developed a program to get the Linq query and write it to excel file using EPPLUS (the below code) but it is slow because it is filling the file line by line. is there anyway to fill the excel file all at once? to export all the query at once to excel file? fnctnData is the query result Thanks for the help public Boolean GenerateExcel(IEnumerable<ReportData> fnctnData,string fileName,ReportFilTer smf) { Boolean ret=false; try { string temp = Path.GetDirectoryName(AppDomain

C# HttpGet response gives me an empty Excel file with EPPlus

北城以北 提交于 2019-12-04 06:09:48
问题 I've created an endpoint that generates an Excel file. It's supposed to function as a GET in case I want some other code to POST it to a different endpoint for emailing, or in case I want to just download the Excel file by hitting the endpoint manually in a browser. It's downloading the Excel file, but when I try to open it I see the message "Excel cannot open the file 'blahblah' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the

reading a empty cell, gives object reference error

本秂侑毒 提交于 2019-12-04 04:58:12
When I read a cell by doing Worksheets.Cells[2,5].value.ToString(); I get a error "System.NullReferenceException: Object reference not set to an instance of an object." What would be a good way to check for null and then assign the value, without having to have a "if" statement. string strValue = Worksheets.Cells[2,5].value==null ? string.Empty : Worksheets.Cells[2,5].value.ToString(); or object objValue = Worksheets.Cells[2,5].value ?? string.Empty 来源: https://stackoverflow.com/questions/11964271/reading-a-empty-cell-gives-object-reference-error

EPPlus Pivot Table - Collapse entire field

好久不见. 提交于 2019-12-04 03:17:59
问题 Does anyone know how to do this? I'm using EPPlus in .Net and have created a pivot table with 2 row fields and one summary datafield: Dim Pivot As OfficeOpenXml.Table.PivotTable.ExcelPivotTable Pivot = wksPivot.PivotTables.Add(wksPivot.Cells("A1"), Datarange, "pName") Pivot.RowFields.Add(Pivot.Fields("Fld1")).Sort = Table.PivotTable.eSortType.Ascending Pivot.RowFields.Add(Pivot.Fields("Fld2")).Sort = Table.PivotTable.eSortType.Ascending Dim dtaFld As OfficeOpenXml.Table.PivotTable

Trying to read an Excel file with EPPlus works on the server, but not through a browser

泪湿孤枕 提交于 2019-12-04 02:50:15
When I published my project and ran it on the server, it worked. EPPlus found all 4 worksheets, iterated through them, and uploaded my data to SQL. But when I run it through my browser, or my coworkers browser, it shows 0 worksheets. Any idea why this might be happening? There's not much to the code at that point, but here's that part: using (ExcelPackage package = new ExcelPackage(new FileInfo(strFile))) { if (package.Workbook.Worksheets.Count <= 0) strError = "Your Excel file does not contain any work sheets"; else { foreach (ExcelWorksheet worksheet in package.Workbook.Worksheets) { EPPlus

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

家住魔仙堡 提交于 2019-12-04 01:33:25
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 Try this: using (ExcelPackage p = new ExcelPackage()) { //Code to fill Excel file with data. Byte[] bin = p.GetAsByteArray(); Response