使用C#在excel中设置行边框 [英] Set row border in excel using C#
本文介绍了使用C#在excel中设置行边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我为每行设置边框的代码。
this is my code for set the border for each row.
Excel.Range BorderRAnge;
BorderRAnge = xlsheet.get_Range("A","E");
BorderRAnge.Font.Bold = true;
BorderRAnge.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlMedium, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic);
当我运行错误时显示如下;
无法隐式转换类型''Microsoft.Office.Interop.Excel.Range ''到''Excel.Range''。存在显式转换(您是否错过了演员表?)
上述错误显示在BorderRAnge = xlsheet.get_Range(A,E)中; (这一行)。
请帮帮我。我的代码中有什么错误。我试过但它没有用。
when i run error shows as follows;
Cannot implicitly convert type ''Microsoft.Office.Interop.Excel.Range'' to ''Excel.Range''. An explicit conversion exists (are you missing a cast?)
the above error shows in BorderRAnge = xlsheet.get_Range("A","E"); (this line).
please help me. what is the mistake in my code. i tried but it is not working.
推荐答案
尝试单独设置边框,如下所示
try to set border individually like below
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeBottom]
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeRight]
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeLeft]
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeTop]
希望这有帮助
hope this helps
这篇关于使用C#在excel中设置行边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文