如题如果大家有写好的代码操作EXCEL的pas希望能共享下

解决方案 »

  1.   


    Excelid.worksheets[1].Range['A2:A2'].Font.Superscript := True; //上标
    Excelid.worksheets[1].Range['A2:A2'].Font.Subscript := True;  //下标
     
    With ActiveCell.Characters(Start:=1, Length:=1).Font
            .Name = "宋体"
            .FontStyle = "常规"
            .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:=2, Length:=1).Font
            .Name = "宋体"
            .FontStyle = "常规"
            .Size = 11
            .Strikethrough = False
            .Superscript = True
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontMinor
        End With
        With ActiveCell.Characters(Start:=3, Length:=1).Font
            .Name = "宋体"
            .FontStyle = "常规"
            .Size = 11
            .Strikethrough = False
            .Superscript = False
            .Subscript = True
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontMinor
        End With
    我录制了一段宏 ,关于With ActiveCell.Characters(Start:=3, Length:=1).Font 这怎么在DELPHI里面写?上面是设置整个单元的,我想实现的是设置单元格里一两个字符的为上下标
      

  2.   


     Start,   Length:   OleVariant;
       Start   :=   3;
       Length   :=   2;
       Excelid.ActiveCell.Characters[Start,   Length].Font.FontStyle   :=   'Bold';
       Excelid.worksheets[1].Range['A2:A2'].Characters[Start,Length].Font.Color  
       :=  clFuchsia;
       Excelid.worksheets[1].Range['A2:A2'].Characters[Start,Length].Font.Superscript 
       := True;