epplus

epplus charts without gridlines in c# ( Its a web Application)

流过昼夜 提交于 2019-12-05 21:27:19
Graph Without GridLines I am trying to create a chart in excel file using epplus and c#. I am able to create graph , I am trying to remove the gridlines in graph as shown in the images . I found solution to do it in windows application , but i wanted to do it in web application , below is the code i use to generate graph. ExcelRange erLossesRangeMacInv = worksheet.Cells["G5:G10"]; var chartOEE=(ExcelBarChart)worksheetGraph.Drawings.AddChart("barChartOEE", eChartType.ColumnClustered); chartOEE.SetSize(300, 300);//Setting size of graph chartOEE.SetPosition(10, 10); // position of graph in excel

reading a empty cell, gives object reference error

倖福魔咒の 提交于 2019-12-05 21:05:28
问题 When I read a cell by doing Worksheets.Cells[2,5].value.ToString(); I get a error "System.NullReferenceException: Object reference not set to an instance of an object." What would be a good way to check for null and then assign the value, without having to have a "if" statement. 回答1: string strValue = Worksheets.Cells[2,5].value==null ? string.Empty : Worksheets.Cells[2,5].value.ToString(); or object objValue = Worksheets.Cells[2,5].value ?? string.Empty 来源: https://stackoverflow.com

How to read excel using EPPlus

折月煮酒 提交于 2019-12-05 20:03:44
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]; DataTable tbl = new DataTable(); foreach (var firstRowCell in ws.Cells[1, 1, 1, ws.Dimension.End.Column]) {

EPPlus not caluculating formula output after binding

穿精又带淫゛_ 提交于 2019-12-05 19:18:10
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 calculated. I tried using the following code but it didn't work for me: ws.Workbook.CalcMode = ExcelCalcMode

Export DataSet to excel 2007 EPPlus

本秂侑毒 提交于 2019-12-05 19:06:47
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 method is null,i think that where the erros is,but i cant understand where,here is the full code: namespace

How to create Excel file with EPPlus for A4 paper

穿精又带淫゛_ 提交于 2019-12-05 18:59:09
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.PrinterSettings.BottomMargin = 0; ws.PrinterSettings.LeftMargin = 0; ws.Cells[ws_dimension_adress]

EPPlus Excel Change cell color

心已入冬 提交于 2019-12-05 17:19:35
I am trying to set the color of a given cell with the color of another cell (that is already colored in the template. But worksheet.Cells[row, col].Style.Fill.BackgroundColor doesn't seem to have a get property. Is it possible to do that or do I have to find the exact hexdecimal code of the color on the internet ? EDIT using the code in the answer, I get that error (it is written in French but it translate with what I wrote in my first comment) How about something like this? //get color from this cell var rgb = ws.Cells[1, 2].Style.Fill.BackgroundColor.Rgb; //Convert to system.drawing.color

Epplus use Excel Styles like Hyperlink

断了今生、忘了曾经 提交于 2019-12-05 14:17:03
问题 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; 回答1: Try to create a named style and set it to the cell as follows: // string link = "your link". // worksheet is your worksheet

Can EPPlus distinguish between blank cells and empty text cells in an Excel worksheet?

一笑奈何 提交于 2019-12-05 12:33:01
I'm using the EPPlus .NET library (v4.0.4) to interpret saved Excel workbooks. In one such worksheet, some empty cells have been set to 'text' format using the Excel 'apostrophe' trick (that is, the user has entered a single apostrophe in those cells, so that Excel will display them as blank). Sample XML for two such cells is as follows: <c r="F6" s="1" t="inlineStr"> <is> <t /> </is> </c> <c r="G6" s="1" /> Here, F6 has an apostrophe (i.e. is an empty text cell) and G6 is genuinely blank. Is is possible to read this 'inline string' ( inlineStr ) property using EPPlus or otherwise distinguish

(C#) Can I programmatically set an XLSX cell to a picture/image?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 11:16:02
I am hoping to make spreadsheets that contain some pictures (embed pictures from files) and I started looking at EPPlus (looks like a great library) However it seems that the images are not tied to a cell - rather to an x,y, coordinate. Is there a way with EPPlus or other way to set a cell to a picture (and then manipulate the size of the cell?) SetPosition Jon Peltier You can insert the picture, then adjust its .Top and .Left so it aligns with the .Top and .Left of the appropriate cell. You can set the .RowHeight of the cell's row using the same units as the .height of the picture (though