写了两个工具函数。

This commit is contained in:
unknown 2023-10-09 00:18:07 +08:00
parent 041ec287b9
commit e40b81672a
1 changed files with 41 additions and 0 deletions

View File

@ -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 "";
}
}
}