我正在生成一個帶有PdfPTable
的PDF文檔。有三欄說列a,列b和列c。目前,它看起來來像這樣:如何在下一行c#中顯示pdftable(iTextSharp)的單元格(具有其行值的列)?
Col a | Col b | Col c
--------------------------------------------------------
ValuesofCol a | ValuesofCol b | ValuesofCol c
但隨着山口Ç是說明,它包含了大量的數據,我想表看起來像這樣:
Col a | Col b
--------------------------------------------------------
ValueofCol a | ValueofColb
--------------------------------------------------------
Col c
--------------------------------------------------------
ValueOfCol c
--------------------------------------------------------
Cola | ColB
--------------------------------------------------------
ValueofCol a | ValueofCol b
--------------------------------------------------------
Colc
--------------------------------------------------------
ValueOfCol c
--------------------------------------------------------
這裏我寫的代碼片段
PdfPTable table = new PdfPTable(3);
table.HorizontalAlignment = 0;
table.SpacingBefore = 10f;
table.SpacingAfter = 10f;
table.TotalWidth = 550f;
table.LockedWidth = true;
float[] widths = new float[] { 2f, 3f, 3f };
table.SetWidths(widths);
//Header
table.AddCell(CreateHeaderCell("Cola"));
table.AddCell(CreateHeaderCell("Colb "));
table.AddCell(CreateHeaderCell("Colc"));
//Row 1
if (DsetAssesmentSummary.Tables[0].Rows.Count > 0)
{
table.AddCell(CreateCell(DsetAssesmentSummary.Tables[0].Rows[0]["Cola"].ToString(), true));
}
if (DsetAssesmentSummary.Tables[0].Rows.Count > 0)
{
table.AddCell(CreateCell(DsetAssesmentSummary.Tables[0].Rows[0]["Colb"].ToString(), true));
}
if (DsetAssesmentSummary.Tables[0].Rows.Count > 0)
{
table.AddCell(CreateCell(DsetAssesmentSummary.Tables[0].Rows[0]["Colc"].ToString(), true));
}
看看你有什麼以下'山口C'所以也許它應該被定義爲'Colc' – MethodMan
嗨MethodMan-感謝烏拉圭回合的反應,我給了一個虛擬的列名作爲COLC。布魯諾的文章幫助我解決了問題 –