
package com.tmerclub.cloud.common.util;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author xxw
 * @version 1.0
 * @description:
 * @since 2023/11/22 15:46
 */
public class SheetUtil {

    /**
     * 判断execl文档是否为空
     * @param file
     * @return
     */
    public static Boolean sheetIsNull(MultipartFile file) {
        InputStream inputStream = null;
        XSSFWorkbook workbook;
        try {
            inputStream = file.getInputStream();
            workbook = new XSSFWorkbook(inputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        try {
            XSSFSheet sheetAt = workbook.getSheetAt(0);
        } catch (Exception e) {
            return true;
        }
        return false;
    }
}
