Fel*_*Soh 2 c# asp.net excel text 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"));
}
Run Code Online (Sandbox Code Playgroud)
问题:如何使用EPplus在excel电子表格中向合并单元格添加文本? 请帮帮我,谢谢!
你可以使用
ws.Cells["A1:A3"].Value = "content not found";
Run Code Online (Sandbox Code Playgroud)
要么
ws.Cells["A1"].Value = "content not found";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4277 次 |
| 最近记录: |