Warum wird die 2. Tabellenreihe nicht geschrieben? [Duplikat
Diese Frage hat hier bereits eine Antwort:
Ungerade nummerierte Zelle, die nicht zu Pdf @ hinzugefügt wur 1 AntwortIch versuche, eine Tabelle ohne Rahmen mit 4 Spalten und 2 Zeilen über meinem PDF-Dokument zu erstellen. Das Problem ist, dass die 2. Zeile nicht geschrieben wird. Das ist mein Code:
float[] columnWidths = { 2, 1, 1, 1};
PdfPTable table = new PdfPTable(columnWidths);
table.WidthPercentage = 100;
if (...) //true
{
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("AAA:_______________",infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 1st col,1st row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("BBB:_____", infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 2nd col,1st row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("CCC:_____", infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 3rd col,1st row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("DDD:_____", infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 4th col,1st row
}
}
if (...) //true
{
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("EEE: " + eee));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 1st col,2nd row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("FFF: " + fff));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 2nd col,2nd row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("GGG: " + ggg));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 3rd col,2nd row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("HHH:___________________"));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 4th col,2nd row
}
}
document.Add(table);
Wie kann ich damit umgehen? Und die zweite Frage: Kann ich für jede if-Bedingung eine feste Position haben (überprüfen Sie die Kommentare im Code)? Wenn also eine if-Bedingung in der ersten Zeile nicht zutrifft, sollte diese Zelle leer sein?