|
|
|
@ -43,7 +43,6 @@ public class ExcelConvertPdf {
|
|
|
|
|
Sheet sheet = workbook.getSheetAt(0); |
|
|
|
|
int column = sheet.getRow(1).getLastCellNum(); |
|
|
|
|
int row = sheet.getPhysicalNumberOfRows(); |
|
|
|
|
System.out.println(row); |
|
|
|
|
//下面是找出表格中的空行和空列
|
|
|
|
|
List nullCol = new ArrayList<>(); |
|
|
|
|
List nullRow = new ArrayList<>(); |
|
|
|
@ -76,7 +75,6 @@ public class ExcelConvertPdf {
|
|
|
|
|
PdfPTable table = new PdfPTable(column-sheet.getRow(1).getFirstCellNum()); |
|
|
|
|
List<CellRangeAddress> ranges = new ArrayList(); |
|
|
|
|
int sheetMergeCount = sheet.getNumMergedRegions(); |
|
|
|
|
System.out.println("sheetMergeCount"+sheetMergeCount); |
|
|
|
|
for (int i = 0; i < sheetMergeCount; i++) { |
|
|
|
|
CellRangeAddress range = sheet.getMergedRegion(i); |
|
|
|
|
ranges.add(range); |
|
|
|
@ -104,10 +102,6 @@ public class ExcelConvertPdf {
|
|
|
|
|
} else { |
|
|
|
|
str = cell.getStringCellValue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
System.out.println("i ::"+i + "j::"+j); |
|
|
|
|
System.out.println(str); |
|
|
|
|
|
|
|
|
|
for (CellRangeAddress range : ranges) { //合并的单元格判断和处理
|
|
|
|
|
|
|
|
|
|
if (j >= range.getFirstColumn() && j <= range.getLastColumn() && i >= range.getFirstRow() |
|
|
|
@ -125,7 +119,6 @@ public class ExcelConvertPdf {
|
|
|
|
|
rowNum = range.getLastRow() - range.getFirstRow() + 1; |
|
|
|
|
colNum = range.getLastColumn() - range.getFirstColumn() + 1; |
|
|
|
|
cell1 = mergeCell(str, font, rowNum, colNum); |
|
|
|
|
System.out.println("合并"+rowNum+"、"+colNum); |
|
|
|
|
table.addCell(cell1); |
|
|
|
|
flag = false; |
|
|
|
|
mergeFlag = ranges.size() > 1; |
|
|
|
|