epplus

Reading Excel spreasheet using EPPlus

霸气de小男生 提交于 2019-11-28 09:08:52
Could someone point me in the right direction on how to read a Excel spreasheet, loop through all the rows and columns to retreive value using EPPlus and MVC? So fare I see examples to create a spreasheet, but did not find any on opening an excel file and read values from it. Any help would be appreciated. TIA Sue.. weismat Simple example // Get the file we are going to process var existingFile = new FileInfo(filePath); // Open and read the XlSX file. using (var package = new ExcelPackage(existingFile)) { // Get the work book in the file var workBook = package.Workbook; if (workBook != null) {

Save as using EPPlus?

走远了吗. 提交于 2019-11-28 09:04:25
Does any one know how to use the package.Saveas function? package.SaveAs(tempFolderPathAlt + saveas + ".xlsx"); At the moment this is underlined in red with the following error: The best overloaded method match for 'OfficeOpenXml.ExcelPackage.SaveAs(System.IO.Stream)' has some invalid arguments At the moment i'm saving the file in the following way. FileStream aFile = new FileStream(tempFolderPathAlt + saveas + ".xls", FileMode.Create); byte[] byData = package.GetAsByteArray(); aFile.Seek(0, SeekOrigin.Begin); aFile.Write(byData, 0, byData.Length); aFile.Close(); But this way the package

Using secondary axis for chart cause x-axis and primary y-axis issue (Excel)

寵の児 提交于 2019-11-28 04:38:25
问题 Making a chart using secondary axis, makes my chart primary y-axis is shown with some values which I don't want to have. Only x-axis and secondary y-axis . and also the x-axis is drawn without the date values what I've passed. Code: chartType2 = GetChartType(worksheet, chartToDraw, endcolcnt, i, chartType2, chartType); chartType2.UseSecondaryAxis = true; Scale(headerString, endcolcnt, worksheet, chartType2, stcol, isFieldSame, endcol, stcolumn1, endrow, startRow); and Scale Function only

Get Merged Cell Area with EPPLus

眉间皱痕 提交于 2019-11-28 03:35:33
问题 I'm using EPPlus to read excel files. I have a single cell that is part of merged cells. How do I get the merged range that this cell is part of? For example: Assume Range ("A1:C1") has been merged. Given Range "B1" it's Merge property will be true but there isn't a way to get the merged range given a single cell. How do you get the merged range? I was hoping for a .MergedRange which would return Range("A1:C1") 回答1: There is no such property out of the box but the worksheet has a MergedCells

Autofit Row Height of Merged Cell in EPPlus

做~自己de王妃 提交于 2019-11-28 03:19:00
问题 I'm using EPPlus and C# and trying to autosize/autofit the height of a row to accommodate the height needed to show all of the contents of a merged cell with text wrapping. However no matter what I try the text always truncates. Since I'm repeating this process with various text sizes on various worksheets, I don't want to hard code the row height (except to enforce a minimum height for the row). If possible I'd like to do this within EPPlus/C#. With the cells A2:E2 merged and WrapText = true

Excel date format using EPPlus

人盡茶涼 提交于 2019-11-28 02:23:32
问题 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? 回答1: I agree with Yosoyke. You're probably targeting the wrong cells. You can try: ws.Cells["A3"].Style.Numberformat.Format =

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

非 Y 不嫁゛ 提交于 2019-11-28 01:40:56
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 below (example): Code : [HttpPost] public ActionResult ExportUsingEPPlus(ExportAssetsViewModel model) {

Is it possible to ignore Excel warnings when generating spreadsheets using EPPlus?

痞子三分冷 提交于 2019-11-28 01:07:47
I'm storing mix of numeric and non-numeric values in a single column in spreadsheet using C# and EPPlus. When I open spreadsheet with Excel it shows green triangles in the cells with numeric values giving warning that 'Number Stored as Text' and giving option to ignore it for particular cell. Can I do it from code or is it some Excel specific feature? You really have 2 options using code: change the .NumberFormat property of Range to TEXT ( I believe equivalent in epplus is Cell[row, column].Style.NumberFormat.Format ) prefix any number with ' ( a single quote ) - Excel then treats the number

Legend color is incorrect in excel chart created using EPPlus

拜拜、爱过 提交于 2019-11-27 23:19:52
I am wondering if there is a way to manually set the legend entry colors. I changed the series colors to a custom color, but the legend color is not updating. See image: Here is an improved version of the code that the OP linked to in the comments. This version you pass in the color you want (instead of it just using random ones) to SetChartPointsColor and it will set all point colors to the same as well as create and entry for the legend: public static void SetChartPointsColor(this ExcelChart chart, int serieNumber, Color color) { var chartXml = chart.ChartXml; var nsa = chart.WorkSheet

Create Pivot Table Filters With EPPLUS

こ雲淡風輕ζ 提交于 2019-11-27 22:33:29
I am using EPPLUS excel library. Do you have an idea how to create pivot table with report filters, row label and values ? Some simple example will be excellent. Here is a simple example. Note that EEPlus does not have the ability to do page filters so you will have to use (in order of difficulty) VBA, Excel Interop, or XML manipulation (I used XML below). You can put this code into a unit test of the EPPlus source download for easy testing: const string FORMATCURRENCY = "#,###;[Red](#,###)"; var file = new FileInfo(@"c:\temp\temp.xlsx"); if (file.Exists) file.Delete(); var pck = new