How to set cell color programmatically epplus?

Check your line: if (dtdata.Rows[4].ToString() == “Annual Leave”) If it is a standard .net table wouldnt .ToString() evaluate to “System.Data.DataRow”? Also ws.Cells[“E1”] will need to be adjusted for each cell after looping through the row count (basically what krillgar was saying). Something like that: [TestMethod] public void Cell_Color_Background_Test() { //http://stackoverflow.com/questions/28679602/how-to-set-cell-color-programmatically-epplus //Throw in some data var … Read more

Excel Date column returning INT using EPPlus

…when I need to read that excel file, the only dates that are incorrect are the ones the user has changed So when you read the modified excel-sheet, the modified dates are numbers whereas the unchanged values are strings in your date-format? You could get the DateTime via DateTime.FromOADate: long dateNum = long.Parse(worksheet.Cells[row, column].Value.ToString()); DateTime … Read more

Adding images into Excel using EPPlus

I’m not sure if this is the best solution but definetly a workaround for your problem. Here’s what I did: ExcelPackage package = new ExcelPackage(); var ws = package.Workbook.Worksheets.Add(“Test Page”); for (int a = 0; a < 5; a++) { ws.Row(a * 5).Height = 39.00D; } for (int a = 0; a < 5; a++) … Read more

Excel to DataTable using EPPlus – excel locked for editing

I see, that’s what I’ve posted recently here (now corrected). It can be improved since the ExcelPackage and the FileStream (from File.OpenRead) are not disposed after using. public static DataTable GetDataTableFromExcel(string path, bool hasHeader = true) { using (var pck = new OfficeOpenXml.ExcelPackage()) { using (var stream = File.OpenRead(path)) { pck.Load(stream); } var ws = … Read more

EPPlus: how can I assign border around each cell after I apply LoadFromCollection?

If I know the amount of columns the model has, I can count the number of rows with a function and do this: var modelRows = exportQuery.Count()+1; string modelRange = “D1:F” + modelRows.ToString(); var modelTable = worksheet.Cells[modelRange]; Or, with more context. I verified that EPPlus will accept a string variable in Cells[], which allows me … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)