【问题标题】:How can I add formatting within a cell that only applies to part of the cell value using EPPlus?如何使用 EPPlus 在仅适用于部分单元格值的单元格中添加格式?
【发布时间】:2016-09-29 20:58:56
【问题描述】:

我知道如何在 EPPlus 中格式化单元格值,但前提是该格式适用于整个值。如何添加仅适用于单元格值的部分的格式?

例如...

【问题讨论】:

标签: epplus


【解决方案1】:

使用RichText 集合来构建它:

using (var pck = new ExcelPackage())
{
    var wb = pck.Workbook;
    var ws = wb.Worksheets.First();

    var cell = ws.Cells["B2"];
    cell.RichText.Add("This is some ");
    cell.RichText.Add("formatting");
    cell.RichText.Add(" withing a value");

    cell.RichText[1].Color = Color.Red;
    cell.RichText[1].Size = 14;

    pck.Save();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 2017-11-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-04
    相关资源
    最近更新 更多