此主题相关图片如下:4.png
这是参照帮助,生成的PDF 文件,效果十分不理想,同时没有将标题一同生成。
代码如下:
Dim Chart As New ChartBuilder
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t1 As Table = Tables("批次统计临时表") '定义一个变量t引用数据表
Dim sm As Integer = t1.Compute("Sum(各环节成本)") '计算总数量
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Chart.SeriesList.Clear()
For Each r As Row In t1.Rows
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = r("各环节名称") & "(" & Format(r("各环节成本"),"#,###.00") & ")" '设置图系的标题
Series.Y(0) = r("各环节成本") '指定值
If r("各环节名称") = "其他环节" Then '如果是其他环节
Series.Offset = 20 '那么图系偏离中心点20个像素.
End If
Series.DataLabelText = Math.Round(r("各环节成本")*100/sm,2) & "%" '计算百分比
Next
Chart.PrintWidth = 200
Chart.PrintHeight = 100
Chart.SaveImage(ProjectPath & "Reports\【单】批次各环节成本构成分析.wmf")
Dim Book As New XLS.Book(ProjectPath & "Attachments\【单】批次各环节成本构成分析.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(15,7).Value = New XLS.Picture(Chart.Image) '修改模板
Sheet(9,4).Value = "" & RJ & "" '修改模板
Sheet(9,5).Value = "操作员:" & User.Name '修改模板
Dim t As String = Date.Now
Dim wjm As String = t.SubString(0,4) & t.SubString(5,2) & t.SubString(8,2) & t.SubString(11,2) & t.SubString(14,2) & t.SubString(17,2)
Dim fl As String = ProjectPath & "Reports\" & wjm & ".pdf"
Book.Build() '生成细节区
Book.SaveToPDF(fl) '保存为PDF文件
Dim Proc As New Process '打开PDF文件
Proc.File = fl
Proc.Start()
[此贴子已经被作者于2019/9/26 17:05:33编辑过]