写了两个工具函数。
This commit is contained in:
		@@ -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 "";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user