请问,如果选中Excel的一个区域,用C#怎么才能让区域整体的外边框编程红色(不是单元格的边框颜色),在线等!!

解决方案 »

  1.   

         
                Microsoft.Office.Interop.Excel.Range c = myExcel.get_Range(cell1, cell2);
                c.Borders.ColorIndex = 3;
                
                c.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                c.Borders.Weight = 2;
      

  2.   

    我试了下,这个Range的borders设置的是单元格。我想实现一个整体选中区域的四个边框变色,里面单元格的颜色不变,这么说您清楚吗?
      

  3.   

    GDI+不好用啊,谁会实现这个功能?
      

  4.   

    一个简单的办法,录制宏,进行你所需要的操作,然后去看VBA的代码
    Microsoft.Office.Interop.Excel.Range c= myExcel.get_Range(cell1, cell2).Borders(xlEdgeLeft); 
                c.Borders.ColorIndex=3; 
                
                c.Borders.LineStyle= Microsoft.Office.Int;Microsoft.Office.Interop.Excel.Range c= myExcel.get_Range(cell1, cell2).Borders(xlEdgeTop); 
                c.Borders.ColorIndex=3; 
                
                c.Borders.LineStyle= Microsoft.Office.Int;Microsoft.Office.Interop.Excel.Range c= myExcel.get_Range(cell1, cell2).Borders(xlEdgeBottom); 
                c.Borders.ColorIndex=3; 
                
                c.Borders.LineStyle= Microsoft.Office.Int;Microsoft.Office.Interop.Excel.Range c= myExcel.get_Range(cell1, cell2).Borders(xlEdgeRight); 
                c.Borders.ColorIndex=3; 
                
                c.Borders.LineStyle= Microsoft.Office.Int
    刚录制了下宏,C#应该是上面的代码,没在VS环境里写,可能有错误