2013-07-11 2 views
0

에 대한 일반적인 사용할 수 있습니다 내가 수동으로 추가하는 대신 Pdfcells의 일반을 만들고 싶어어떻게 내가 테이블을 생성 iTextSharp를 사용하고 PdfPcells

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; 
+0

은 [PdfPTable.getDefaultCell는() (http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfPTable.html#getDefaultCell%28%29) 당신은 무엇을 찾고 ? –

답변

1

@Alexis 비둘기의 의견 당신이있어 무엇을하지 않은 경우 래퍼 함수에 대해 어떻게 생각하세요?

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); 
+0

고마워, 내 생각에 대한 매개 변수를 루프에 대한 만들고 개체를 생성하는 방법에 대한 매개 변수를 전달하는 경우 내 아이디어가 있지만 정말 유용한 메서드 :) – Sonic

관련 문제