Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);

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.
Posted
Updated 14-Jun-20 6:42am
v3
Comments
CHill60 5-Feb-13 5:15am    
what's your declaration of "Excel" and "xlsheet"?
Zoltán Zörgő 5-Feb-13 5:46am    
Repost on: http://www.codeproject.com/Answers/540513/howplustoplussetplusborderplusinplusexcelplusforpl
What is with that one? Don't you think it is rude not reacting to the answers?

1 solution

try to set border individually like below
C#
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeBottom]
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeRight]
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeLeft]
BorderRAnge.Borders[Excel.XlBordersIndex.xlEdgeTop]


hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900