|
|
@@ -260,10 +260,13 @@ public class PDFUtils {
|
|
|
table.setWidthPercentage(100);
|
|
|
float[] columnWidths = new float[columnCount];
|
|
|
for (int j = 0; j < columnCount; j++) {
|
|
|
- columnWidths[j] = 1f;
|
|
|
+ if (j==1||j==0){
|
|
|
+ columnWidths[j] = 50f;
|
|
|
+ }else {
|
|
|
+ columnWidths[j] = 10f;
|
|
|
+ }
|
|
|
}
|
|
|
table.setWidths(columnWidths);
|
|
|
-
|
|
|
// 处理行数据
|
|
|
int rowCount = 0;
|
|
|
for (Row row : sheet) {
|
|
|
@@ -271,9 +274,9 @@ public class PDFUtils {
|
|
|
for (int colIndex = 0; colIndex < columnCount; colIndex++) {
|
|
|
Cell cell = row.getCell(colIndex);
|
|
|
String cellValue = getCellValue(cell);
|
|
|
-
|
|
|
- PdfPCell pdfCell = new PdfPCell(new Phrase(cellValue, PDFUtils.getFont()));
|
|
|
- pdfCell.setPadding(3);
|
|
|
+ Font font = PDFUtils.getFont(10);
|
|
|
+ PdfPCell pdfCell = new PdfPCell(new Phrase(cellValue, font));
|
|
|
+ pdfCell.setPadding(1);
|
|
|
|
|
|
// 设置表头样式
|
|
|
if (rowCount == 0) {
|
|
|
@@ -288,13 +291,13 @@ public class PDFUtils {
|
|
|
rowCount++;
|
|
|
|
|
|
// 限制处理的行数,避免内容过多
|
|
|
- if (rowCount > 100) {
|
|
|
- PdfPCell pdfCell = new PdfPCell(new Phrase("... (内容过多,省略剩余部分)", PDFUtils.getFont()));
|
|
|
- pdfCell.setColspan(columnCount);
|
|
|
- pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
- table.addCell(pdfCell);
|
|
|
- break;
|
|
|
- }
|
|
|
+// if (rowCount > 100) {
|
|
|
+// PdfPCell pdfCell = new PdfPCell(new Phrase("... (内容过多,省略剩余部分)", PDFUtils.getFont()));
|
|
|
+// pdfCell.setColspan(columnCount);
|
|
|
+// pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+// table.addCell(pdfCell);
|
|
|
+// break;
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
document.add(table);
|