Click here to Skip to main content
15,905,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i try Export DataGridView data in Excel but problem is when i Export data in excel file first column font color by default white Color then i use this code

wb.Worksheet(1).Cells("A1:N1").Style.Font.FontColor = XLColor.Black;

but this not Work

What I have tried:

but When i Try and Change Color Black to other it's work Fine
like
wb.Worksheet(1).Cells("A1:N1").Style.Font.FontColor = XLColor.Red;
Posted
Updated 12-Jun-20 3:34am
Comments
CHill60 12-Jun-20 9:26am    
What are you using to export to Excel?
Amar chand123 12-Jun-20 9:31am    
Using ClosedXML.Excel;

1 solution

Ok, I'm seeing some reports that this is a bug in Excel. You can check this by opening the file in Excel and trying to set the font colour manual using Colors, Color Model = RGB, Red =0, Green = 0, Blue = 0. You should find that your text becomes 100% transparent.

To get around this you could try setting your text to "almost" black RGB = (1,1,1) or #FF010101

Main credit [^]
 
Share this answer
 
Comments
Amar chand123 12-Jun-20 9:43am    
Thank you sir and sorry but can you solve in closexml my first column show filters i want remove
CHill60 12-Jun-20 10:58am    
The link I posted was to the CloseXML troubleshooting site - apparently the following will work in ClosedXML
wb.Worksheet(1).Cells("A1:N1").Style.Font.FontColor = XLColor.FromHtml("#FF010101"); 

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