【发布时间】:2016-02-22 08:31:24
【问题描述】:
我的代码无法读取最后 3 个 table.addCell .(table.addCell(card.getPk().getCardNumber()); table.addCell(card.getStatus()); table.addCell(card.getAmount().toString());) 我的代码有什么问题?
PdfPTable table = new PdfPTable(19);
table.setWidthPercentage(100);
PdfPCell column = new PdfPCell();
column.setColspan(19);
table.addCell(column);
table.addCell(ReportConstants.REPORT_COLUMN_PURCHASE_DATE);
table.addCell(ReportConstants.REPORT_COLUMN_PURCHASE_TIME);
table.addCell(ReportConstants.REPORT_COLUMN_TRANSACTION_NUMBER);
table.addCell(ReportConstants.REPORT_COLUMN_BUYERS_NAME);
table.addCell(ReportConstants.REPORT_COLUMN_BUYERS_TYPE);
table.addCell(ReportConstants.REPORT_COLUMN_CENTER);
table.addCell(ReportConstants.REPORT_COLUMN_PAYMENT);
table.addCell(ReportConstants.REPORT_COLUMN_IPG_REF);
table.addCell(ReportConstants.REPORT_COLUMN_CREATED_BY);
table.addCell(ReportConstants.REPORT_COLUMN_UPDATE_DT);
table.addCell(ReportConstants.REPORT_COLUMN_UPDATE_BY);
table.addCell(ReportConstants.REPORT_COLUMN_STATUS);
table.addCell(ReportConstants.REPORT_COLUMN_CARD_TYPE);
table.addCell(ReportConstants.REPORT_COLUMN_TTL_AMOUNT);
table.addCell(ReportConstants.REPORT_COLUMN_OR_NUMBER);
table.addCell(ReportConstants.REPORT_COLUMN_REMARKS);
table.addCell(ReportConstants.REPORT_COLUMN_CARD_NUMBER);
table.addCell(ReportConstants.REPORT_COLUMN_CARD_STATUS);
table.addCell(ReportConstants.REPORT_COLUMN_AMOUNT);
for(CardPurchaseReport cardPurchase : cardPurchases){
table.addCell(dateFormat.format(cardPurchase.getPurchaseDate()));
table.addCell(timeFormat.format(cardPurchase.getPurchaseDate()));
table.addCell(cardPurchase.getPurchaseNumber());
table.addCell(cardPurchase.getBuyerName());
table.addCell(cardPurchase.getBuyerType());
table.addCell(cardPurchase.getCenter());
table.addCell(cardPurchase.getPaymentType());
table.addCell(cardPurchase.getIpgRefNumber());
table.addCell(cardPurchase.getCreatedBy());
table.addCell(dateFormat.format(cardPurchase.getUpdatedDate()));
table.addCell(cardPurchase.getUpdatedBy());
table.addCell(cardPurchase.getStatus());
table.addCell(cardPurchase.getCardType());
table.addCell(cardPurchase.getTotalAmount().toString());
table.addCell(cardPurchase.getOrNumber());
table.addCell(cardPurchase.getRemarks());
if(cardNums != null){
for(CardMasterWS cardNum : cardNums){
if(cardNum.getOrderTicket().equalsIgnoreCase(cardPurchase.getPurchaseNumber())){
CardMaster card = cardMasterDao.getCardDetails(cardNum.getCardNumber());
table.addCell(card.getPk().getCardNumber());
table.addCell(card.getStatus());
table.addCell(card.getAmount().toString());
}
}
}
}
doc.add(table);
doc.close();
【问题讨论】:
-
cardNums的大小是多少?如果为零 (0),则这三个addCell方法不运行是正常的。还要检查你的条件if(cardNum.getOrderTicket().equalsIgnoreCase(cardPurchase.getPurchaseNumber())),如果它返回true -
嗨@elefasGR 谢谢。我的 cardNums 的大小是 30,我的 if 语句是真的。
-
iText 不显示不完整的行。葬礼行有 19 个单元格吗?如果没有,请使用
setCompleteRows完成最后一行。 -
@BrunoLowagie 最后一行有 19 个单元格。
-
您确定
cardNum.getOrderTicket().equalsIgnoreCase(cardPurchase.getPurchaseNumber())是否真实存在?例如。使用日志语句?
标签: java eclipse pdf itext java-ee-7