epplus

Excel to DataTable using EPPlus - excel locked for editing

ε祈祈猫儿з 提交于 2019-11-26 16:10:13
I'm using the following code to convert an Excel to a datatable using EPPlus: public DataTable ExcelToDataTable(string path) { var pck = new OfficeOpenXml.ExcelPackage(); pck.Load(File.OpenRead(path)); var ws = pck.Workbook.Worksheets.First(); DataTable tbl = new DataTable(); bool hasHeader = true; foreach (var firstRowCell in ws.Cells[1, 1, 1, ws.Dimension.End.Column]) { tbl.Columns.Add(hasHeader ? firstRowCell.Text : string.Format("Column {0}", firstRowCell.Start.Column)); } var startRow = hasHeader ? 2 : 1; for (var rowNum = startRow; rowNum <= ws.Dimension.End.Row; rowNum++) { var wsRow =

EPPlus Large Dataset Issue with Out of Memory Exception

我们两清 提交于 2019-11-26 09:49:17
问题 System Out of Memory Exception. I see the memory Stream is only flushed when saved. We have 1.5 - 2GB Datasets. I am using EPPlus Version 3.1.3.0 We do the following in code. We loop through --> Create a Package --> each table in the datareader --> Add WorkSheet to the Package --> Dispose Each table. --> Save the Package. Each Datatable is of a 300Mg Size up to 15 Tables out form the System. This is causing a issue, I have logged this in detail @ https://epplus.codeplex.com/workitem/15085 I

EPPlus number format

被刻印的时光 ゝ 提交于 2019-11-26 09:22:28
问题 I have an excel sheet generated with Epplus, I am experiencing some pain points and i wish to be directed by someone who have solved a similar challenge. I need to apply number formatting to a double value and i want to present it in excel like this. 8 -> 8.0 12 -> 12.0 14.54 -> 14.5 0 -> 0.0 Here is my code ws.Cells[row, col].Style.Numberformat.Format = \"##0.0\"; The final excel file always append E+0 to the end of this format and therefore presents the final values like this instead. 8 ->

Adding images into Excel using EPPlus

一曲冷凌霜 提交于 2019-11-26 09:04:34
问题 I am trying to add the same image multiple times into an excel file using EPPlus. I am using the following code to do so: Image logo = Image.FromFile(path); ExcelPackage package = new ExcelPackage(info); var ws = package.Workbook.Worksheets.Add(\"Test Page\"); for(int a = 0; a < 5; a++) { ws.Row(a*5).Height = 39.00D; var picture = ws.Drawings.AddPicture(a.ToString(), logo); picture.SetPosition(a*5, 0, 2, 0); } Everything works perfectly and all the images are correctly added but they are

C# create/modify/read .xlsx files

十年热恋 提交于 2019-11-26 05:38:53
问题 I am looking for a way to create, modify, read .xlsx files in C# without installing Excel or creating files on the server before giving to the user to download. I found NPOI http://npoi.codeplex.com/ which looks great but supports .xls not .xlsx I found ExcelPackage http://excelpackage.codeplex.com/ which looks great but has the additional overhead of creating the file on the server before it can be sent to the user. Does anyone know of a way around this? I found EPPlus http://epplus.codeplex

Export DataTable to Excel with EPPlus

落爺英雄遲暮 提交于 2019-11-26 04:12:56
问题 I want to export a data table to an Excel file with EPPlus. That data table has a property with int type, so I want the same format in the Excel file. Does anyone know way to export a DataTable like this to Excel? 回答1: using (ExcelPackage pck = new ExcelPackage(newFile)) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts"); ws.Cells["A1"].LoadFromDataTable(dataTable, true); pck.Save(); } That should do the trick for you. If your fields are defined as int EPPlus will properly cast the