epplus

EPPlus - copy worksheet from template to another excelpackage doesnt work (C#)

戏子无情 提交于 2019-12-24 17:28:11
问题 I'm having a DataSet filled with different DataTables SQL-Results. Some of the DataTables are connected with a Excel-Template-File. So in the end in want to have an excelfile with a mixture of new worksheets and copied worksheets from some template. That's why my code looks like this: public void CopyResultToExcelFileWithTemplate(DataSet sourceResult, string exportFilePath, string sourceName, string templateExcelFilePath, string sheetName = null) { var excelFile = new FileInfo(exportFilePath)

Set Gridline Color Using EPPlus?

让人想犯罪 __ 提交于 2019-12-24 13:41:44
问题 Is it possible to set a worksheet's gridline color using epplus? The "Gridline color" option I'm trying to set programmatically is shown in the screenshot below. 回答1: I dont see an option for it in EPPlus. Could manually set the attributes using xml: [TestMethod] public void Sheet_Gridline_Color_Test() { //http://stackoverflow.com/questions/29380587/set-gridline-color-using-epplus //Throw in some data var dtMain = new DataTable("tblData"); dtMain.Columns.Add(new DataColumn("Col1", typeof(int)

How to put two series with different types of charts inside a control chart using Epplus?

南楼画角 提交于 2019-12-24 11:19:11
问题 I am trying to combine two types of graphs into a single graphical chart using EPPLUS , I would appreciate if you could help me controller.cs public ActionResult ExportarExcel() { var myChart2 = ws.Drawings.AddChart("chart", eChartType.ColumnClustered); /*//Define las series para el cuadro var series = myChart.Series.Add("C7: E7", "C6: E6"); myChart.Border.Fill.Color = System.Drawing.Color.Green; myChart.Title.Text = "My Chart"; myChart.SetSize(500, 400); //Agregar a la 6ta fila y a la 6ta

WebApi using EPPlus excel file download - error on open - unreadable content - repair

纵然是瞬间 提交于 2019-12-24 04:58:00
问题 On my extjs webclient I hit a button and it downloads an excel template and populates data. When I click on the CHROME popup to open excel file, it gives me the excel error message below. Does anyone know how I can fix this? The actual file looks fine to me. Here is my webapi code public HttpResponseMessage CreatePosSheet(string cName, string calcMethod, string username, int cid, HttpRequestMessage Request) { string templatePath = HttpContext.Current.Server.MapPath(@"~\tempLocation\"); string

Creating an excel file with EPPlus, but it is always read-only

醉酒当歌 提交于 2019-12-23 17:57:42
问题 I'm creating/sending a file with EPPlus like this: using (ExcelPackage package = new ExcelPackage()) { ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Sheet"); ... //create file here Response.Clear(); Response.ContentType = "application/xlsx"; Response.AddHeader("content-disposition", "attachment; filename=" + filename + ".xlsx"); Response.BinaryWrite(package.GetAsByteArray()); Response.End(); } Everything works fine, except the file always comes back as read-only, and I can't

Headers for Excel worksheet using EPPlus

孤人 提交于 2019-12-23 11:24:12
问题 I am using EPPLus to create and format an excel sheet from my data set. I want to set headers on the excel sheet using EPPlus. I could not find a way to do it. I want to set the left header, right header and center header. I have done this using VBA code, but I wan to move away from that. In VBA I would just do With ActiveSheet.PageSetup .LeftHeader = "" .RightHeader ="" .CenterHeader= "" End With Help!! Thanks PS: I am creating a winforms application. I was not sure if that would change

Prompted to Save Changes on file created with EPPlus

不打扰是莪最后的温柔 提交于 2019-12-23 10:54:52
问题 I am creating a series of Excel Workbooks using EPPlus v3.1.3. When I open the newly created files, if I close it without touching anything it asks me if I want to save my changes. The only thing I've noticed changes if I say "yes" is that the app.xml file is slightly altered - there is no visible difference in the workbook, and the rest of the XML files are the same. I have tried both of these approaches: ExcelPackage p = new ExcelPackage(new FileInfo(filename)); p.Save(); as well as

EPPlus - AutoFitColumns() method fails when a column has merged cells

℡╲_俬逩灬. 提交于 2019-12-23 07:50:19
问题 I was wondering if anyone has come up with a workaround to this problem. I've noticed that the AutoFitColumns() method is failing on columns with merged cells. I've included a basic code example below: var cellRange = worksheet.Cells[1, column, 2, column]; cells.Merge = true; cells.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center; cells.Value = "Some Text Goes Here"; worksheet.Cells.AutoFitColumns(); The resulting worksheet will have the cells in rows 1 and 2

Can't write data to existing xlsx file

僤鯓⒐⒋嵵緔 提交于 2019-12-23 02:44:23
问题 I wrote this code below string filePath = @"C:\report_data.xlsx"; // Saves the file via a FileInfo var file = new FileInfo(filePath); // Creates the package and make sure you wrap it in a using statement using (var package = new ExcelPackage(file)) { // Adds a new worksheet to the empty workbook OfficeOpenXml.ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Report System - " + DateTime.Now.ToShortDateString()); // Starts to get data from database for (int row = 1; row < 10; row++)

Can't write data to existing xlsx file

与世无争的帅哥 提交于 2019-12-23 02:44:10
问题 I wrote this code below string filePath = @"C:\report_data.xlsx"; // Saves the file via a FileInfo var file = new FileInfo(filePath); // Creates the package and make sure you wrap it in a using statement using (var package = new ExcelPackage(file)) { // Adds a new worksheet to the empty workbook OfficeOpenXml.ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Report System - " + DateTime.Now.ToShortDateString()); // Starts to get data from database for (int row = 1; row < 10; row++)