怎样用c#操作excel里的chart对象,如增加一个饼图?

chensan 2003-10-27 09:37:03
怎样用c#操作excel里的chart对象,如增加一个饼图?
搜遍了msdn & csdn,还没有答案。
...全文
470 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
eliphe 2004-01-16
  • 打赏
  • 举报
回复
用HSkyXChart Web统计图表2.8版本,附带asp、C#、VB.Net完整演示实例.

下载地址:http://www.skyec.com/U_View_cpxz_detail.asp?ProductID=8

有完整演示程序,效果图和接口说明

可以生成柱型图,横柱型图,折线图,饼图,点图,区域图,雷达图
chensan 2003-10-29
  • 打赏
  • 举报
回复
谢谢rottenapple(烂苹果) ,有没有更多的资料啊,如何设置标题,图例等???
chensan 2003-10-29
  • 打赏
  • 举报
回复
还有哪位大侠指点指点,谢谢。
libinghome 2003-10-28
  • 打赏
  • 举报
回复
y
siao 2003-10-27
  • 打赏
  • 举报
回复
先在excel里面编宏,然后读它的vb的代码,找到对应的c#里面的类型和方法,一般名字很相近的,这样你就不用问别人了
chensan 2003-10-27
  • 打赏
  • 举报
回复
Thanks for 楼上的.
Find something in google.

Excel excel = new Excel();
Worksheet sheet = excel.Worksheets[0];

Cells cells = sheet.Cells;
cells[0,1].PutValue("Income");
cells[1,0].PutValue("Company A");
cells[2,0].PutValue("Company B");
cells[3,0].PutValue("Company C");
cells[1,1].PutValue(10000);
cells[2,1].PutValue(20000);
cells[3,1].PutValue(30000);

int chartIndex = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15);

Chart chart = sheet.Charts[chartIndex];
chart.NSeries.Add("B2:B4", true);
chart.NSeries.CategoryData = "A2:A4";

ASeries aSeries = chart.NSeries[0];
aSeries.Name = "=B1";
chart.IsLegendShown = true;
chart.Title.Text = "Income Analysis";
zkjbeyond 2003-10-27
  • 打赏
  • 举报
回复
GZ楼上能不能详细点啊!
rottenapple 2003-10-27
  • 打赏
  • 举报
回复
public void CreateChart()
{
Excel.Worksheet thisWorksheet;
thisWorksheet = thisWorkbook.ActiveSheet as Excel.Worksheet;
Excel.ChartObjects charts =
(Excel.ChartObjects)thisWorksheet.ChartObjects(Type.Missing);

// Adds a chart at x = 100, y = 300, 500 points wide and 300 tall.
Excel.ChartObject chartObj = charts.Add(100, 300, 500, 300);
Excel.Chart chart = chartObj.Chart;

// Gets the cells that define the bounds of the data to be charted.
Excel.Range chartRange = thisWorksheet.get_Range("A5","D8");
chart.SetSourceData(chartRange,Type.Missing);

chart.ChartType = Excel.XlChartType.xlXYScatter;
Excel.SeriesCollection seriesCollection=
(Excel.SeriesCollection)chart.SeriesCollection(Type.Missing);
Excel.Series series = seriesCollection.Item(seriesCollection.Count);
}

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧