epplus

Insert formatted values as currency type while using EPPlus

人盡茶涼 提交于 2019-12-23 01:21:12
问题 I am using format: type ="$###,###,##0.00" for currency and assigning the format type to the worksheet cells eg. wrkSheet.Cells[0].Style.Numberformat.Format = formatType; But this is inserted as text type in excel. I want this to be inserted as Currency or Number in order to continue to do analysis on the values inserted (sort, sum etc). Currently as it is text type validations do not hold correct. Is there any way to force the type in which the formatted values can be inserted? 回答1: Your

Epplus: How to make “LoadFromCollection” use [DisplayFormat()] attributes in model

耗尽温柔 提交于 2019-12-22 14:57:46
问题 I have an ActionResult (in an MVC 5 website) that successfully uses Epplus to export a data set to an Excel document. In the ActionResult code block, I use code like this to format the column as a short date. WIthout this code, the date column appears as int values. // format date columns as date worksheet.Column(6).Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.ShortDatePattern; However, in the Model, I already have this defined as an attribute. It works great on the View page,

How to get a value from Excel spreadsheet cell using EPPLUS?

北城余情 提交于 2019-12-22 13:57:36
问题 I'm using EPPlus library to create excel from datatable. This is what I do: using (ExcelPackage pck = new ExcelPackage()) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo"); ws.Cells["A5:I5"].LoadFromDataTable(dt, true); ws.DefaultColWidth = 25; var headerCell = ws.Cells["A5:I5"]; headerCell.Style.Fill.PatternType = ExcelFillStyle.Solid; headerCell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.BurlyWood); var headerFont = headerCell.Style.Font; headerFont.Bold = true; int

Add drop down in excel using EPplus

依然范特西╮ 提交于 2019-12-22 12:21:02
问题 I need help. How can i add a drop down in excel using Epplus? No need for validation. I just need to add this to my template. Records in the drop down are not dynamic. 回答1: using (ExcelPackage p = new ExcelPackage()) { ExcelWorksheet ws = obj.CreateSheet(p, "sheetname", 1, true); var unitmeasure = ws.DataValidations.AddListValidation("a1"); unitmeasure.Formula.Values.Add("Sq Ft"); unitmeasure.Formula.Values.Add("Meter"); } 来源: https://stackoverflow.com/questions/40614881/add-drop-down-in

How to create Excel file with EPPlus for A4 paper

浪子不回头ぞ 提交于 2019-12-22 10:40:07
问题 My current project use EPPlus to create Excel files. These files are printed by the user and I'm trying to force the Excel file to print in only one A4 page, regardless the width og the content. Actually, when the file is printed, it takes two pages and the second contains just one column. My code: ws.PrinterSettings.Orientation = eOrientation.Landscape; ws.PrinterSettings.PrintArea = ws.Cells[ws_dimension_adress]; ws.PrinterSettings.TopMargin= 0; ws.PrinterSettings.RightMargin = 0; ws

Error reading xlsx (2007) file in EPPLUS

跟風遠走 提交于 2019-12-22 10:34:04
问题 I have an error while trying to read excel files ( xlsx ) which were saved in Excel 2007 using EPPlus library. Some workaround: ASP.net mvc 5 app with EPPlus v. 4.0.4.0 User can download template file from my site, then fill required data in it, and upload it back. File contains 4 worksheets, one of them is hidden . Workbook is password protected, worksheets are proteced too. All of them have different passwords. Template file ( xlsx ) produced in Excel 2007 or 2010 . When user posts file

How to read excel using EPPlus

随声附和 提交于 2019-12-22 09:59:48
问题 using .net 4.5 I'm trying to read .xls/.xlsx file using EPPlus (v4.0.4), but get an error. SO has questions on the same error but none relate or solve my problem. protected void Page_Load(object sender, EventArgs e) { GetDataTableFromExcel(@"D:\test.xlsx"); } private DataTable GetDataTableFromExcel(string path, bool hasHeader = true) { using (var pck = new OfficeOpenXml.ExcelPackage()) { using (var stream = File.OpenRead(path)) { pck.Load(stream); } var ws = pck.Workbook.Worksheets[1];

EPPlus not caluculating formula output after binding

感情迁移 提交于 2019-12-22 09:39:18
问题 I am using EPPlus. I am stuck at cell formulas. My code is below: ExcelPackage pck = new ExcelPackage(@"D:\MYSheets\EmptyFile.xlsx"); var ws = pck.Workbook.Worksheets["MySheet"]; ws.Cells["A3"].Value = "2.3"; ws.Cells["A4"].Value = "10.2"; ws.Cells["A5"].Formula = "=SUM(A3:A4)"; ws.Cells["A5"].Style.Numberformat.Format = "#,##0.00"; pck.Save(); When I open Excel, by default, A5 cell is not calculating the sum of A3 and A4. Unless I modify the A3 and/or A4 cells, the A5 cell remains not

Export DataSet to excel 2007 EPPlus

空扰寡人 提交于 2019-12-22 09:26:24
问题 I'm trying to export a DataSet to excel 2007,i cant use the normal code that is used to export using mime types in the contenttype like this "Response.ContentType = "application/ms-excel";" If i use mime type for xls i get a warning when a i try to export,i can't have this error because of the clients,so i started using EPPlus,but now i'm having expections erros,like "ArgumentNullException was unhandled by user code".When i'm debbuging i noticed that the variable ds in the btnExportClick

OpenXML / EPPlus - Create PivotCache in .Net

﹥>﹥吖頭↗ 提交于 2019-12-22 05:55:13
问题 I'm hoping this could help me, at least, answer one of the 2 questions I asked here, but I am looking how to create a PivotCache in EPPlus / OpenXML and can't find anything online / in their documentation that shows how to do it. So, suposing I have one Excel sheet, wksRawData created in EPPlus and I want to create a second sheet with a pivot table based upon the pivot cache of wksRawData.Cells(wksRawData.Dimension.Address) - In the hopes that then I could delete wksRawData but still keep the