does anyone know how do I check if there is any file in a directory, then if there isn't, how can I add text "content not found" onto the excel spreadsheet in merged cells?
This is what I have tried:
foreach (string subdir in filesindirectory)
{
string[] splitter = subdir.Split('\\');
string folderName = splitter[splitter.Length - 1];
ExcelWorksheet ws = package.Workbook.Worksheets.Add(folderName); //create new worksheet
ImageCount = 0;
foreach (string img in Directory.GetFiles(subdir))
{
if (subdir.Length == 0)
{
ws.Cells["A1:A3"].Merge = true;
ws.Cells["A1:A3"].Style.VerticalAlignment = ExcelVerticalAlignment.Top;
ws.Cells["A1:A3"].Style.Border.Top.Style = ExcelBorderStyle.Thin;
ws.Cells["A1:A3"].Style.Border.Left.Style = ExcelBorderStyle.Thin;
ws.Cells["A1:A3"].Style.Border.Right.Style = ExcelBorderStyle.Thin;
ws.Cells["A1:A3"].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
ws.Cells["A1:A3"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:A3"].Style.Fill.BackgroundColor.SetColor(System.Drawing.ColorTranslator.FromHtml("#f0f3f5"));
}
Question: How to add text to merged cell in excel spreadsheet using EPplus? Please help me on this, thanks!
You can either use
ws.Cells["A1:A3"].Value = "content not found";
or
ws.Cells["A1"].Value = "content not found";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.