[英]Add Text to Merged Cells In Excel Spreadsheet Using EPPlus
有誰知道如何檢查目錄中是否有文件,然后如果沒有,如何在合並單元格中的Excel電子表格中添加“找不到內容”文本?
這是我嘗試過的:
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"));
}
問題:如何使用EPplus在Excel電子表格中的合並單元格中添加文本? 請幫助我,謝謝!
您可以使用
ws.Cells["A1:A3"].Value = "content not found";
要么
ws.Cells["A1"].Value = "content not found";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.