Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
图示数据导出EXCEL代码
窗口事件
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim tbl As DataTable = DataTables("总览") '定义一个变量tbl引用数据表
Dim lst As List(Of String) = tbl.GetUniqueValues("", "乡名") '获得产品名称集合
Chart= Forms("窗口1").Controls("Chart1") ' 引用窗口中的图表
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = lst.Count '设置图系的长度
For i As integer = 0 to lst.Count - 1 '指定每个数据点的位置
Series.X(i) = i '指定水平坐标
Series.Y(i) = tbl.Compute("Sum(设计面积)","[乡名] = '" & lst(i) & "'") '指定垂直坐标
Series.TooltipText = "X = {#XVAL}, Y = {#YVAL}"
Chart.AxisX.SetValueLabel(i, lst(i)) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart = Forms("窗口1").Controls("Chart2") '引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.SeriesList.Clear() '清除图表原来的图系
Dim SeriesText() As String = { "退耕地", "荒山","生态林","经济林" }
For n As Integer = 0 To 3
Series = Chart.SeriesList.Add() '增加一个图系
Series.Text = SeriesText(n) '设置图系的标题
Series.Length = lst.Count '设置图系的长度
For i As Integer = 0 To lst.Count - 1
Series.X(i) = i
Series.Y(i) = tbl.Compute("Sum(" & SeriesText(n) & ")","[乡名] = '" & lst(i) & "'")
Next
Next
For i As Integer = 0 to lst.Count - 1
Chart.AxisX.SetValueLabel(i, lst(i)) '指定字符表示
Next
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
Chart.BarClusterWidth = 80
顶
图示数据搞的很漂亮喔!