Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to capture Excel cell borders properly?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. CO+1 This could really use to be explained better but this is actually a good question. This is what I understand: Open up Excel, put a bottom border on cell A1. Format-paint A1 to somewhere and you get a bottom border. Format-paint A2 to somewhere and you get no border. If you press Ctrl+1 on cell A1, you see the bottom border as you expect. BUT do the same on cell A2 and *you see a top border*!? This is what I assume the OP is seeing from code as well. So what is Format Painter doing differently?
      singulars
    2. COYou got it, I am trying to mock this behavior of Format Painter, But in my code when I capture cell A2 and apply it somewhere it shows TOP border which is not as per native behaviour. In C# code when I do selection.Borders[xl.XlBordersIndex.xlEdgeTop].LineStyle it still gives me XlLineStyle.xlContinuous which it should because cell A2 does not have a TOP border whereas cell A1 has a BOTTOM border.
      singulars
    3. COThis is a fascinating question! +1. If with VBA you set the bottom border of C2, the right border of B3, the left border of D3 and the top border of C4 to double, you will get a properly formatted double border around C3. Using Format Painter, I can copy C2 and its bottom border to another cell. If I then set the top border of C3 to single and use Format Painter to copy C2 again, it has lost its bottom border. I have always accepted that there is a single edge between C2 and C3 like on a sheet of squared paper and it did not matter how it was set.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload