epplus

Epplus use Excel Styles like Hyperlink

对着背影说爱祢 提交于 2019-12-04 00:40:29
I am trying to style some cells, I'd like to use the standard "Hyperlink" Style, but I am unable to find it. here is my best guess code, but the Workbook does not contain a style other than "standard" var hLinkStyle = (from s in dataSheet.Workbook.Styles.NamedStyles where s.Name == "Hyperlink" select s).FirstOrDefault(); hyperlinkCell.StyleName = hLinkStyle.Name; liang Try to create a named style and set it to the cell as follows: // string link = "your link". // worksheet is your worksheet reference. var namedStyle = worksheet.Workbook.Styles.CreateNamedStyle("HyperLink"); namedStyle.Style

Make column or cells readonly with EPPlus

依然范特西╮ 提交于 2019-12-03 23:32:02
问题 Is there a way to make a column or group of cells locked or read only using EPPlus? I've tried the code below both separate and together however neither seems to have the desired effect. Either the entire worksheet is locked (if I include the IsProtected statement) or nothing at all. ws.Protection.IsProtected = true; ws.Column(10).Style.Locked = true; EDIT Here is entire block of code from my controller FileInfo newFile = new FileInfo("C:\\Users\\" + User.Identity.Name + "\\Desktop" + @"\

invoke formula in excel via epplus

落爺英雄遲暮 提交于 2019-12-03 23:21:05
I have an excel sheet in ASP.NET MVC4 C# project and I am able to read from excel sheet successfully using EPPlus. Now, I want to be able to pass in 2 numbers into cell C:2 and C:3 and be able to invoke formula in C:4 which is =SUM(C2:C3). So from C# I want to pass in 4 and 6 and invoke the formula and be able to get the result back from C:4 which is 40 (SUM of 10 and 30). How do I accomplish that in C#. In the following code, I get back zero for d.Average d.Average = Convert.ToDouble(currentWorksheet.Cells["C4"].Value); Here is my following code in c# so far to traverse a row. using (var

EPPlus converts Excel Spreadsheet column to random negative value

五迷三道 提交于 2019-12-03 21:38:24
I have a C# method, see code below, that generates an Excel spreadsheet using EPPlus. The method takes in 3 strings, one of which is a pipe delimited string named csv that has my data in it. The data I'm using has 14 columns, and in the 14th column I have data that looks like: 103.01.06, or 01.01, or some other numeric values separated by periods. The problem I'm seeing is that if the value is 103.01.06, then EPPlus transforms that into the value -656334. Is there some way to fix this? private void GenerateSpreadsheet(string id, string csv, string worksheetName) { using (ExcelPackage pck = new

Epplus example of `LoadFromCollection<T>(IEnumerable<T>, Boolean, TableStyles, BindingFlags, MemberInfo[])`

↘锁芯ラ 提交于 2019-12-03 14:24:38
When using Epplus ExcelPackage, I typically use a basic LoadFromCollection function to populate a Worksheet, like in this manner: worksheet.Cells[1, 1].LoadFromCollection(Collection:data, PrintHeaders:true); On this site , I see the listing of other overloads of that function, but no specific examples. This one looks interesting. Can someone provide a basic example of this function overload in use? LoadFromCollection<T>(IEnumerable<T> Collection, Boolean PrintHeaders, TableStyles TableStyle, BindingFlags memberFlags, MemberInfo[] Members) I can see by clicking through the API that "

Generating an excel file with EPPlus is failing

断了今生、忘了曾经 提交于 2019-12-03 11:45:04
问题 When I try to generate an Excel file using EPPlus, Excel give me the following error message: Excel cannot open the file 'myfilename.xlsx' because the file format or file extension is not valid. Verify the the file has not been corrupted and that the file extension matches the format of the file. Here's my code: public ActionResult Index() { using (ExcelPackage package = new ExcelPackage()) { // I populate the worksheet here. I'm 90% sure this is fine // because the stream file size changes

Opening Excel Document using EPPlus

主宰稳场 提交于 2019-12-03 09:50:27
I am trying to open an Excel document using EPPlus reference/package. I can't get the Excel application to open. What code am I missing? protected void BtnTest_Click(object sender, EventArgs e) { FileInfo newFile = new FileInfo("C:\\Users\\Scott.Atkinson\\Desktop\\Book.xls"); ExcelPackage pck = new ExcelPackage(newFile); //Add the Content sheet var ws = pck.Workbook.Worksheets.Add("Content"); ws.View.ShowGridLines = false; ws.Column(4).OutlineLevel = 1; ws.Column(4).Collapsed = true; ws.Column(5).OutlineLevel = 1; ws.Column(5).Collapsed = true; ws.OutLineSummaryRight = true; //Headers ws.Cells

How to set Column Type when using EPPlus

偶尔善良 提交于 2019-12-03 06:27:46
问题 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

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

妖精的绣舞 提交于 2019-12-03 05:21:51
问题 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? 回答1: Try

How to set XLSX cell width with EPPlus?

允我心安 提交于 2019-12-03 04:28:39
问题 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,