|
|
@@ -13,6 +13,7 @@ import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
|
|
|
import com.itextpdf.text.pdf.parser.RenderListener;
|
|
|
import com.itextpdf.text.pdf.parser.TextRenderInfo;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.CellType;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
|
@@ -22,6 +23,7 @@ import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
public class PdfAddContextUtils {
|
|
|
|
|
|
@@ -66,14 +68,13 @@ public class PdfAddContextUtils {
|
|
|
public static String getExcelFullTitle(org.apache.poi.ss.usermodel.Workbook workbook, String title) {
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
sheet.setForceFormulaRecalculation(true);
|
|
|
- int rowNum = sheet.getLastRowNum();
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
Row row = sheet.getRow(i);
|
|
|
if (row != null) {
|
|
|
short cellNum = row.getLastCellNum();
|
|
|
for (int j = 0; j < cellNum; j++) {
|
|
|
Cell cell = row.getCell(j);
|
|
|
- if (cell != null) {
|
|
|
+ if (cell != null && cell.getCellTypeEnum() == CellType.STRING) {
|
|
|
String cellValue = cell.getStringCellValue();
|
|
|
if (cellValue != null && !cellValue.isEmpty()) {
|
|
|
if (containsAllCharactersInOrder(cellValue, title)) {
|
|
|
@@ -86,6 +87,44 @@ public class PdfAddContextUtils {
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
+ public static String getExcelFullTitleByProjectName(org.apache.poi.ss.usermodel.Workbook workbook, String projectName) {
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if (row == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ short cellNum = row.getLastCellNum();
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ if (cell == null || cell.getCellTypeEnum() != CellType.STRING) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String cellValue = cell.getStringCellValue();
|
|
|
+ if (cellValue == null || cellValue.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (Objects.equals(cellValue, projectName) && i + 1 < sheet.getLastRowNum()) {
|
|
|
+ Row row1 = sheet.getRow(i + 1);
|
|
|
+ if (row1 == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (int k = 0; k < row1.getLastCellNum(); k++) {
|
|
|
+ Cell cell1 = row1.getCell(k);
|
|
|
+ if (cell1 == null || cell1.getCellTypeEnum() != CellType.STRING) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ cellValue = cell1.getStringCellValue();
|
|
|
+ if (cellValue != null && cellValue.trim().length() > 2) {
|
|
|
+ return cellValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public static boolean containsAllCharactersInOrder(String str, String str1) {
|