epplus

OpenXML / EPPlus - Create PivotCache in .Net

荒凉一梦 提交于 2019-12-05 11:11:40
I'm hoping this could help me, at least, answer one of the 2 questions I asked here , but I am looking how to create a PivotCache in EPPlus / OpenXML and can't find anything online / in their documentation that shows how to do it. So, suposing I have one Excel sheet, wksRawData created in EPPlus and I want to create a second sheet with a pivot table based upon the pivot cache of wksRawData.Cells(wksRawData.Dimension.Address) - In the hopes that then I could delete wksRawData but still keep the pivot table. How would I do that? So far, my code for creating the pivot table in my second worksheet

Epplus Csharp | How to manipulate already opened(in use) Excel File

橙三吉。 提交于 2019-12-05 10:02:00
Epplus Csharp | How to manipulate already opened(in use) Excel File. it works only when Excel file is closed. I can do like closing before code execution and reopen again, but do not think it's a way to go as my file contains more than 50000 rows (file size is big). Please advise, how to figure it out. Thanks in advance It is only possible, if the file is opened for reading by a third-party , but not for writing. If the third-party opened the file for writing, your attempt to open the same file even just for reading will result in System.IO.IOException . In fact, it's all about FileStream and

EPPlus - Do I need to call Dispose on objects like ExcelRange?

≯℡__Kan透↙ 提交于 2019-12-05 08:44:44
I'm using the C# EPPlus library to create Excel documents. ExcelWorksheet ws = pkg.Workbook.Worksheets.Add("Sheet1"); ws.Cells["E3"].Value = "Foo"; ws.Cells["F3"].Value = "Bar"; ws.Cells["F3"].Style.Font.Bold = true; The ws.Cells[] return type is ExcelRange which has a Dispose() method. Do I need to call it each time I use ws.Cells[] ? Something like ExcelWorksheet ws = pkg.Workbook.Worksheets.Add("Sheet1"); ExcelRange rng; rng = ws.Cells["E3"]; rng.Value = "Foo"; rng.Dispose(); using (rng = ws.Cells["F3"]) { rng.Value = "Bar"; rng.Style.Font.Bold = true; } would be a heavy syntax ! Is it

EPPlus converts Excel Spreadsheet column to random negative value

ぃ、小莉子 提交于 2019-12-05 07:28:29
问题 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?

Create an SQL CLR UDF with C#

我怕爱的太早我们不能终老 提交于 2019-12-05 04:41:31
问题 I have been given the task of being able to push SQL query result sets to Excel files. Currently I have a C# console application in place (below) that takes a query, and dumps the results into a specified xlsx file using the EPPlus library. using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using OfficeOpenXml; using OfficeOpenXml.Style; namespace ExcelExport { class Program { static void Main

Downloading Excel File

可紊 提交于 2019-12-05 01:42:51
问题 I have asked this before but am still having difficulties in initiating the file download. var fileName = "ExcelData.xlsx"; var file = new FileInfo(fileName); using (var package = new OfficeOpenXml.ExcelPackage(file)) { var worksheet = package.Workbook.Worksheets.FirstOrDefault(x => x.Name == "Employee Data"); if (package.Workbook.Worksheets.FirstOrDefault(x => x.Name == "Employee Data") == null) { worksheet = package.Workbook.Worksheets.Add("Employee Data"); } else { package.Workbook

How can i get actual used range for modified excels using Epplus?

混江龙づ霸主 提交于 2019-12-04 23:34:43
I am reading data from excel to datable using EPPlus. After reading an excel sheet with 10 rows of record, I modified the excel sheet by removing existing data and kept data for only one row. But when I am reading the modified excel it still reading 10 rows (1 with value and remaining as null fields) to data table. How can limit this? I am using following code for reading Excel. using (var pck = new OfficeOpenXml.ExcelPackage()) { using (var stream = File.OpenRead(FilePath)) { pck.Load(stream); } var ws = pck.Workbook.Worksheets.First(); bool hasHeader = true; // adjust it accordingly(this is

Is it possible to copy row (with data, merging, style) in Excel using Epplus?

这一生的挚爱 提交于 2019-12-04 23:13:54
The problem is that I need to insert data into Excel from the collection several times using a single template for the entire collection. using (var pckg = new ExcelPackage(new FileInfo(association.TemplatePath))) { var workSheet = pckg.Workbook.Worksheets[1]; var dataTable = WorksheetToDataTable(workSheet); /*Some stuff*/ FindAndReplaceValue(workSheet, dictionary, row); } private DataTable WorksheetToDataTable(ExcelWorksheet oSheet) { int totalRows = oSheet.Dimension.End.Row; int totalCols = oSheet.Dimension.End.Column; DataTable dt = new DataTable(oSheet.Name); DataRow dr = null; for (int i

EPPlus: Copy Style to a range

試著忘記壹切 提交于 2019-12-04 21:40:54
问题 i would like to insert x-new rows/columns to a worksheet and apply the style of the row/column from which was inserted (backgroundcolor/border etc). This is how i add new rows: xlsSheet.InsertRow(18, RowCount); Then i would like to copy/apply the style of the "base" row to the new inserted rows: for (int i = 0; i < RowCount; i++) { xlsSheet.Cells[16, 1, 16, xlsSheet.Dimension.End.Column].Copy(xlsSheet.Cells[16 + i + 1, 1]); } But this code doesnt copy/apply the style of the "base" rows. At

Opening Excel Document using EPPlus

自闭症网瘾萝莉.ら 提交于 2019-12-04 16:45:22
问题 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