如何检查excel值是否格式化(粗体/斜体......)? C#有可能吗? [英] How to check whether excel values are formatted (bold/italic...)? C# Is it possible?

查看:122
本文介绍了如何检查excel值是否格式化(粗体/斜体......)? C#有可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查excel值是否格式化(粗体/斜体......)? C#



我想用实际的方式打开一个excel文件。我想显示从excel到grid的值。但如果excel值为粗体,则网格中的值应为粗体。

我该怎么做?



我如何阅读excel?如果我读到excel到数据表,我该如何检查值是否为bold \\ italic?





例如。

我有一个带有两列的excel文件。该excel中的一些值是粗体。其中一些是斜体。我想在Excel中将这些值添加到网格视图中。如果excel中的值为粗体,则网格中的值应为粗体。所以我想检查excel中的值是否是粗体。

如果我读取excel到datatable然后在gridview中显示将不会检查excel中该值的格式。在网格视图中将是一个纯文本。

How to check whether excel values are formatted (bold/italic...)? C#

I want to open one excel file pragmatically. I want to show that values from excel in to grid. But if excel values are bold, values in grid should be bold.
How can i do this?

How can i read excel ? If i read excel in to data table, how can i check whether values are bold\italic ?


For example.
I have one excel file with two columns.Some of the values in that excel are bold.Some of them are italic. I want to add these values in excel in to a grid view. If value in the excel is bold value in grid should be bold. So i want to check whether the value in excel is bold\italic.
If i read excel in to datatable then show in gridview will not check the format of that value in excel.In grid view it will a plain text.

推荐答案

你好Kavitha,



正如瑞安所说,你将不得不使用互操作以应用格式。

如果您使用Interop,则可以执行此操作

查看以下示例:

http://stackoverflow.com/questions/7401996/microsoft-interop-excel-formatting-cells [<一个href =http://stackoverflow.com/questions/7401996/microsoft-interop-excel-formatting-cellstarget =_ blanktitle =新窗口> ^ ]

在Excel中格式化列 [ ^ ]



问候,

Praneet
Hi Kavitha,

As Ryan said, you will have to use Interop to apply formatting.
And yes you can do this if you use Interop
Check out these examples:
http://stackoverflow.com/questions/7401996/microsoft-interop-excel-formatting-cells[^]
Formatting columns in Excel[^]

Regards,
Praneet

这篇关于如何检查excel值是否格式化(粗体/斜体......)? C#有可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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