私はvb.netからレポートを作成しようとしていますが、ここにあります
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Word.Table
For Each dc As BSPLib.Bills.BillDeliverychallan In Bill.BillDCs
Dim dcpara As Word.Paragraph
dcpara = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
dcpara.Range.Font.Bold = 5
dcpara.Range.Text = "Delivery Challan: " & dc.DCName
dcpara.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
dcpara.Format.SpaceBefore = 12
dcpara.Format.SpaceAfter = 2 '24 pt spacing after paragraph.
dcpara.Range.InsertParagraphAfter()
Dim count As Integer = dc.BillItems.Count
Dim r As Integer
oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, count + 1, 7)
oTable.Range.ParagraphFormat.SpaceBefore = 2
oTable.Range.ParagraphFormat.SpaceAfter = 0
oTable.Columns(1).Width = oWord.CentimetersToPoints(0.89)
oTable.Columns(2).Width = oWord.CentimetersToPoints(5.58)
oTable.Columns(3).Width = oWord.CentimetersToPoints(2)
oTable.Columns(4).Width = oWord.CentimetersToPoints(0.6)
oTable.Columns(5).Width = oWord.CentimetersToPoints(1.7)
oTable.Columns(6).Width = oWord.CentimetersToPoints(0.5)
oTable.Columns(7).Width = oWord.CentimetersToPoints(2.01)
For r = 1 To count
'BQT TABLES 15 NOS @ 25.00 = 375.00
oTable.Cell(r, 1).Range.Text = dc.BillItems(r - 1).ItemSerial & "."
oTable.Cell(r, 1).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
oTable.Cell(r, 1).Range.Font.Bold = 0
oTable.Cell(r, 2).Range.Text = dc.BillItems(r - 1).ItemName
oTable.Cell(r, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
oTable.Cell(r, 2).Range.Font.Bold = 0
oTable.Cell(r, 3).Range.Text = dc.BillItems(r - 1).Quantity & " " & dc.BillItems(r - 1).ItemMeasure
oTable.Cell(r, 3).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
oTable.Cell(r, 3).Range.Font.Bold = 0
oTable.Cell(r, 4).Range.Text = "@"
oTable.Cell(r, 4).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
oTable.Cell(r, 4).Range.Font.Bold = 0
oTable.Cell(r, 5).Range.Text = dc.BillItems(r - 1).PricePerUnit.ToString("F")
oTable.Cell(r, 5).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
oTable.Cell(r, 5).Range.Font.Bold = 0
oTable.Cell(r, 6).Range.Text = "="
oTable.Cell(r, 6).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
oTable.Cell(r, 6).Range.Font.Bold = 0
oTable.Cell(r, 7).Range.Text = dc.BillItems(r - 1).TotalFinal.ToString("F")
oTable.Cell(r, 7).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
oTable.Cell(r, 7).Range.Font.Bold = 0
Next
oTable.Cell(r + 1, 7).Range.Text = (dc.Total / dc.Days).ToString("F")
oTable.Cell(r + 1, 7).Range.Font.Bold = 0
oTable.Cell(r, 7).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
oTable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowLeft
'Using a line break before my next table
Dim oLineBreak1 As Word.Paragraph
oLineBreak1 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
oLineBreak1.Format.SpaceAfter = 0
oLineBreak1.Format.SpaceBefore = 0
oLineBreak1.Range.Font.Size = 2
oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, 1, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 0
oTable.Range.ParagraphFormat.SpaceBefore = 0
If dc.Days > 1 Then
oTable.Cell(1, 1).Range.Text = " From " & dc.FromDate.ToShortDateString & " To " & dc.ToDate & " --- " & dc.Days & " days" & " For: " & dc.ForDate
Else
oTable.Cell(1, 1).Range.Text = " From " & dc.FromDate.ToShortDateString & " To " & dc.ToDate & " --- " & dc.Days & " day" & " For:" & dc.ForDate
End If
oTable.Cell(1, 1).Width = oWord.CentimetersToPoints(12.44)
oTable.Cell(1, 2).Width = oWord.CentimetersToPoints(2.67)
oTable.Cell(1, 2).Range.Text = dc.Total.ToString("F")
oTable.Cell(1, 2).Range.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight
oTable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter
'Dim break As Word.WdBreakType
'End If
Next
問題は、for各ループのデータが次のページに拡張される場合、forループのデータ全体を次のページに移動させたいということです。ページカウント整数を追加し、開始と終了でそれを検証して、ページを決定および変更することを考えています。問題は、指定された行番号にページ分割を挿入する方法がわからないことです。ページ分割はWord.WdBreakType.wdPageBreak
、行番号に挿入する方法ですか?
ありがとうございました。