package com.gz.utils;

import cn.hutool.core.util.StrUtil;

import java.util.List;

/**
 * Excel工具
 * @author LiuchangLan
 * @date 2021/3/4 14:45
 */
public class ExcelUtils {


    /**
     * @description 读取Excel单元格的String值
     * @author LiuChangLan
     * @since 2021/3/4 14:46
     */
    public static String getExcelCellStringValue(List<Object> row, int index) {
        if (index >= row.size()) {
            return null;
        }else if (row.get(index) == null){
            return null;
        }else {
            return String.valueOf(row.get(index)).trim();
        }
    }

    /**
     * 读取Excel单元格的Integer值
     * @description
     * @author LiuChangLan
     * @since 2021/3/4 14:46
     */
    public static Integer getExcelCellIntegerValue(List<Object> row, int index) {
        String str = getExcelCellStringValue(row, index);
        if (StrUtil.isEmpty(str) || "null".equals(str)){
            return 0;
        }else {
            return Integer.valueOf(getExcelCellStringValue(row, index));
        }
    }

}
