Multiple Formats in one cell using c#

后端 未结 3 810
既然无缘
既然无缘 2021-01-14 01:53

I want to have mutple format types in one cell in my workbook. For example I want my A1 cell to display \" Name: Aaron Kruger \". When I programmatically

3条回答
  •  鱼传尺愫
    2021-01-14 02:08

    I recorded a macro, it shouldn't be hard to translate it to C#:

    ActiveCell.FormulaR1C1 = "Test test"
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Test test"
    With ActiveCell.Characters(Start:=1, Length:=5).Font
        .Name = "Calibri"
        .FontStyle = "Regular"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With ActiveCell.Characters(Start:=6, Length:=4).Font
        .Name = "Calibri"
        .FontStyle = "Bold"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    

提交回复
热议问题