我有一个非常简单的itextsharp表,如下所示:
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
// Create spacing after row here only.
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
doc.Add(table);
Run Code Online (Sandbox Code Playgroud)
如何仅在第1行和第2行之间创建空格?
谢谢.
如果你想添加空行,我理解请: 试试这个:
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
PdfPCell cellBlankRow = new PdfPCell(new Phrase(" "));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cellBlankRow);
table.AddCell("");
table.AddCell("");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
Run Code Online (Sandbox Code Playgroud)
只需使用插入空白行Phrase.我测试过并且工作正常..!如果我误解请告诉我..!