epplus

Excel date format using EPPlus

五迷三道 提交于 2019-11-29 09:02:28
I'm having trouble with format my cells to Date. FileInfo info = new FileInfo(path); using (ExcelPackage package = new ExcelPackage(info)) { ExcelWorksheet ws = package.Workbook.Worksheets.Add(sheetName); ws.Cells[3, 1].Style.Numberformat.Format = "yyyy-mm-dd"; ws.Cells["A3"].Formula = "=DATE(2014,10,5)"; } Output from this in Excel: 41 917,00 Why is this not working? Taraz I agree with Yosoyke. You're probably targeting the wrong cells. You can try: ws.Cells["A3"].Style.Numberformat.Format = "yyyy-mm-dd"; ws.Cells["A3"].Formula = "=DATE(2014,10,5)"; prashant kalyanraman worksheet.Cells[

How to create a link inside a cell using EPPlus

泄露秘密 提交于 2019-11-28 22:00:23
问题 I am trying to figure out how to write a Hyperlink inside a cell using EPPlus instead of the cell containing the link text. I need it to be recognized as a link and be clickable. Any help is appreciated. 回答1: The below code worked fine with me. string FileRootPath = "http://www.google.com"; _Worksheet.Cells[intCellNumber, 1].Formula = "HYPERLINK(\"" + FileRootPath + "\",\"" + DisplayText + "\")"; I hope this would help you. Happy coding!! 回答2: This is the other way to do: var cell = sheet

ASP.NET MVC EPPlus Download Excel File

我只是一个虾纸丫 提交于 2019-11-28 21:22:32
So I'm using the fancy EPPlus library to write an Excel file and output it to the user to download. For the following method I'm just using some test data to minimize on the code, then I'll add the code I'm using to connect to database later. Now I can download a file all fine, but when I go to open the file, Excel complains that it's not a valid file and might be corrupted. When I go to look at the file, it says it's 0KB big. So my question is, where am I going wrong? I'm assuming it's with the MemoryStream. Haven't done much work with streams before so I'm not exactly sure what to use here.

Using EPPlus Excel - How to ignore excel error checking or remove green tag on top left of the cell

心已入冬 提交于 2019-11-28 18:58:11
I use EPPlus to export excel 2007 file. The file can export normally but i have some problem with setting column format. My string column with numeric style (Purchase Order No. ex. 49000001) be exported with green tag on the top left of the each cell, How can i remove it? I try to set number format to "General" but it's not work Please help. p.s i use C# EPPLus does not currently support disabling that green tag. However, it is possible to modify the project in order to suppress it. First you will need to add a new class to the project, ExcelIgnoredError.cs: using System; using System

EPPlus - LoadFromCollection - Text converted to number

你离开我真会死。 提交于 2019-11-28 13:49:46
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 setting the entire column to .Style.Numberformat.Format = "@" (and any other style I could think of) and I've

EPPlus Pivot Table - Copy Values to New Sheet

北战南征 提交于 2019-11-28 11:33:41
问题 I've successfully created a pivot table using EPPlus. The pivot table resides in a seperate sheet from the raw data. I would like to copy the pivot table data to a new, third, sheet, but just the values, not the pivot defintions. Does EPPlus support this? 回答1: You can just copy the datasource range via Cache Definition: public void PivotDataCopy() { const string FORMATCURRENCY = "#,###;[Red](#,###)"; var file = new FileInfo(@"c:\temp\temp.xlsx"); if (file.Exists) file.Delete(); var pck = new

Using EPPlus how can I generate a spreadsheet where numbers are numbers not text

試著忘記壹切 提交于 2019-11-28 11:09:06
I am creating a spreadsheet from a List<object[]> using LoadFromArrays The first entry of the array is a title, the other entries are possibly numbers, text or dates (but the same for each array in the list). The generated Excel sheet has the green triangle warning that numbers are formatted as text. I loop through all the cells and set their format to Number like so ws.Cells[i, j].Style.Numberformat.Format = "0"; However the problem remains and I still see the green warning, even though the number format is set to number when I look in the Format Cell... dialogue. What are my options here? It

Use epplus to create .xlsm file

半世苍凉 提交于 2019-11-28 10:50:55
问题 I'm trying to have a website export a .xlsm file and I can't seem to find anything that helps. Here's a simple example I'm using to test building a .xlsx file (which works). @using OfficeOpenXml; <html> <body> <div id="page-wrapper"> @{ // Change file extension to xlsm to test string fileExtension = "xlsm"; ExcelPackage p = new ExcelPackage(); p.Workbook.Worksheets.Add("Worksheet Name"); int LatestWorksheetNumber = p.Workbook.Worksheets.Count; ExcelWorksheet ws = p.Workbook.Worksheets

How to parse excel rows back to types using EPPlus

拈花ヽ惹草 提交于 2019-11-28 09:46:26
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", Surname = "Doe", Birthdate = new DateTime(2000, 1, 1) }, new Customer{ Id = 2, Firstname = "Mary", Surname =

EPPLUS how to know the format of the Worksheet cell

大城市里の小女人 提交于 2019-11-28 09:11:05
问题 I am using EPPlus to read excel sheets and load the data into datatable to perform further operations and then save back the modified data to the excel file. The below code checks if the cell value is a float value then it converts the float value to datetime. The code works fine when the cell value is a date eg: Invoice Date = 42009 , but it converts the not a date value like eg : amount = 10 to a date. Is there any way in EPPlus library from which i can determine the format of the cell (i.e