tags:

views:

39

answers:

1

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?

+2  A: 

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
thank you very much! you helped me a lot. i can check now the whole cell text for boldnessRange test;bool isBold = (bool)test.Font.Bold;
throbbing salami