以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 统计表导出并生成图表问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=176529) |
||||
-- 作者:cqlpjks -- 发布时间:2022/4/16 14:53:00 -- 统计表导出并生成图表问题 原统计表: 此主题相关图片如下:原统计表.png 怎么导出后箭头处缺了“二诊”2字? 导出并生成图表代码: Dim tjnj As String = e.Form.Controls("年级").text \'统计年级 Dim tjlb As String = e.Form.Controls("类别").text \'统计类别 Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "Excel文件|*.xls" \'设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 \'生成图表 Dim Chart As new ChartBuilder \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Dim t As Table = Tables(tjnj &"级"& tjlb & "市区目标对比") \'定义一个变量t引用数据表 Chart.ChartType = ChartTypeEnum.Bar \'图表类型改为Bar(条形) Chart.SeriesList.Clear() \'清除图表原来的图系 Dim xms() As String = {"全区合计","梁平中学","红旗中学","梁平一中","西大实中","屏锦中学","袁驿中学","福禄中学"} For Each xm As String In xms Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = xm \'设置图系的标题 series.length = t.Cols.count-2 For r As Integer = 0 To t.Cols.count-4 \'横坐标开始行位置 Series.X(r) = r Series.Y(r) = val(t.Compute("sum(" & t.Cols(r+3).name & ")", "单位 = \'" & xm & "\'")) \'横坐标开始列位置 Chart.AxisX.SetValueLabel(r, t.Cols(r+3).caption) \'指定字符表示 Next series.DataLabelCompass = LabelCompassEnum.North Series.DataLabelText = "{#YVAL}" Next series.DataLabelCompass = LabelCompassEnum.North Series.DataLabelText = "{#YVAL}" Chart.AxisX.AnnoWithLabels = True \'启用字符标示 Chart.AxisX.AnnoRotation = - 45 \'X轴标示逆时针旋转45度 Chart.LegendVisible = True \'显示图列 Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端) Chart.AxisX.Text = "统计项目" Chart.AxisY.Text = "重点人数" chart.LegendText = "图例:单位" Chart.BarClusterWidth = 80 \'力列宽窄 Chart.PrintWidth = 300 \'图表长 Chart.PrintHeight = 180 \'图表高 \'保存文件 t.SaveExcel(dlg.FileName, tjnj &"级"& tjlb & "市区目标对比") \'保存文件 Dim b As New XLS.Book(dlg.FileName) Dim s As XLS.Sheet = b.Sheets(tjnj &"级"& tjlb & "市区目标对比") s(t.rows.Count + 2,1).Value = New XLS.Picture(Chart.Image) Dim Style As Xls.Style = b.NewStyle \'新建一个样式 \'单元格内容自动换行 Style.WordWrap = XLS.LineStyleEnum.Thin \'单元格内容自动换行 \'加网格线 Style.AlignHorz = XLS.AlignHorzEnum.Center \'居中 Style.AlignVert = XLS.AlignVertEnum.Center \'居中 Style.BorderTop = XLS.LineStyleEnum.Thin \'上边框 Style.BorderBottom = XLS.LineStyleEnum.Thin \'下边框 Style.BorderLeft = XLS.LineStyleEnum.Thin \'左边框 Style.BorderRight = XLS.LineStyleEnum.Thin \'右边框 \'上下左右边框颜色 Style.BorderColorTop = Color.Black \'黑色 Style.BorderColorBottom = Color.Black Style.BorderColorLeft = Color.Black Style.BorderColorRight = Color.Black For i As Integer = 0 To s.Rows.count -1 For n As Integer = 0 To s.Cols.count -1 s(i,n).Style = Style Next Next \'符合条件的行字体变红加粗 Style = b.NewStyle Style.ForeColor = Color.Red \'样式的字体颜色设为红色 Style.Font = new font("宋体",9,FontStyle.Bold) \'宋体,9号,加粗 Style.AlignHorz = XLS.AlignHorzEnum.Center \'居中 Style.AlignVert = XLS.AlignVertEnum.Center \'居中 Style.BorderTop = XLS.LineStyleEnum.Thin \'上边框 Style.BorderBottom = XLS.LineStyleEnum.Thin \'下边框 Style.BorderLeft = XLS.LineStyleEnum.Thin \'左边框 Style.BorderRight = XLS.LineStyleEnum.Thin \'右边框 \'上下左右边框颜色 Style.BorderColorTop = Color.Black \'黑色 Style.BorderColorBottom = Color.Black Style.BorderColorLeft = Color.Black Style.BorderColorRight = Color.Black For i As Integer = 0 To s.Rows.count -1 Dim Hjs() As String = {"分数线","全区合计"} For Each Hj As String In Hjs If s(i,2).Text.EndsWith(Hj) Then \'如果指定列(sheet(i,2)第3列 For n As Integer = 0 To s.Cols.count -1 s(i,n).Style = Style Next End If Next Next b.Save(dlg.FileName) DataTables.Delete(tjnj &"级"& tjlb & "市区目标对比") End If e.Form.Controls("Label1").Text = "近三届上市重点人数对照表已导出并删除!" 如何修改代码?请指教。谢谢! |
||||
-- 作者:有点蓝 -- 发布时间:2022/4/16 15:37:00 -- 请上传实例测试 |
||||
-- 作者:cqlpjks -- 发布时间:2022/4/17 10:33:00 -- 文件超过2M,传不上来。如果不生成图像,就不存在那个问题。 [此贴子已经被作者于2022/4/17 11:13:24编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2022/4/17 20:24:00 -- 新建项目,导入对应的表格和代码,重现同样的问题,然后把新项目发上来 |
||||
-- 作者:cqlpjks -- 发布时间:2022/4/18 9:36:00 -- 高三分析统计程序测试文件:
[此贴子已经被作者于2022/4/18 9:37:21编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2022/4/18 9:49:00 --
|
||||
-- 作者:cqlpjks -- 发布时间:2022/4/18 10:34:00 -- 文件版本过高,我打不开。麻烦你直接发“导出并生成图表”代码。谢谢! |
||||
-- 作者:有点蓝 -- 发布时间:2022/4/18 11:43:00 -- 更新到最新版本。或者找台电脑安装最新版的试用版 |
||||
-- 作者:cqlpjks -- 发布时间:2022/4/18 13:23:00 -- 搞定。谢谢! \'保存文件 t.SaveExcel(dlg.FileName, tjnj &"级"& tjlb & "市区目标对比") \'保存文件 Dim b As New XLS.Book(dlg.FileName) Dim s As XLS.Sheet = b.Sheets(tjnj &"级"& tjlb & "市区目标对比") s(t.rows.Count + 3,1).Value = New XLS.Picture(Chart.Image) Dim Style As Xls.Style = b.NewStyle \'新建一个样式 另请教:我没另外付费,Foxtable软件可以更新吗?
|
||||
-- 作者:有点蓝 -- 发布时间:2022/4/18 13:35:00 -- Foxtable提供3年免费更新。超过3年的可以续费,具体请联系客服,QQ:800014337 |