无法使用c#以编程方式更改Excel图表条颜色(不是单元格颜色) [英] Cannot change excel chart bars color(not cell color) programatically using c#

查看:101
本文介绍了无法使用c#以编程方式更改Excel图表条颜色(不是单元格颜色)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到任何资源帮助我改变excel图表栏的颜色,因为每个栏颜色会给用户更多视觉效果的这个栏的状态。

示例:
< br> excel细胞

A B
Case1 70%
Case2 10%
----------------------- ------

基于每种情况的值我想设置图表栏颜色的相关值。

case1吧颜色应该是(绿色),因为它高于50 %
case2条形颜色应该是(红色)因为它低于50%

..........我知道我怎么能从excel它自己做.....
但是我需要在运行时这样做,因为我在c#应用程序中渲染这个excel表。这是与"xlarea"相关的东西。 ??

thanx


Ahmed

I didn't find any resource helps me to change the color of excel chart bar as each bar color will give the user more visual effects of the status of this bar.

Example:

excel cells

A            B
Case1    70%
Case2    10% 
-----------------------------

based on the value for each case i want to set the chart bar color of related value.

case1 bar color should be (green) as it is above 50%
case2 bar color should be (red) as it is under 50%

..........I know how i can do it from excel it self.....
But i need to do this in runtime as i'm rendering this excel sheet in c# application.
is it something related to "xlarea" ??

thanx


Ahmed

推荐答案

希望你必须得到你的答案现在问题:)无论如何以下是其中一个解决方案:

选择纸张单元格的范围


Microsoft.Office.Interop.Excel。

Hope you must have got the answer to your question by now :) anyway following is one of the solution:

Select the range of the cells of the sheet

Microsoft.Office.Interop.Excel.

范围 range = worksheet.get_Range( 字符串 。格式( " A {0}" ,x.ToString()), 。格式( " D {0}" ,x.ToString()));

更改颜色


range.Interior.ColorIndex = 1 //选择你的数字选择

类似于border

range.Borders.ColorIndex = 2;

这是针对您选择的范围。对于特定的细胞做一些研究。

Range range = worksheet.get_Range(string.Format("A{0}",x.ToString()), string.Format("D{0}",x.ToString()));

To change color

range.Interior.ColorIndex = 1 //Choose ur choice of number

Similar for border

range.Borders.ColorIndex = 2;

This is for the range you have selected. For particular cell do some research on it.


这篇关于无法使用c#以编程方式更改Excel图表条颜色(不是单元格颜色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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