diff --git a/code/后端/desktop_archievement_backend/src/main/java/com/cpic/xim/utils/poi/MyPOIUtils.java b/code/后端/desktop_archievement_backend/src/main/java/com/cpic/xim/utils/poi/MyPOIUtils.java new file mode 100644 index 0000000..19d964d --- /dev/null +++ b/code/后端/desktop_archievement_backend/src/main/java/com/cpic/xim/utils/poi/MyPOIUtils.java @@ -0,0 +1,41 @@ +/* + * @Author: Kane + * @Date: 2023-10-08 22:12:05 + * @LastEditors: Kane + * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/utils/poi/MyPOIUtils.java + * @Description: POI相关的工具 + * + * Copyright (c) ${2023} by Kane, All Rights Reserved. + */ +package com.cpic.xim.utils.poi; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; + +public class MyPOIUtils +{ + public String getStringCellValue( Cell cell ) + { + switch( cell.getCellType() ) + { + case STRING: + return cell.getStringCellValue(); + default: + return ""; + } + } + + public String getStringCellValue( Row row, int columnIndex ) + { + Cell cell = row.getCell(columnIndex, MissingCellPolicy.RETURN_NULL_AND_BLANK); + + switch( cell.getCellType() ) + { + case STRING: + return cell.getStringCellValue(); + default: + return ""; + } + } +} \ No newline at end of file