表格的 Row.Border 會覆蓋掉 Cell.Border 設定,即便未定列的某一邊框線或是將色彩設為 Empty 都是同樣的結果。
PDFQ7.pdf (2.1 KB)
PicQ7.png (5.4 KB)
Public Sub Gen_PDF_Q7()
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 = "100 100 100"}
pPage.Paragraphs.Add(pTable)
Dim R1Border As New Aspose.Pdf.BorderInfo With {
.Top = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange},
.Left = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange},
.Right = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange}
}
Dim R2Border As New Aspose.Pdf.BorderInfo With {
.Left = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange},
.Right = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange}
}
Dim R3Border As New Aspose.Pdf.BorderInfo With {
.Left = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange},
.Right = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange},
.Bottom = New Aspose.Pdf.GraphInfo With {.LineWidth = 0.5, .Color = Aspose.Pdf.Color.Orange}
}
Dim CellBorder As New Aspose.Pdf.BorderInfo With {
.Top = New Aspose.Pdf.GraphInfo With {.LineWidth = 1, .Color = Aspose.Pdf.Color.Red},
.Left = New Aspose.Pdf.GraphInfo With {.LineWidth = 1, .Color = Aspose.Pdf.Color.Red},
.Right = New Aspose.Pdf.GraphInfo With {.LineWidth = 1, .Color = Aspose.Pdf.Color.Red},
.Bottom = New Aspose.Pdf.GraphInfo With {.LineWidth = 1, .Color = Aspose.Pdf.Color.Red}
}
Dim pRows As Aspose.Pdf.Rows = pTable.Rows
Dim pRow1 As Aspose.Pdf.Row = pRows.Add()
pRow1.FixedRowHeight = 100
Dim pCell11 As Aspose.Pdf.Cell = pRow1.Cells.Add("R1C1")
Dim pCell12 As Aspose.Pdf.Cell = pRow1.Cells.Add("R1C2")
Dim pCell13 As Aspose.Pdf.Cell = pRow1.Cells.Add("R1C3")
Dim pRow2 As Aspose.Pdf.Row = pRows.Add()
pRow2.FixedRowHeight = 100
Dim pCell21 As Aspose.Pdf.Cell = pRow2.Cells.Add("R2C1")
Dim pCell22 As Aspose.Pdf.Cell = pRow2.Cells.Add("R2C2")
Dim pCell23 As Aspose.Pdf.Cell = pRow2.Cells.Add("R2C3")
Dim pRow3 As Aspose.Pdf.Row = pRows.Add()
pRow3.FixedRowHeight = 100
Dim pCell31 As Aspose.Pdf.Cell = pRow3.Cells.Add("R3C1")
Dim pCell32 As Aspose.Pdf.Cell = pRow3.Cells.Add("R3C2")
Dim pCell33 As Aspose.Pdf.Cell = pRow3.Cells.Add("R3C3")
pRow1.Border = R1Border
pRow2.Border = R2Border
pRow3.Border = R3Border
pCell12.Border = CellBorder
pCell22.Border = CellBorder
pDoc.Save("X:\Coding\PDFQ7.pdf")
End Sub