?
Solved

How to know if an Excel cell has a rectangle inside an its background color using vb.net

Posted on 2011-02-11
8
Medium Priority
?
404 Views
Last Modified: 2012-05-11
Dear experts:
I'm using Microsoft.Office.Interop.Excel to read an Excel file with vb.net. There is no problem with text or formulas but how can I know if a cell has a rectangle inside and what is the color of that rectangle?
0
Comment
Question by:BemboX
[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
  • 5
  • 3
8 Comments
 
LVL 7

Expert Comment

by:dimaj
ID: 34876296
Try something like this:

"I got few experiences with Excel automation.
Let get back to the previous post and add this line.
Excel.Range range = ws.get_Range(ws.Cells[1,1],ws.Cells[1,2]);
range.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;"

Please note, this has been copied and pasted from this thread: http://bytes.com/topic/c-sharp/answers/252803-setting-excel-2003-borders-programmatically
0
 

Author Comment

by:BemboX
ID: 34888300
Thanks for your answer but the rectangle is inside the cell, this is not a border.
0
 
LVL 7

Expert Comment

by:dimaj
ID: 34891995
so, that rectangle is an embedded image?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:BemboX
ID: 34892487
I think it was created as a form (insert/form). I am attaching an example of an excel file with rectangles. Rectangles.xls
0
 
LVL 7

Expert Comment

by:dimaj
ID: 34892853
Thanks for that...

by the looks of it, that rectangle is not part of the cell... What you'll need to do is the following:
1) Get list of all objects on the worksheet
2) find the cell of interest and try to get that cell's coordinates
3) Loop through the list of your rectangles and see if a coordinate falls in a cell of interest.

If I'll find some code, I'll post it, but I hope this will at least give you some idea of where to start looking from.
0
 
LVL 7

Accepted Solution

by:
dimaj earned 2000 total points
ID: 34892961
0
 

Author Comment

by:BemboX
ID: 34893055
Thanks for your answer, that code is helpful.
0
 
LVL 7

Expert Comment

by:dimaj
ID: 34893066
Glad to help :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

770 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