使用Excel互操作更改特定文本的字体颜色 [英] Change font colour of specific text with Excel interop

查看:163
本文介绍了使用Excel互操作更改特定文本的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我似乎找不到使用interop在Excel中更改特定文本的字体颜色的任何信息.我知道如何更改整个范围的字体颜色,但是我想更改一个单元格中仅部分文本的字体颜色.换句话说,我要在一个单元格中使用两种不同的字体颜色.有人做过吗?

谢谢

Hi
I can''t seem to find any info on changing the font colour of specific text in Excel using interop. I know how to change the font colour of an entire range but I want to change the font colour of only part of the text in one cell. In other words I want two different font colours in one cell. Has anybody done this before?

Thanks

推荐答案

托马斯,

范围range = null;
range =(Range)objSheet.get_Range(objSheet.Cells [1,3],objSheet.Cells [3,3];
range.Interior.Color = System.Drawing.ColorTranslator.ToOle(Syste.Drawing.Color.Green);

将此代码添加到Excel导出中,为第3列的前3行的单元格上色.
[1,3]->行,列.
objSheet-> Excel工作表对象.

谢谢:)
Hi Thomas,

Range range=null;
range=(Range)objSheet.get_Range(objSheet.Cells[1,3],objSheet.Cells[3,3];
range.Interior.Color=System.Drawing.ColorTranslator.ToOle(Syste.Drawing.Color.Green);

Add this Code in your Excel Export.It''s color the cell for 3rd Column first 3 rows.
[1,3] --> row,column.
objSheet --> Excel Work Sheet Object.

Thanks :)


With ActiveCell.Characters(Start:=3, Length:=3).Font
    .Name = "Arial"
    .FontStyle = "Regular"
    .Size = 10
    .Color = "Red"
    .ThemeFont = xlThemeFontNone
End With


像这样吗?


Something like this?


您找到解决方案了吗?我也不会对我有帮助.
Did you found a solution? I''t would be helpful to me also.


这篇关于使用Excel互操作更改特定文本的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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