发现在Excel工作表粗体文本使用C# [英] find bold text in excel sheet using C#

查看:169
本文介绍了发现在Excel工作表粗体文本使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到里面的Excel工作表的单元格粗体文字?我使用C#,OLEDB和ADO.NET读取xls文件,但我不解决怎么解决我的任务。我是否需要使用Iterop.Excel?

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?

推荐答案

是的,你需要Interop.Excel

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;
}

这篇关于发现在Excel工作表粗体文本使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆