CreateSolidFill removes my Borders. How to keep them ?

1 Answer 84 Views
Spreadsheet
Ian
Top achievements
Rank 2
Bronze
Iron
Iron
Ian asked on 27 Apr 2023, 10:26 AM

I'm using PatternFill.CreateSolidFill to add colors to some of my spreadsheet cells, and it works fine.

But when I come to reset those colors back to 'normal' , their borders have gone:

Here, I apply the fill to some cells, but want to reset the color where the formatting rules does not apply. I am applying a solid fill, like:

PatternFill.CreateSolidFill(ThemableColor.FromArgb(255, 255, 255, 255))

..but this is where the border goes away.

How should I reset the border as well as the original color ?

Thanks

1 Answer, 1 is accepted

Sort by
0
Nikolay Demirev
Telerik team
answered on 28 Apr 2023, 01:41 PM

Hi Ian,

The borders you see are the gridlines. They are just a UI feature so the person creating the sheet can see the cells. If, for example, you try to print it, there will be no borders. So if you set fill to the cells, the fill goes over the gridlines. It is the same with Excel.

By default, the cells don't even have a background, so if you set any background color, it goes over the gridlines and hides them. So if you want to remove the background, you have to clear the background property of those cells. Here is an example: 

worksheet.Cells[5, 5].ClearFill();

If you want a white background and still have gridlines, then you have to set the cell borders, but printing the document will also have the borders.

 

Regards,
Nikolay Demirev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ian
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 03 May 2023, 08:11 AM

Perfect!

Thanks

Tags
Spreadsheet
Asked by
Ian
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Nikolay Demirev
Telerik team
Share this question
or