package com.zbkj.common.utils.excel;

import com.zbkj.common.exception.CrmebException;
import org.springframework.web.multipart.MultipartFile;

public class ExcelValidUtil {

	public static void canImport(final MultipartFile file) {
		if (file == null || file.isEmpty()) {
			throw new CrmebException("请选择要导入的文件");
		}
		String filename = file.getOriginalFilename().toLowerCase();
		if (!(filename.endsWith("csv") || filename.endsWith("xls") || filename.endsWith("xlsx"))) {
			throw new CrmebException("导入的文件格式错误，允许的格式：csv、xls、xlsx");
		}
	}
}
