epplus-4

EPPlus LoadFromDataTable() is double escaping ampersands

旧街凉风 提交于 2019-12-13 01:16:05
问题 Here's my code: ExcelPackage pck = new ExcelPackage(stream); ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Rules"); ws.Cells["A1"].LoadFromDataTable(_rules, true); ws.Cells[ws.Dimension.Address].AutoFitColumns(); ws.Cells[ws.Dimension.Address].Style.WrapText = true; pck.Save(); The _rules DataTable has rows whose text contains an ampersand: &. Let's say AT&T for example. When viewing the file in Excel, the text appears as AT&T . I drilled down on the sharedStrings.xml and found the text

How to get a shape/picture coordinates in pixels in an excel file (xlsx) using EPPlus

岁酱吖の 提交于 2019-12-12 03:26:28
问题 Has anyone succeeded in obtaining the x and y coordinate in pixels of a shape or a picture in a sheet in an excel 2010 file using epplus? 回答1: I finally found a solution using internal xml data, it seems that excel is using a unit for measure called EMU which is equal to 1/9525 pixel . the solution is below public static Rectangle GetDimensions(string shapeName, ExcelWorksheet sheet) { const int EMU = 9525; var shapeBaseNodexPath = string.Format("//*[@name='{0}']", shapeName); //get node that

Epplus row height issue

旧城冷巷雨未停 提交于 2019-12-11 06:44:04
问题 I have an excel file with over 1000 rows. Each row contains some data and 2 images. The images are attached as OfficeOpenXml.Drawing.eEditAs.OneCell After populating the Excel I run this, to set the row height. int prodTableStart = 3; int prodTableEnd = 1025; while (prodTableStart <= prodTableEnd) { ws.Row(prodTableStart).Height = 112d; // works, but mega slow prodTableStart++; } I tried to speed up with something like this: ws.Cells["A" + prodTableStart + ":L" + prodTableEnd].Rows but that

EPPLUS To Clear Contents of A Range Of Cells

跟風遠走 提交于 2019-12-10 16:05:54
问题 I want to use EPPLUS to clear a range of cells. I tried the syntax below, but it gives me an error of object reference not set to an instance of an object What would be the proper way to clear the contents of cells A24:C36 with EPPLUS? ExcelPackage package = new ExcelPackage(); ExcelWorksheet ws = package.Workbook.Worksheets["Sheet1"]; ws.Cells["A24:C36"].Clear(); 回答1: Your code is correct. I think the .xlsx file does not have Worksheets with Sheet1 name. For example, I created this excel

How to Check and merge two rows if next value is same or not in excel with epPlus

冷暖自知 提交于 2019-12-08 10:56:26
问题 I am working on dynamic Excel creation with the help of EPPlus library and I have an excel which data looks like: Name EmpCode Department attendance Prashant 111 CSE 70% for Sep Prashant 111 CSE 90% for Oct XYZ 112 HR 50% for Sep XYZ 112 HR 90% for Oct What I want is: if the current EmpCode is equal to the value of next row then merge this both columns so the expected output will be I am damn sure that each empCode will be repeated only two times. The code what I have tried: for (var rowNum =

Add List Validation to Column except the first two rows

为君一笑 提交于 2019-12-08 00:57:40
问题 I am trying to add a dropdown (list validation) upon creating the excel, I already found the way to add it to whole column but my scenario is different because I only add the validation to whole column except the first row and second row. This is what I have tried so far: public MemoryStream GetExcelSheet() { using (var package = new ExcelPackage()) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Test"); var val = worksheet.DataValidations.AddListValidation("A:A"); val.Formula

Access Protected Excel File with ExcelDataReader and Epplus

安稳与你 提交于 2019-12-07 08:56:54
问题 title pretty much says it all. Looking for a way to access a password protected excel file with ExcelDataReader and Epplus, can't find a proper answer. If using ExcelDataReader, my code looks like excelStream = File.Open(excelFilePath, FileMode.Open, FileAccess.Read); excelReader = ExcelReaderFactory.CreateOpenXmlReader(excelStream); excelDataSet = excelReader.AsDataSet(); If using EPPlus my connection code looks like excelPackage = new ExcelPackage(new FileInfo(excelFilePath)); excelWorkbook

Add List Validation to Column except the first two rows

狂风中的少年 提交于 2019-12-06 12:38:03
I am trying to add a dropdown (list validation) upon creating the excel, I already found the way to add it to whole column but my scenario is different because I only add the validation to whole column except the first row and second row. This is what I have tried so far: public MemoryStream GetExcelSheet() { using (var package = new ExcelPackage()) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Test"); var val = worksheet.DataValidations.AddListValidation("A:A"); val.Formula.Values.Add("Male"); val.Formula.Values.Add("Female"); val.ShowErrorMessage = true; worksheet.Cells["A1"]

Error reading xlsx (2007) file in EPPLUS

早过忘川 提交于 2019-12-06 04:17:51
I have an error while trying to read excel files ( xlsx ) which were saved in Excel 2007 using EPPlus library. Some workaround: ASP.net mvc 5 app with EPPlus v. 4.0.4.0 User can download template file from my site, then fill required data in it, and upload it back. File contains 4 worksheets, one of them is hidden . Workbook is password protected, worksheets are proteced too. All of them have different passwords. Template file ( xlsx ) produced in Excel 2007 or 2010 . When user posts file back I'm trying to open and read it using EPPlus When I post file which was filled in Excel2010 everythins

Excel & EPPlus .NET library: Advanced DropDown list validation

倾然丶 夕夏残阳落幕 提交于 2019-12-01 05:30:12
In Epplus, when we create a DropDown list for some cells in excel file, then user put a value which is not part of the list, the cell show a message says: value must match one of the listed items. Instead of this message, Is it possible to prevent the user to put a value which is not part of the drop down list? Thanks in advance, I3i0 I did it with the following code: //ExcelWorksheet ws var validation = ws.DataValidations.AddListValidation(cell.Address); //Error handling validation.ShowErrorMessage = true; validation.ErrorStyle = ExcelDataValidationWarningStyle.stop; validation.ErrorTitle =