0

iTextSharp を使用してテーブルを生成しています。手動で追加するのではなく、ジェネリックの Pdfcells を作成したい

PdfPCell HeadCell0 = new PdfPCell(new Paragraph("FullName", Htitle));
HeadCell0.BackgroundColor = Color.LIGHT_GRAY;
PdfPCell HeadCell1 = new PdfPCell(new Paragraph("Username", Htitle));
HeadCell1.BackgroundColor = Color.LIGHT_GRAY;
PdfPCell HeadCell2 = new PdfPCell(new Paragraph("Email", Htitle));
HeadCell2.BackgroundColor = Color.LIGHT_GRAY;
PdfPCell HeadCell3 = new PdfPCell(new Paragraph("Department", Htitle));
HeadCell3.BackgroundColor = Color.LIGHT_GRAY;
PdfPCell HeadCell4 = new PdfPCell(new Paragraph("AddedBy", Htitle));
HeadCell4.BackgroundColor = Color.LIGHT_GRAY;
PdfPCell HeadCell5 = new PdfPCell(new Paragraph("Account Type", Htitle));
HeadCell5.BackgroundColor = Color.LIGHT_GRAY;
4

1 に答える 1

1

@Alexis Pigeon のコメントが探しているものではない場合、ラッパー関数はどうですか?

public static PdfPCell MakeHeader(string text, iTextSharp.text.Font Htitle) {
    PdfPCell HeadCell = new PdfPCell(new Paragraph(text, Htitle));
    HeadCell.BackgroundColor = iTextSharp.text.Color.LIGHT_GRAY;

    return HeadCell;
}

PdfPCell HeadCell0 = MakeHeader("FullName", Htitle);
于 2013-07-11T19:08:47.200 に答える