同時設定 IsRowBroken 及 RowSpan 時,會導致跨頁的儲存格在前頁面沒有隔線,文字也掉到第二頁。
PDFQ6.pdf (4.5 KB)
PicQ6.png (28.2 KB)
Public Sub Gen_PDF_Q6()
Dim RowCount As Integer = 40
Dim ColCount As Integer = 5
Dim iRowSpan As Integer = 25
Dim SpanRow As Integer = 10
AsposeFunc.AsposePDFLicense_20240906()
Dim pDoc As New Aspose.Pdf.Document()
Dim pPages As Aspose.Pdf.PageCollection = pDoc.Pages
Dim pPage As Aspose.Pdf.Page = pPages.Add()
pPage.SetPageSize(Aspose.Pdf.PageSize.A4.Width, Aspose.Pdf.PageSize.A4.Height)
Dim PageMargin As New Aspose.Pdf.MarginInfo With {.Top = 25, .Left = 25, .Right = 25, .Bottom = 25}
Dim pPageInfo As Aspose.Pdf.PageInfo = pPage.PageInfo
pPageInfo.Margin = PageMargin
Dim pTable As New Aspose.Pdf.Table With {.ColumnWidths = "20% 20% 20% 20% 20%"}
pPage.Paragraphs.Add(pTable)
Dim Border As New Aspose.Pdf.BorderInfo With {
.Top = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5},
.Left = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5},
.Right = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5},
.Bottom = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5}
}
Dim pRows As Aspose.Pdf.Rows = pTable.Rows
For iRow As Integer = 0 To RowCount - 1
Dim pRow As Aspose.Pdf.Row = pRows.Add()
pRow.MinRowHeight = 25
pRow.IsRowBroken = True
Dim pCells As Aspose.Pdf.Cells = pRow.Cells
For iCol As Integer = 0 To ColCount - 1
Dim R1C1 As String = "R" & iRow + 1 & "C" & iCol + 1
Dim pCell As Aspose.Pdf.Cell = pCells.Add(R1C1)
pCell.Border = Border
Next
Next
If SpanRow > 0 Then
pRows(iRowSpan).Cells(0).RowSpan = SpanRow
pRows(iRowSpan).Cells(2).RowSpan = SpanRow
For i As Integer = 1 To SpanRow - 1
pRows(iRowSpan + i).Cells(0).RowSpan = 0
pRows(iRowSpan + i).Cells(2).RowSpan = 0
Next
End If
For ipRow As Integer = pRows.Count - 1 To 0 Step -1
Dim pRow As Aspose.Pdf.Row = pRows(ipRow)
Dim pCells As Aspose.Pdf.Cells = pRow.Cells
For ipCol As Integer = pCells.Count - 1 To 0 Step -1
Dim pCell As Aspose.Pdf.Cell = pCells(ipCol)
If pCell.RowSpan = 0 OrElse pCell.ColSpan = 0 Then
pCells.Remove(pCell)
End If
Next
Next
pDoc.Save("X:\Coding\PDFQ6.pdf")
End Sub