直接使用表单数据作为数据源创建图表
问题描述:使用表单中的单元格数据作为数据源,直接生成图表。问题解答:Sheetview 下提供了AddChart方法用于使用指定范围单元格作为数据源添加图表。
关键代码:
privatevoid AddChart()
{
fpSpread1.Sheets.Cells.Value = "c1";
fpSpread1.Sheets.Cells.Value = "c2";
fpSpread1.Sheets.Cells.Value = "c3";
fpSpread1.Sheets.Cells.Value = "s1";
fpSpread1.Sheets.Cells.Value = "s2";
fpSpread1.Sheets.Cells.Value = "s3";
fpSpread1.Sheets.Cells.Value = "s4";
fpSpread1.Sheets.Cells.Value = "s5";
fpSpread1.Sheets.Cells.Value = "s6";
fpSpread1.Sheets.Cells.Value = 1;
fpSpread1.Sheets.Cells.Value = 2;
fpSpread1.Sheets.Cells.Value = 3;
fpSpread1.Sheets.Cells.Value = 4;
fpSpread1.Sheets.Cells.Value = 5;
fpSpread1.Sheets.Cells.Value = 6;
fpSpread1.Sheets.Cells.Value = 7;
fpSpread1.Sheets.Cells.Value = 8;
fpSpread1.Sheets.Cells.Value = 9;
fpSpread1.Sheets.Cells.Value = 10;
fpSpread1.Sheets.Cells.Value = 11;
fpSpread1.Sheets.Cells.Value = 12;
fpSpread1.Sheets.Cells.Value = 13;
fpSpread1.Sheets.Cells.Value = 14;
fpSpread1.Sheets.Cells.Value = 15;
fpSpread1.Sheets.Cells.Value = 16;
fpSpread1.Sheets.Cells.Value = 17;
fpSpread1.Sheets.Cells.Value = 18;
FarPoint.Win.Spread.Model.CellRange range = new FarPoint.Win.Spread.Model.CellRange(0, 0, 7, 4);
fpSpread1.Sheets.AddChart(range, typeof(FarPoint.Win.Chart.BarSeries), 400, 300, 0, 0, FarPoint.Win.Chart.ChartViewType.View3D, false);
}
?
效果截图:
示例下载:点击下载
页:
[1]