epplus

Converting Excel cell to percentage using epplus

Deadly 提交于 2019-12-10 12:38:38
问题 I would like to convert the value in to 2 decimal places. I am using EPPlus if the value is 66.6666667 and I would like to show it as 66.66% I tried the following code but its not working. foreach (var dc in dateColumns) { sheet.Cells[2, dc, rowCount + 1, dc].Style.Numberformat.Format = "###,##%"; } Please help. 回答1: I found it! I tried foreach (var dc in dateColumns) { sheet.Cells[2, dc, rowCount + 1, dc].Style.Numberformat.Format ="#0\\.00%"; } 回答2: The correct formula is as follows:

Read data from an Excel file

故事扮演 提交于 2019-12-10 12:25:14
问题 I searched the official documentation, but it is focused on creating the Excel file and not on reading. Any code snippet as an example will help me! How do I read Excel data? COMPANY | DOCUMENT | COMPANYONE | 123455986 | COMPANYTWO | 123455986 | COMPANYTHREE| 123455986 | 回答1: Or use Excel Interop: using Microsoft.Office.Interop.Excel; ... Microsoft.Office.Interop.Excel.Application xl = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook workbook = xl

Print command in EPPlus?

删除回忆录丶 提交于 2019-12-10 10:54:11
问题 I'm using EPPLUS to allow users to download data to Excel. However, I'd like to add a feature wherein they can just choose to print this data rather than download it. Can we issue a print command from EPPLus? 回答1: It is a web app Ah, so there's the main problem... You know, even if EPPlus had a method for printing, it wouldn't help you, because it would try to trigger a printing dialog on the server-side, but you need to send the file to the client over the internet. So I'm afraid the answer

Epplus find column using column name

萝らか妹 提交于 2019-12-10 02:21:37
问题 I have excel sheet created dynamically, i would like to format some columns as date however i don't know the index of these columns in advance i only know the header title. 1- I load the excel from DataTable var templateXls = new ExcelPackage(); var sheet = templateXls.Workbook.Worksheets.Add(parameters.ReportName); sheet.Cells["A1"].LoadFromDataTable(myDataTable, true); Now how can i format for example column with name "Birthdate" to be short-date field? the column can be in any index

Get all the cell values from excel using EPPlus

我的梦境 提交于 2019-12-09 20:07:46
问题 I want to use the ExcelWorksheet object from the EPPlus library and retrieve all the cells with values as well as their positions. At the end of the day, I want a dictionary similar to this. Dictionary<KeyValuePair<int, int>, object> values. I am looking for a nice and clean way to extract the cell values into this dictionary for use. I am quite aware that you can reference the cell values directly as below, but is there a nice clean way of extracting all the data ? worksheet.Cells[row,

How to remove a column from excel sheet in epplus

谁都会走 提交于 2019-12-08 19:08:45
问题 I'm using csharp to insert data into excel sheet into 7 columns. The interface of this program will allow users to select 7 checkboxes. If they select all 7, all the 7 columns in spreadhseet will have data, if they select one checkbox then only one column will have data. I have got a for loop which will check if data is there, if no data exists, I want to remove that column in epplus. Here's a previous discussion on this topic How can I delete a Column of XLSX file with EPPlus in web app It's

.xlsx Created and Saved Using Template with EPPlus is Unreadable/Corrupt

本小妞迷上赌 提交于 2019-12-08 18:02:58
问题 The Problem I'm trying to create a small program that uses an Excel template to create an Excel document and then writes to several cells using EPPlus. Unfortunately, the files appear to be corrupt no matter what I try. My code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using OfficeOpenXml; using System.IO; namespace ConsoleApplication9 { public sealed class ExcelSerialize { private readonly List<Tuple<string, string>> Results; private readonly

Lock image (or picture) or Get image (or picture) from excel using EPPlus

落爺英雄遲暮 提交于 2019-12-08 15:36:34
问题 I'm using EPPlus for excel export. In that, I've locked image. Through code before insert some values to cells, I've unprotect sheet data or cells. After unprotect, I've inserted values and locked those cells and then applied protection. For the cells which have data are locked. But the image has unlocked. Now I'm having only two solution. How to keep the image (or picture) has locked in sheet. How to get the image (or picture) from excel and insert that image as embedded. How to do that ?

Formatting a column with EPPLUS Excel Library

被刻印的时光 ゝ 提交于 2019-12-08 15:35:11
问题 I wrote a C# program to create an excel spreadsheet. The sheet has multiple columns. I want to format ONE of the columns. aFile = new FileInfo(excelDocName); // excelDocName is a string ExcelPackage pck = new ExcelPackage(aFile); var ws = pck.Workbook.Worksheets.Add("Content"); ws.View.ShowGridLines = true; ws.Cells["B:B"].Style.Numberformat.Format = "0.00"; ws.Cells[1, 1].Value = "AA"; ws.Cells[1, 2].Value = "BB"; ws.Cells[1, 3].Value = "CC"; ws.Cells[1, 4].Value = "DD"; for (int row = 2;

how to get EPPlus OpenXML row count (c#)

我是研究僧i 提交于 2019-12-08 14:56:18
问题 I searched for it and found the link C# EPPlus OpenXML count rows int iRowCount = currentWorksheet.Dimension.End.Row - currentWorksheet.Dimension.Start.Row; But this gives a value of 4721 as count. It is giving the whole row count, how can I get row count of rows which has value. Something like UsedRange. 回答1: You can get the count by workBook.Worksheets.Count 回答2: Actual Answer to return the number of Rows and Columns of the UsedRange (the dimention) of a sheet is... int iColCnt = Worksheet