首页 aspose word 插入文本 表格 图片

aspose word 插入文本 表格 图片

举报
开通vip

aspose word 插入文本 表格 图片Public Sub CreatDoc(ByValtitlestr As String, ByVal ds As DataSet, ByValfn As String, ByValStartDate As Date, ByValEndDate As Date, Optional ByValDayReport As Integer = 0) 'Instantiate a Pdf instance Dim doc1 As Aspose.Words.Document = New Aspose.Words.Docum...

aspose word 插入文本 表格 图片
Public Sub CreatDoc(ByValtitlestr As String, ByVal ds As DataSet, ByValfn As String, ByValStartDate As Date, ByValEndDate As Date, Optional ByValDayReport As Integer = 0) 'Instantiate a Pdf instance Dim doc1 As Aspose.Words.Document = New Aspose.Words.Document Dim builder As New Aspose.Words.DocumentBuilder(doc1) builder.Write(titlestr) builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak) builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak) For i As Integer = 0 To ds1.Tables.Count - 1 If ds1.Tables(i).Rows.Count> 0 Then If i = 4 Then builder.MoveToDocumentEnd() builder.InsertBreak(Aspose.Words.BreakType.PageBreak) 'Chart图片 Select Case DayReport Case 0 doc1 = InsertImg2Doc(doc1, StartDate, EndDate, "小时", 3) 'sec2 = InsertImg2Pdf(sec2, StartDate, EndDate, "小时", 3) Case 1 doc1 = InsertImg2Doc(doc1, StartDate, EndDate, "天", 10) 'sec2 = InsertImg2Pdf(sec2, StartDate, EndDate, "天", 10) Case 2 doc1 = InsertImg2Doc(doc1, StartDate, EndDate, "天", 10) doc1 = InsertImg2Doc(doc1, StartDate, EndDate, "周", 10) 'sec2 = InsertImg2Pdf(sec2, StartDate, EndDate, "天", 10) 'sec2 = InsertImg2Pdf(sec2, StartDate, EndDate, "周", 10) End Select builder.MoveToDocumentEnd() builder.InsertBreak(Aspose.Words.BreakType.PageBreak) End If doc1 = InsertTable2Doc(doc1, ds1.Tables(i)) End If Next ds1.Dispose() doc1.Save(fn) End Sub Private Function InsertTable2Doc(ByVal doc1 As Aspose.Words.Document, ByValtb As DataTable) As Aspose.Words.Document Dim builder As New Aspose.Words.DocumentBuilder(doc1) builder.MoveToDocumentEnd() builder.StartTable() builder.Write(tb.TableName) '表头 For i As Integer = 0 Totb.Columns.Count - 1 builder.InsertCell() builder.Write(tb.Columns(i).ColumnName) Next builder.EndRow() For i As Integer = 0 Totb.Rows.Count - 1 For j As Integer = 0 Totb.Columns.Count - 1 builder.InsertCell() builder.Write(tb.Rows(i)(j).ToString) Next builder.EndRow() Next builder.EndTable() builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak) Return doc1 End Function Function InsertImg2Doc(ByVal doc1 As Aspose.Words.Document, ByValstartDate As Date, ByValenddate As Date, ByVal type1 As String, ByValChartTypeAs Integer, Optional ByVal Enable3D As Boolean = True) As Aspose.Words.Document Dim builder As New Aspose.Words.DocumentBuilder(doc1) builder.MoveToDocumentEnd() builder.Write("按" & type1 & "浏览量:") Dim dt As DataTable = stat1.StatByDate(type1, "", startdate, enddate) Dim mychart As System.Windows.Forms.DataVisualization.Charting.Chart = stat1.ShowChart1(dt, ChartType, "浏览量", type1, Enable3D) 'mychart.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column '初始化数值 mychart.Width = doc1.GetPageInfo(0).WidthInPoints - 40 mychart.Height = 300 mychart.Series(0).Name = "浏览量" Dim ms As MemoryStream = New MemoryStream() mychart.Saveimage(ms, System.Drawing.Imaging.ImageFormat.Png) 'mychart.Dispose() Dim image1 As Aspose.Pdf.Generator.Image = New Aspose.Pdf.Generator.Image() image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png 'image1.ImageInfo.ImageStream = ScaleImg(ms, sec2.PageInfo.PageWidth, 0) image1.ImageInfo.ImageStream = ms builder.InsertImage(ms) Return doc1 End Function
本文档为【aspose word 插入文本 表格 图片】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_321635
暂无简介~
格式:doc
大小:19KB
软件:Word
页数:6
分类:互联网
上传时间:2019-05-11
浏览量:125