[英]Add Text to Merged Cells In Excel Spreadsheet Using EPPlus
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? 有谁知道如何检查目录中是否有文件,然后如果没有,如何在合并单元格中的Excel电子表格中添加“找不到内容”文本?
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? 问题:如何使用EPplus在Excel电子表格中的合并单元格中添加文本? 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";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.