How to find bold text inside cells of Excel sheet? I'm using C#, OLEDB and ADO.NET for reading xls file, but I don't resolve how to resolve my task. Do I need to use Iterop.Excel?
Asked
Active
Viewed 3,698 times
1 Answers
7
Yes, you will need Interop.Excel
using Microsoft.Office.Interop.Excel;
int FindFirstBold(Range cell)
{
for (int index = 1; index <= cell.Text.ToString().Length; index++)
{
Characters ch = cell.get_Characters(index, 1);
bool bold = (bool) ch.Font.Bold;
if(bold) return index;
}
return 0;
}

volody
- 6,946
- 3
- 42
- 54
-
thank you very much! you helped me a lot. i can check now the whole cell text for boldness Range test; bool isBold = (bool)test.Font.Bold; – desperate man Jun 26 '10 at 09:31
-
nice answer, I don't suppose you know much about detecting cells containing pivot tables using interop? I have asked a question here: http://stackoverflow.com/questions/35623752/detect-pivot-table-in-microsoft-excel-using-interop-c-sharp – Alex Feb 25 '16 at 14:37