gpt4 book ai didi

c# - 使用 C# 在 Excel 工作表中查找粗体文本

转载 作者:行者123 更新时间:2023-11-30 20:11:57 25 4
gpt4 key购买 nike

如何在 Excel 工作表的单元格内找到粗体文本?我正在使用 C#、OLEDB 和 ADO.NET 读取 xls 文件,但我没有解决如何解决我的任务。我需要使用 Iterop.Excel 吗?

最佳答案

是的,您将需要 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;
}

关于c# - 使用 C# 在 Excel 工作表中查找粗体文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3122741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com