epplus

Writing an Excel file in EPPlus

天涯浪子 提交于 2019-12-03 04:15:37
问题 I have been stuck on this for days and despite all of the help out there, none of these solutions have been working for me. What I want to do is create an excel file using the EPPlus library with some basic data in it that I am pulling from a stored procedure. This is the code that I have in my ExportDocument.cs file: public static ExcelPackage CreateExcelDocument(int [] arr) { String path = @"D:\temp\testsheet3.xlsx"; //FileInfo newFile = null; /*if (!File.Exists(path + "\\testsheet2.xlsx"))

How do i iterate through rows in an excel table using epplus?

允我心安 提交于 2019-12-03 02:59:43
问题 I'm new to epplus, and i'm trying to read some values from an excel table. This is what i have so far: var fileInfo = new FileInfo(filename); using(var excelPackage = new OfficeOpenXml.ExcelPackage(fileInfo)) { foreach (var sheet in excelPackage.Workbook.Worksheets) { foreach (ExcelTable table in sheet.Tables) { foreach(var row in table.Rows) // <-- !! { ... } } } } However, now i'm stumped, as the ExcelTable only has a Columns property, but not a Rows property as i had expected. I cannot

EPPlus error reading file

。_饼干妹妹 提交于 2019-12-02 23:39:05
问题 using code like using OfficeOpenXml; // namespace for the ExcelPackage assembly … FileInfo newFile = new FileInfo(@"C:\mynewfile.xlsx"); using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { … } I get an exception error of 'IBM437' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Parameter name: name Any ideas as to what the problem could be? Thanks Martin 回答1: The problem is in the ZIP file

Set Download Location With EPPlus

南楼画角 提交于 2019-12-02 20:26:27
问题 I was following This tutorial on EPPlus, but I am left scratching my head on how to set the downloads location to the logged in users "Downloads" folder? I know for me the location would be this, but is their a way to assign it w/o knowing the logged on persons account info? C:\Users\laptop\Downloads And here is my syntax: string location = "C:\\"; string filename = "EPPlusTest.xlsx"; using (ExcelPackage objExcelPackage = new ExcelPackage()) { ExcelWorksheet objWorksheet = objExcelPackage

How to set Column Type when using EPPlus

限于喜欢 提交于 2019-12-02 19:54:50
I'm using EPPlus to generate Excel files, in DAL I'm populating DataTable , filling data into table, and passing table to Presentation Layer. From there I'm using LoadFromDataTable() method to generate Excel file. Everything works fine, except that I want to set one of the column's type to Date . I tried to set Column type of my DataTable to Date and than pass DataTable to Presentation Layer, but it seems EPPlus either, ignored it, or didn't recognize, because when I'm opening generated Excel file, cell's type is Number . If I manually Format Cells and set Type to Date , Excel shows correct

Set custom BackgroundColor of a Excel sheet cell using epplus c#

陌路散爱 提交于 2019-12-02 18:41:00
The problem: I am using EEPlus. I am stuck at applying a hex color code, e.g. #B7DEE8 , for a cell in my Excel sheet. I got the following (working) code: ws.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(Color.Gray); But I need something like the following: ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor("#B7DEE8"); So my question is: is it possible to use hex color codes with EEPlus? If so, how can I do that? Yograj Gupta Try this Color colFromHex = System.Drawing.ColorTranslator.FromHtml("#B7DEE8"); ws.Cells["A1:B1"]

How to set XLSX cell width with EPPlus?

天大地大妈咪最大 提交于 2019-12-02 17:49:56
Hello I have this code where i create an xlsx file and i need to pre set the width of the xlsx sheet cells. The actual problem is that when i open the excell i need to double click on the gap between the columns with the mouse in order to unwrap the columns and revieal the data that is hidden. Is there a way to do this programmaticaly with Epplus? using (ExcelPackage p = new ExcelPackage()) { String filepath = "C://StatsYellowPages.csv"; DataSet ds = ExportCSVFileToDataset(filepath, "tblCustomers", "\t"); //Here setting some document properties p.Workbook.Properties.Title = "StatsYellowPages";

How do i iterate through rows in an excel table using epplus?

心不动则不痛 提交于 2019-12-02 17:37:12
I'm new to epplus , and i'm trying to read some values from an excel table. This is what i have so far: var fileInfo = new FileInfo(filename); using(var excelPackage = new OfficeOpenXml.ExcelPackage(fileInfo)) { foreach (var sheet in excelPackage.Workbook.Worksheets) { foreach (ExcelTable table in sheet.Tables) { foreach(var row in table.Rows) // <-- !! { ... } } } } However, now i'm stumped, as the ExcelTable only has a Columns property, but not a Rows property as i had expected. I cannot find a Rows property on any object in the library. How do I iterate through a table, reading Row for Row?

EPPlus error reading file

两盒软妹~` 提交于 2019-12-02 13:35:30
using code like using OfficeOpenXml; // namespace for the ExcelPackage assembly … FileInfo newFile = new FileInfo(@"C:\mynewfile.xlsx"); using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { … } I get an exception error of 'IBM437' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Parameter name: name Any ideas as to what the problem could be? Thanks Martin The problem is in the ZIP file reader ( ZipInputStream ). You need to add the encodings like windows-1252 manually: dotnet add package

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

感情迁移 提交于 2019-12-02 08:40:49
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 file extension matches the format of the file." After getting that error, I've tried changing the MIME