以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]统计表导出并生成图表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=84606) |
||||||||
-- 作者:cqlpjks -- 发布时间:2016/5/5 16:01:00 -- [求助]统计表导出并生成图表
请教:1.在条形图上同时显示“总分”和“类别” 2.导出表时只导出了一个表“总分2015级三诊高文部分优生对照表”,还有一个表“总分2015级三诊高理部分优生对照表”没导出来。 怎么修改代码,请指教。谢谢! |
||||||||
-- 作者:大红袍 -- 发布时间:2016/5/5 16:05:00 -- 哪个窗口哪个按钮怎么测试啊。 |
||||||||
-- 作者:大红袍 -- 发布时间:2016/5/5 16:38:00 -- Dim bbs() As String = {"高文","高理"} Dim tjnj As String = e.Form.Controls("年级").text \'统计年级 Dim tjlb As String = e.Form.Controls("类别").text \'统计类别 For Each bb As String In bbs \'生成Excel报表 Dim b As New XLS.Book Dim t As Table = Tables("总分" & tjnj & "级" & tjlb & bb & "部分优生对照表") Dim s As XLS.Sheet = b.Sheets(0) For c As Integer = 0 To t.Cols.Count -1 \'添加列标题 s(0, c).Value = t.Cols(c).Name Next For r As Integer = 0 To t.Rows.Count - 1 \'填入数据 For c As Integer = 0 To t.Cols.Count -1 s(r +1, c).Value = t.rows(r)(c) Next Next \'生成图表 Dim Chart As WinForm.Chart = e.Form.Controls("Chart1") Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart.ChartType = ChartTypeEnum.Bar \'图表类型改为Bar(条形) Chart.SeriesList.Clear() \'清除图表原来的图系 Chart.AxisX.ClearValueLabel Chart.BarClusterWidth = 80 Dim xms As List(of String) = t.DataTable.GetValues("姓名") For Each lb As String In t.DataTable.GetValues("类别") Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = lb \'设置图系的标题 Dim drs As List(Of DataRow) = t.DataTable.Select("") Series.Length = xms.Count For r As Integer = 0 To xms.count-1 Series.X(r) = r Series.Y(r) = val(t.compute("sum(总分)", "姓名 = \'" & xms(r) & "\' and 类别 = \'" & lb & "\'")) Chart.AxisX.SetValueLabel(r, xms(r)) \'指定字符表示 Next series.DataLabelCompass = LabelCompassEnum.North Series.DataLabelText = "{#YVAL}" Next Chart.AxisX.AnnoWithLabels = True \'启用字符标示 Chart.AxisX.AnnoRotation = - 45 \'X轴标示逆时针旋转45度 chart.SeriesList(0).MarkSize= 1 \'设置数据点标记的大小 Chart.LegendVisible = True \'显示图列 Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端) Chart.AxisX.Text = "姓名" Chart.AxisY.Text = "总分" Chart.PrintWidth = 300 Chart.PrintHeight = 150 s(t.rows.Count + 2,1).Value = New XLS.Picture(Chart.Image) b.Save("d:\\期末考试文件\\" & t.name & ".xls") Dim Proc As New Process Proc.File = "d:\\期末考试文件\\" & t.name & ".xls" Proc.Start() Next |
||||||||
-- 作者:cqlpjks -- 发布时间:2016/5/5 17:20:00 -- 谢谢! |
||||||||
-- 作者:cqlpjks -- 发布时间:2016/5/6 11:51:00 -- 请教:纵坐标的起始值能否从表中的最小值开始,间距值为20?那样要清楚些。谢谢! [此贴子已经被作者于2016/5/6 11:53:57编辑过]
|
||||||||
-- 作者:大红袍 -- 发布时间:2016/5/6 12:01:00 -- 参考
http://www.foxtable.com/help/topics/1016.htm
http://www.foxtable.com/help/topics/1018.htm |
||||||||
-- 作者:cqlpjks -- 发布时间:2016/5/6 15:19:00 -- 没有具体的值,根据“总分”列的最大值和最小值来自动确定。 怎么修改代码:Chart.AxisY.Min = 400 \'指定Y轴的最小值 Chart.AxisY.Max = 700 \'指定Y轴的最大值。请指教。谢谢! |
||||||||
-- 作者:大红袍 -- 发布时间:2016/5/6 15:21:00 -- compute 统计max,min
http://www.foxtable.com/help/topics/0548.htm
|
||||||||
-- 作者:cqlpjks -- 发布时间:2016/5/6 15:31:00 -- 谢谢! |
||||||||
-- 作者:cqlpjks -- 发布时间:2016/5/6 17:43:00 -- 导出后不能自成图表,不知怎么修改代码?请指教!谢谢!
Dim bbs() As String = {"高文","高理"} |