epplus

How convert stream excel file to datatable C#?

Deadly 提交于 2019-11-30 09:36:31
I use Epplus to reading xlsx files from stream. It has a bug , it cant read some columns in my workbook.How can read xlsx files from stream to datatable without epplus ? my older code: public static DataSet ReadExcelFile(Stream stream) { try { //2. Reading from a OpenXml Excel file (2007 format; *.xlsx) IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); //... DataSet result = excelReader.AsDataSet(); return result; } catch (Exception x) { throw x; } } I didnt report it, but i tried so much combinations.If there are empty columns in worksheet ,epplus reader cant read

Merge cells using EPPlus?

徘徊边缘 提交于 2019-11-30 07:47:35
I'm using the EPPlus library to read/write Excel files: http://epplus.codeplex.com/ I'm trying to simply merge some cells when writing a document: using (ExcelPackage pck = new ExcelPackage()) { //Create the worksheet ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo"); //Format the header for column 1-3 using (ExcelRange rng = ws.Cells["A1:C1"]) { bool merge = rng.Merge; } } There's a property named Merge that simply returns true or false. I thought maybe that would Merge the cells, but it doesn't. Anyone know how to do this? You have to use it like this: ws.Cells["A1:C1"].Merge = true;

EPPlus - Read Excel Table

筅森魡賤 提交于 2019-11-30 06:40:15
Using EPPlus, I want to read an excel table, then store all the contents from each column into its corresponding List . I want it to recognize the table's heading and categorize the contents based on that. For example, if my excel table is as below: Id Name Gender 1 John Male 2 Maria Female 3 Daniel Unknown I want the data to store in List<ExcelData> where public class ExcelData { public string Id { get; set; } public string Name { get; set; } public string Gender { get; set; } } So that I can call out the contents using the heading name. For example, when I do this: foreach (var data in

Shaman.EPPlus + ASP.NET Core MVC - Part already exist exception

╄→尐↘猪︶ㄣ 提交于 2019-11-30 05:43:08
问题 I am using Shaman.EPPlus, a version of EPPlus that should be compatible with ASP.NET Core MVC. I am trying to export a collection of object as xlxs file. The code looks like this: foreach(var client in clientsToExport) { clientList.Add(new object[] { "FirstName", client.FirstName }); } MemoryStream stream = new MemoryStream(); using (ExcelPackage pck = new ExcelPackage(stream)) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Clients"); ws.Cells["A1"].LoadFromArrays(clientList); pck.Save();

Create excel graph with epplus

╄→гoц情女王★ 提交于 2019-11-30 05:40:59
问题 here is what I have. I have an excel sheet with two column. Column 1 had descriptions for legend, like Category1 Category 2 etc. Column 2 has numbers with total count like 6,4,18 etc. Category Count Category1 6 Category2 4 Category3 18 I need to display a graph with the count values and display the category names for each line. I tried different values but I cannot figure it out. Here is my current code ExcelChart ec = (ExcelLineChart)chartSheet.Drawings.AddChart("chart_1", eChartType.Line);

How to group rows/columns in EPPlus

帅比萌擦擦* 提交于 2019-11-30 03:09:01
问题 Is there a way to achieve this in EPPlus? Only thing I could find on the internet is grouping specific data for example: AAA ---> AAA 5 occurrences AAA BBB 2 occurences BBB BBB AAA AAA AAA but not visually like in the screenshots 回答1: Looks like you want to do Row and Columns outlines that are collapsed. This should demonstrate how to do that: [TestMethod] public void Row_Col_Grouping_Test() { //http://stackoverflow.com/questions/32760210/how-to-group-rows-columns-in-epplus //Throw in some

Downloading Excel file after creating using EPPlus

亡梦爱人 提交于 2019-11-30 02:50:00
问题 I am using the EPPlus library to generate an excel file which I successfully save in a folder on the server. How can download this file to my local machine? This is my code public void CreateExcelFirstTemplate() { var fileName = "C:\ExcelDataTest\ExcellData.xlsx"; var file = new FileInfo(fileName); using (var package = new OfficeOpenXml.ExcelPackage(file)) { var worksheet = package.Workbook.Worksheets.FirstOrDefault(x => x.Name == "Attempts"); worksheet = package.Workbook.Worksheets.Add(

EPPlus - How to use a template

喜你入骨 提交于 2019-11-29 23:10:29
I have recently discovered EPPlus ( http://epplus.codeplex.com/ ). I have an excel .xlsx file in my project with all the styled column headers. I read on their site that you can use templates. Does anyone know how or can provide code sample of how to use my template.xlsx file with EPPlus? I would like to be able to simply load my data into the rows without messing with the headings. The solution I ended up going with: using System.IO; using System.Reflection; using OfficeOpenXml; //Create a stream of .xlsx file contained within my project using reflection Stream stream = Assembly

Autofit rows in EPPlus

一笑奈何 提交于 2019-11-29 23:06:10
问题 I cannot find a way to autofit row height using the EPPlus Excel library. When I used Excel Interop, I could do sheet.Rows.AutoFit() . I'm looking around the interface using ILSpy, but so far I didn't find anything useful. Is there some workaround, or am I missing something? UPDATE : Row 4 is giving me problems: I tried doing sheet.Row(4).CustomHeight = false, but it didn't work... I also tried setting the property before and after loading the cell content, and it's still the same. It does

Epplus number of drop down items limitation in excel file

萝らか妹 提交于 2019-11-29 21:37:14
问题 Consider this code: var dropDown = sheet.DataValidations.AddListValidation(cells[2, colIndex, maxCol, colIndex].Address); foreach (var bb in brokerBranchs) { dropDown.Formula.Values.Add(bb.Title); } With 29 of dropDown items everything is ok and created excel file works fine but as the number of items exceeds 29, opening created file shows following error: Opening corrupted result file discards all drop down items associated with all columns. What is possible solution to this problem? Any