epplus

Adding a specific autofilter on a column

坚强是说给别人听的谎言 提交于 2019-11-27 22:23:46
I'm trying to set a filter on a column. This is the way I did it in Interop: private void CheckMasterFile(string path) { var xlApp = new Excel.Application(); var xlWorkbook = xlApp.Workbooks.Open(path); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; foreach (var project in projects) { if (string.IsNullOrEmpty(project.ProjectID.Value)) { continue; } var xlRange = xlWorksheet.UsedRange; if (xlWorksheet.AutoFilter != null) { xlWorksheet.AutoFilterMode = false; } xlRange.AutoFilter(Field: 2, Criteria1: project.ProjectID.Value); var result = xlRange.SpecialCells(Excel.XlCellType

Conditional Formatting by Expression using EPPlus

佐手、 提交于 2019-11-27 20:38:15
I'm trying to format some range by using conditional Formatting feature of EPPlus. I read many document but there is nowhere mentions about Conditional Formatting Expression. I'm very confusing. Don't know how to use that feature. Here are my some questions: Can we use multiple range to put into parameter ExcelAddress (like "H1:H17,L1:L17,"AA1:AA17") The formula is put into Formula property is somehow like Interop Excel or not? (like we use "A1" to represent for the current cell for formatting in interop excel) Can you give me a small demo code leg that use Conditional Formatting Expression.

Using EPPlus with a MemoryStream

随声附和 提交于 2019-11-27 19:36:33
I am using EPPlus to generate an XLSX file in C#. As soon as I instantiate the ExcelPackage with a memory stream - I get the error: "A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))" Code is: MemoryStream stream = new MemoryStream(); using (ExcelPackage package = new ExcelPackage(stream)) { ... } Has anyone else seen this? None of the other answers quite got me there (the Excel worksheet was always empty), but this worked for me: using (var package = new ExcelPackage()) { var worksheet = package.Workbook.Worksheets.Add("Worksheet Name");

EPPlus - Read Excel Table

为君一笑 提交于 2019-11-27 14:41:19
问题 Using EPPlus, I want to read an excel table, then store all the contents from each column into its corresponding List . I want it to recognize the table's heading and categorize the contents based on that. For example, if my excel table is as below: Id Name Gender 1 John Male 2 Maria Female 3 Daniel Unknown I want the data to store in List<ExcelData> where public class ExcelData { public string Id { get; set; } public string Name { get; set; } public string Gender { get; set; } } So that I

ASP.NET MVC EPPlus Download Excel File

痞子三分冷 提交于 2019-11-27 13:58:10
问题 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

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

久未见 提交于 2019-11-27 12:02:20
问题 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# 回答1: EPPLus does not currently support disabling that green tag. However, it is possible to modify the project in order to suppress it.

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

筅森魡賤 提交于 2019-11-27 06:04:02
问题 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

Export to Excel - LINQ - Include ForeignKey values in .ToList()?

混江龙づ霸主 提交于 2019-11-27 04:49:15
问题 I am attempting to add Excel Export functionality to my MVC5/Code-First Entity Framework application via the EPPlus library. On my Export View I have filled a MultiSelectList with each of my INV_Assets model properties. These then get passed into my ExportController to designate which fields of the model are to be exported. I've gotten the Headers (via the MultiSelectList ) to load into Row1 of Excel and the data from my INV_Assets model to export to excel via EPPlus LoadFromCollection() as

Using EPPlus with a MemoryStream

北战南征 提交于 2019-11-27 04:23:36
问题 I am using EPPlus to generate an XLSX file in C#. As soon as I instantiate the ExcelPackage with a memory stream - I get the error: "A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))" Code is: MemoryStream stream = new MemoryStream(); using (ExcelPackage package = new ExcelPackage(stream)) { ... } Has anyone else seen this? 回答1: None of the other answers quite got me there (the Excel worksheet was always empty), but this worked for me:

EPPlus number format

回眸只為那壹抹淺笑 提交于 2019-11-27 00:19:37
I have an excel sheet generated with Epplus, I am experiencing some pain points and i wish to be directed by someone who have solved a similar challenge. I need to apply number formatting to a double value and i want to present it in excel like this. 8 -> 8.0 12 -> 12.0 14.54 -> 14.5 0 -> 0.0 Here is my code ws.Cells[row, col].Style.Numberformat.Format = "##0.0"; The final excel file always append E+0 to the end of this format and therefore presents the final values like this instead. 8 -> 8.0E+0 12 -> 12.0E+0 14.54 -> 14.5E+0 0 -> 000.0E+0 When i check in the format cells of the generated