epplus

how to copy ExcelWorkSheet from template with new CodeModule

 ̄綄美尐妖づ 提交于 2019-12-01 20:09:13
I am having an issue with copying a ExcelWorkSheet and the corresponding CodeModule of the copied sheet. Let me explain: Scenario: I have an excel file with macro's (.xlsm) and I use this excel file as a template to create an other excel file (data will be copied into the new file). So, first I fetch some data from a database and open the excel template ( .xlsm ) file. At a certain point, some entries need to be in different worksheets, this is where the 'WorkSheets.Add()' comes in. var newSheet = workbook.Worksheets.Add("someName", templateSheet); After copying the template sheet (which

EPPlus Pivot Table - Collapse entire field

我们两清 提交于 2019-12-01 18:00:51
Does anyone know how to do this? I'm using EPPlus in .Net and have created a pivot table with 2 row fields and one summary datafield: Dim Pivot As OfficeOpenXml.Table.PivotTable.ExcelPivotTable Pivot = wksPivot.PivotTables.Add(wksPivot.Cells("A1"), Datarange, "pName") Pivot.RowFields.Add(Pivot.Fields("Fld1")).Sort = Table.PivotTable.eSortType.Ascending Pivot.RowFields.Add(Pivot.Fields("Fld2")).Sort = Table.PivotTable.eSortType.Ascending Dim dtaFld As OfficeOpenXml.Table.PivotTable.ExcelPivotTableDataField dtaFld = Pivot.DataFields.Add(Pivot.Fields("XYZ")) dtaFld.Function = Table.PivotTable

How to set the style for an entire column in EPPlus?

最后都变了- 提交于 2019-12-01 16:17:41
Is it possible to set the style for an entire column in EPPlus? I would expect that I could just use the Column method, but when I do I get strange results: //Sets all cells in all columns to Red worksheet.Column(1).Style.Font.Color.SetColor(Color.Red); //Sets some cells in column B to red. worksheet.Column(2).Style.Font.Color.SetColor(Color.Red); In both cases I am setting the colour after adding some header rows but before adding the bulk of the rows am an not setting the colour anywhere else. I also get similar unexpected results setting the horizontal alignment. At the moment I am

Force EPPLUS to read as text

流过昼夜 提交于 2019-12-01 15:58:09
I'm developping an application to read xlsx files, do some validation and insert into database. Unfortunatelly when I try to read columns marked as numeric (fe with EAN-13 codes) I get miniumum value of an int. The user doesn't see this because Excel displays it properly. How can I make it read the file as plain text? I know I can use OLEBD for it, but I also need to edit the file dynamically, so epplus ExcelPackage is the best choice. Here is code im using: FileInfo file = new FileInfo(path); MainExcel = new OfficeOpenXml.ExcelPackage(file); { var ws = MainExcel.Workbook.Worksheets.First();

Force EPPLUS to read as text

社会主义新天地 提交于 2019-12-01 14:39:48
问题 I'm developping an application to read xlsx files, do some validation and insert into database. Unfortunatelly when I try to read columns marked as numeric (fe with EAN-13 codes) I get miniumum value of an int. The user doesn't see this because Excel displays it properly. How can I make it read the file as plain text? I know I can use OLEBD for it, but I also need to edit the file dynamically, so epplus ExcelPackage is the best choice. Here is code im using: FileInfo file = new FileInfo(path)

Inconsistent appearance between manual and coded versions of solid databar and databar minimum value

痞子三分冷 提交于 2019-12-01 09:20:15
I am trying to create solid databars in EPPlus 4.0.4, and am running into two problems. First, I haven't been able to figure out how to create a solid fill color. Second, at least for small values, the bars aren't showing up the way I expect them to. The screenshot below illustrates both issues. In both cases, the desired outcome is that of the databar I've added manually in Excel: This is the code I'm currently using: var bars = doc.ConditionalFormatting.AddDatabar(range, Color.FromArgb(99,195,132)); bars.HighValue.Type = eExcelConditionalFormattingValueObjectType.Num; bars.LowValue.Type =

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

时光怂恿深爱的人放手 提交于 2019-12-01 08:01:17
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 assigns the header names and all. Details about the series taken Output: Input Hard to say without more

How to add values to a spreadsheet from a dictionary?

坚强是说给别人听的谎言 提交于 2019-12-01 06:16:23
I have a template spreadsheet document that has two columns, Server Name and IP Address. How can I populate the spreadsheet so that each dictionary key goes in its own cell in the Server column and the corresponding value goes in the cell next to it in the IP column? I am using the EPPlus library but couldn't find anything on the topic. Below is what I found and tried, but its for lists using (ExcelPackage package = new ExcelPackage(_fileInfo)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; for (int i = 0; i < listOfIPs.Count; i++) { worksheet.Cells[i + 2, 1].Value = listOfIPs[i]

Converting XLSX file using to a CSV file

丶灬走出姿态 提交于 2019-12-01 05:44:36
I need to convert an XLSX file to another CSV file. I've done a lot of research on how to do this process, but I did not find anything that suited me. I found this Github Gist only Convert an Epplus ExcelPackage to a CSV file That returns an Array of binary. But apparently it does not work any more. I'm trying to load Array using LoadFromCollection FileInfo novoArquivoCSV = new FileInfo(fbd.SelectedPath); var fileInfoCSV = new FileInfo(novoArquivo + "\\" + nameFile.ToString() + ".csv"); using (var csv = new ExcelPackage(fileInfoCSV)) { csv.Workbook.Worksheets.Add(nameFile.ToString()); var

Huge memory Allocation when using EPPlus Excel Library

醉酒当歌 提交于 2019-12-01 05:22:48
Context I have been using EPPLUS as my tool to automate excel report generation, using C# as the client language of the library. Problem: After trying to write a really big report (response of a SQL Query), with pivot tables, charts and so forth, i end up having a Out of Memory Exception . TroubleShooting In order to troubleshoot, i decided to open an existing report that has 138MB, and use the GC object to try to take a peek on what's happening with my memory, and here are the results. ExcelPackage pkg = new ExcelPackage (new FileInfo (@"PATH TO THE REPORT.xlsx")); ExcelWorkbook wb = pkg