Sub Macro1()
'
' Macro1 Macro
''
    Range("G22:J22").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    With Selection.Borders(xlDiagonalUp)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End Sub
这是一个excel中画斜线的代码,希望哪个大虾帮忙转成C#代码!  

解决方案 »

  1.   

    http://social.msdn.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/4183926b-765b-4ceb-90d3-d8128a349c08/
      

  2.   

    public void Macro1()
    {
    //
    // Macro1 Macro
    // //
    Range("G22:J22").Select();
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone;
    var _with1 = Selection.Borders(xlDiagonalUp);
    _with1.LineStyle = xlContinuous;
    _with1.ColorIndex = 0;
    _with1.TintAndShade = 0;
    _with1.Weight = xlThin;
    var _with2 = Selection.Borders(xlEdgeLeft);
    _with2.LineStyle = xlContinuous;
    _with2.ColorIndex = 0;
    _with2.TintAndShade = 0;
    _with2.Weight = xlThin;
    var _with3 = Selection.Borders(xlEdgeTop);
    _with3.LineStyle = xlContinuous;
    _with3.ColorIndex = 0;
    _with3.TintAndShade = 0;
    _with3.Weight = xlThin;
    var _with4 = Selection.Borders(xlEdgeBottom);
    _with4.LineStyle = xlContinuous;
    _with4.ColorIndex = 0;
    _with4.TintAndShade = 0;
    _with4.Weight = xlThin;
    var _with5 = Selection.Borders(xlEdgeRight);
    _with5.LineStyle = xlContinuous;
    _with5.ColorIndex = 0;
    _with5.TintAndShade = 0;
    _with5.Weight = xlMedium;
    Selection.Borders(xlInsideVertical).LineStyle = xlNone;
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone;
    }
      

  3.   

    http://www.developerfusion.com/tools/convert/vb-to-csharp/
    好东西呀