?
Solved

excel borders drawing problem

Posted on 2003-02-19
3
Medium Priority
?
966 Views
Last Modified: 2007-12-19
i wrote a c# code that create an excel sheet and transfer data from a DataView object into it,
my problem is how can draw borders (all borders) around a range on the sheet?
i use the follow code:
m_objRange.Borders(xlDiagonalDown).LineStyle = xlNone
m_objRange.Borders(xlDiagonalUp).LineStyle = xlNone
m_objRange.Borders(xlEdgeLeft)
m_objRange.Borders.LineStyle = xlContinuous
m_objRange.Borders.Weight = xlThin
m_objRange.Borders.ColorIndex = xlAutomatic
(m_objRange is a Excel.Range object pointing on the relevant range)
but i got a compilation error said:
'Excel.Range.Borders' denotes a 'property' where a 'method' was expected.
what do u think about it???

another problem is how can i hide the existing borders that apears on the rest of the sheet?

if u can send me a samle code it will be great (a c# code)

thank's
 
0
Comment
Question by:stanley_123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
Nebulus_ earned 400 total points
ID: 8040223
I hope this will help you:
(comments represents VBA code)

//Range("G7:J10").Select
Excel.Range sel =  exSheet.get_Range(exSheet.Cells[7,7], exSheet.Cells[10,10]);
sel.Select();
//Selection.Borders(xlDiagonalDown).LineStyle = xlNone
sel.Borders[Excel.XlBordersIndex.xlDiagonalDown].LineStyle = Excel.Constants.xlNone;
//Selection.Borders(xlDiagonalUp).LineStyle = xlNone
sel.Borders[Excel.XlBordersIndex.xlDiagonalUp].LineStyle = Excel.Constants.xlNone;
//With Selection.Borders(xlEdgeLeft)
//          .LineStyle = xlContinuous
//          .Weight = xlMedium
//          .ColorIndex = xlAutomatic
//End With
sel.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous;
sel.Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight = Excel.XlBorderWeight.xlMedium;
sel.Borders[Excel.XlBordersIndex.xlEdgeLeft].ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
//With Selection.Borders(xlEdgeTop)
//          .LineStyle = xlContinuous
//          .Weight = xlMedium
//          .ColorIndex = xlAutomatic
//End With
sel.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous;
sel.Borders[Excel.XlBordersIndex.xlEdgeTop].Weight = Excel.XlBorderWeight.xlMedium;
sel.Borders[Excel.XlBordersIndex.xlEdgeTop].ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
//With Selection.Borders(xlEdgeBottom)
//          .LineStyle = xlContinuous
//          .Weight = xlMedium
//          .ColorIndex = xlAutomatic
//End With
sel.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Excel.XlLineStyle.xlContinuous;
sel.Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlMedium;
sel.Borders[Excel.XlBordersIndex.xlEdgeBottom].ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
//With Selection.Borders(xlEdgeRight)
//          .LineStyle = xlContinuous
//          .Weight = xlMedium
//          .ColorIndex = xlAutomatic
//End With
sel.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = Excel.XlLineStyle.xlContinuous;
sel.Borders[Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlMedium;
sel.Borders[Excel.XlBordersIndex.xlEdgeRight].ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
//Selection.Borders(xlInsideVertical).LineStyle = xlNone
sel.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.Constants.xlNone;
//Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
sel.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.Constants.xlNone;
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question