(一)文件后缀问题:
获取文件名:
String name = multipartFile.getOriginalFilename();
获取后缀,文件类型,小写:
String postFix = FileUtil.extName(name).toLowerCase();
判断是否为图片格式:
public static boolean isImage(String extName) {
String imgs[] = { "bmp", "jpg", "jpeg", "png", "tiff", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd",
"cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "wmf" };
return ArrayUtil.containsIgnoreCase(imgs, extName);
}
其他格式 可以类推。
(二)图片获取传入前台:
这里我传入的是文件流:
@RequestMapping(method = RequestMethod.GET, value = "/getStorageImage")
public void getStorageImage(HttpServletRequest request, HttpServletResponse response, String id) throws IOException {
ValidateUtil.isNotBlank(id, "文件编号非法,找不到对应文件");
OutputStream stream = null;
TaskPhotoSd taskPhotoSd = taskPhotoSdService.selectById(id);
try {
if (taskPhotoSd != null) {
FastDfsFile fastDfsFile = new FastDfsFile();
String fileType = StrUtil.subAfter(taskPhotoSd.getStoragePath(), ".", false);
fastDfsFile.setRemoteFileUrl(StrUtil.subAfter(taskPhotoSd.getStoragePath(), "/", false));
fastDfsFile.setGroupName(StrUtil.subBefore(taskPhotoSd.getStoragePath(), "/", false));
byte[] img = fastDfsUtil.downloadFile(fastDfsFile);
response.addHeader("Content-Disposition", "attachment;filename=" + new String((taskPhotoSd.getPhotoNmae() + "." + fileType).getBytes("GBK"), "ISO8859_1"));
response.addHeader("Content-Length", "" + img.length);
response.setContentType("image/jpg");
stream = new BufferedOutputStream(response.getOutputStream());
stream.write(img);
stream.flush();
} else {
throw new ValidateException("未找到");
}
} catch (Exception e) {
throw e;
} finally {
FortifyUtil.close(stream);
}
}
这里我使用的是fastdfs工具类下载的文件,byte数组获取内容,根据url路径,可以按照不同的方法来获取。
其中上面的代码是浏览器会自动下载,如果要进行预览操作,可以将response.addHeader方法进行注释。
(三)excel文件导出:
@SystemControllerLog(desc="导出")
@RequestMapping(method=RequestMethod.GET, value = "exportProject")
public void exportProject(Project project, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
try {
String fileName = "项目数据"+DateUtil.now()+".xlsx";
List<ProjectExcel> projects = projectService.exportGetData();
new ExcelExport("项目数据", ProjectExcel.class).setDataList(projects).write(response, fileName).dispose();
} catch (Exception e) {
renderResult(response, RestResultGenerator.success("导出项目失败!失败信息:"+e.getMessage()));
}
}
ExcelExport文件如下:
package com.glens.common.excel;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.glens.common.excel.ExcelField.Align;
import com.glens.common.excel.ExcelField.Type;
import com.glens.common.exception.ExcelException;
import com.glens.common.util.FortifyUtil;
/**
* 导出Excel文件(导出“XLSX”格式,支持大数据量导出 )
*
* @ClassName: ExcelExport
* @Description: TODO(这里用一句话描述这个类的作用)
* @author XuBing
* @date 2018年3月13日 下午4:37:01
*/
public class ExcelExport {
private static final Logger logger = LoggerFactory.getLogger(ExcelExport.class);
/**
* 工作薄对象
*/
private Workbook wb;
/**
* 工作表对象
*/
private Sheet sheet;
/**
* 样式列表
*/
private Map<String, CellStyle> styles;
/**
* 当前行号
*/
private int rownum;
/**
* 注解列表(Object[]{ ExcelField, Field/Method })
*/
List<Object[]> annotationList;
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
* @param type 导出类型(1:导出数据)
*/
public ExcelExport(String title, Class<?> cls){
this(title, cls, Type.EXPORT);
}
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
* @param type 导出类型(1:导出数据;2:导出模板)
* @param groups 导入分组
*/
public ExcelExport(String title, Class<?> cls, Type type, String... groups){
this(null, title, cls, type, groups);
}
/**
* 构造函数
* @param wb 工作簿对象,支持多个Sheet,通过ExcelExport.createWorkbook()创建
* @param sheetName,指定Sheet名称
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
* @param type 导出类型(1:导出数据;2:导出模板)
* @param groups 导入分组
*/
public ExcelExport(Workbook wb, String title, Class<?> cls, Type type, String... groups){
if (wb != null){
this.wb = wb;
}else{
this.wb = createWorkbook();
}
this.createSheet(null, title, cls, type, groups);
}
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
* @param headerList 表头数组
*/
public ExcelExport(String title, List<String> headerList) {
this(null, null, title, headerList);
}
/**
* 构造函数
* @param wb 工作簿对象,支持多个Sheet,通过ExcelExport.createWorkbook()创建
* @param sheetName,指定Sheet名称
* @param title 表格标题,传“空值”,表示无标题
* @param headerList 表头列表
*/
public ExcelExport(Workbook wb, String sheetName, String title, List<String> headerList) {
if (wb != null){
this.wb = wb;
}else{
this.wb = createWorkbook();
}
this.createSheet(sheetName, title, headerList, null);
}
/**
* 创建一个工作簿
*/
private Workbook createWorkbook(){
return new SXSSFWorkbook(500);
}
/**
* 创建工作表
* @param sheetName,指定Sheet名称
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
* @param type 导出类型(1:导出数据;2:导出模板)
* @param groups 导入分组
*/
public void createSheet(String sheetName, String title, Class<?> cls, Type type, String... groups){
this.annotationList = CollUtil.newArrayList();
// Get annotation field
Field[] fs = cls.getDeclaredFields();
for (Field f : fs){
ExcelFields efs = f.getAnnotation(ExcelFields.class);
if (efs != null && efs.value() != null){
for (ExcelField ef : efs.value()){
addAnnotation(annotationList, ef, f, type, groups);
}
}
ExcelField ef = f.getAnnotation(ExcelField.class);
addAnnotation(annotationList, ef, f, type, groups);
}
// Get annotation method
Method[] ms = cls.getDeclaredMethods();
for (Method m : ms){
ExcelFields efs = m.getAnnotation(ExcelFields.class);
if (efs != null && efs.value() != null){
for (ExcelField ef : efs.value()){
addAnnotation(annotationList, ef, m, type, groups);
}
}
ExcelField ef = m.getAnnotation(ExcelField.class);
addAnnotation(annotationList, ef, m, type, groups);
}
// Field sorting
Collections.sort(annotationList, new Comparator<Object[]>() {
@Override
public int compare(Object[] o1, Object[] o2) {
return new Integer(((ExcelField)o1[0]).sort()).compareTo(
new Integer(((ExcelField)o2[0]).sort()));
};
});
// Initialize
List<String> headerList = CollUtil.newArrayList();
List<Integer> headerWidthList = CollUtil.newArrayList();
for (Object[] os : annotationList){
ExcelField ef = (ExcelField)os[0];
String headerTitle = ef.title();
// 如果是导出,则去掉注释
if (type == Type.EXPORT){
String[] ss = Convert.toStrArray(StrUtil.splitTrim(headerTitle,"**", 2));
if (ss.length == 2){
headerTitle = ss[0];
}
}
headerList.add(headerTitle);
headerWidthList.add(ef.width());
}
// 创建工作表
this.createSheet(sheetName, title, headerList, headerWidthList);
}
/**
* 添加到 annotationList
*/
private void addAnnotation(List<Object[]> annotationList, ExcelField ef, Object fOrM, Type type, String... groups){
// if (ef != null && (ef.type()==0 || ef.type()==type)){
if (ef != null && (ef.type() == Type.ALL || ef.type() == type)){
if (groups != null && groups.length > 0){
boolean inGroup = false;
for (String g : groups){
if (inGroup){
break;
}
for (String efg : ef.groups()){
if (StrUtil.equals(g, efg)){
inGroup = true;
annotationList.add(new Object[]{ef, fOrM});
break;
}
}
}
}else{
annotationList.add(new Object[]{ef, fOrM});
}
}
}
/**
* 创建工作表
* @param sheetName,指定Sheet名称
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
* @param type 导出类型(1:导出数据;2:导出模板)
* @param groups 导入分组
*/
public void createSheet(String sheetName, String title, List<String> headerList, List<Integer> headerWidthList) {
this.sheet = wb.createSheet(Convert.toStr(sheetName, Convert.toStr(title, "Sheet1")));
this.styles = createStyles(wb);
// Create title
if (StrUtil.isNotBlank(title)){
Row titleRow = sheet.createRow(rownum++);
titleRow.setHeightInPoints(30);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellStyle(styles.get("title"));
titleCell.setCellValue(title);
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
}
// Create header
if (headerList == null){
throw new ExcelException("headerList not null!");
}
Row headerRow = sheet.createRow(rownum++);
headerRow.setHeightInPoints(16);
for (int i = 0; i < headerList.size(); i++) {
Cell cell = headerRow.createCell(i);
cell.setCellStyle(styles.get("header"));
String[] ss =Convert.toStrArray(StrUtil.splitTrim(headerList.get(i), "**", 2));
if (ss.length==2){
cell.setCellValue(ss[0]);
Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
comment.setRow(cell.getRowIndex());
comment.setColumn(cell.getColumnIndex());
comment.setString(new XSSFRichTextString(ss[1]));
cell.setCellComment(comment);
}else{
cell.setCellValue(headerList.get(i));
}
// sheet.autoSizeColumn(i);
}
boolean isDefWidth = (headerWidthList != null && headerWidthList.size() == headerList.size());
for (int i = 0; i < headerList.size(); i++) {
int colWidth = -1;
if (isDefWidth){
colWidth = headerWidthList.get(i);
}
if (colWidth == -1){
colWidth = sheet.getColumnWidth(i)*2;
colWidth = colWidth < 3000 ? 3000 : colWidth;
}
if (colWidth == 0){
sheet.setColumnHidden(i, true);
}else{
sheet.setColumnWidth(i, colWidth);
}
}
logger.debug("Create sheet {0} success.", sheetName);
}
// /**
// * 构造函数
// * @param title 表格标题,传“空值”,表示无标题
// * @param headers 表头数组
// */
// public ExcelExport(String title, List<String> headerList) {
// this(null, null, title, headerList);
// }
//
// /**
// * 构造函数
// * @param wb 工作簿对象,支持多个Sheet,通过ExcelExport.createWorkbook()创建
// * @param sheetName,指定Sheet名称
// * @param title 表格标题,传“空值”,表示无标题
// * @param headerList 表头列表
// */
// public ExcelExport(Workbook wb, String sheetName, String title, List<String> headerList) {
// initialize(wb, sheetName, title, headerList, null);
// }
/**
* 创建表格样式
* @param wb 工作薄对象
* @return 样式列表
*/
private Map<String, CellStyle> createStyles(Workbook wb) {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
CellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
Font titleFont = wb.createFont();
titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16);
titleFont.setBold(true);
style.setFont(titleFont);
styles.put("title", style);
style = wb.createCellStyle();
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop(BorderStyle.THIN);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
Font dataFont = wb.createFont();
dataFont.setFontName("Arial");
dataFont.setFontHeightInPoints((short) 10);
style.setFont(dataFont);
styles.put("data", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(HorizontalAlignment.LEFT);
styles.put("data1", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(HorizontalAlignment.CENTER);
styles.put("data2", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(HorizontalAlignment.RIGHT);
styles.put("data3", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
// style.setWrapText(true);
style.setAlignment(HorizontalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
Font headerFont = wb.createFont();
headerFont.setFontName("Arial");
headerFont.setFontHeightInPoints((short) 10);
headerFont.setBold(true);
headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont);
styles.put("header", style);
return styles;
}
/**
* 添加一行
* @return 行对象
*/
public Row addRow(){
return sheet.createRow(rownum++);
}
/**
* 添加一个单元格
* @param row 添加的行
* @param column 添加列号
* @param val 添加值
* @return 单元格对象
*/
public Cell addCell(Row row, int column, Object val){
return this.addCell(row, column, val, Align.AUTO, Class.class, null);
}
/**
* 添加一个单元格
* @param row 添加的行
* @param column 添加列号
* @param val 添加值
* @param align 对齐方式(1:靠左;2:居中;3:靠右)
* @param dataFormat 数值格式(例如:0.00,yyyy-MM-dd)
* @return 单元格对象
*/
public Cell addCell(Row row, int column, Object val, Align align, Class<?> fieldType, String dataFormat){
Cell cell = row.createCell(column);
String defaultDataFormat = "@";
try {
if(val == null){
cell.setCellValue("");
}else if(fieldType != Class.class){
cell.setCellValue((String)fieldType.getMethod("setValue", Object.class).invoke(null, val));
try{
defaultDataFormat = (String)fieldType.getMethod("getDataFormat").invoke(null);
} catch (Exception ex) {
defaultDataFormat = "@";
}
}else{
if(val instanceof String) {
cell.setCellValue((String) val);
}else if(val instanceof Integer) {
cell.setCellValue((Integer) val);
defaultDataFormat = "0";
}else if(val instanceof Long) {
cell.setCellValue((Long) val);
defaultDataFormat = "0";
}else if(val instanceof Double) {
cell.setCellValue((Double) val);
defaultDataFormat = "0.00";
}else if(val instanceof Float) {
cell.setCellValue((Float) val);
defaultDataFormat = "0.00";
}else if(val instanceof Date) {
cell.setCellValue((Date) val);
defaultDataFormat = "yyyy-MM-dd HH:mm";
}else {
cell.setCellValue((String)Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
"fieldtype."+val.getClass().getSimpleName()+"Type")).getMethod("setValue", Object.class).invoke(null, val));
}
}
// if (val != null){
CellStyle style = styles.get("data_column_"+column);
if (style == null){
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"+(align.value()>=1&&align.value()<=3?align.value():"")));
if (dataFormat != null){
defaultDataFormat = dataFormat;
}
style.setDataFormat(wb.createDataFormat().getFormat(defaultDataFormat));
styles.put("data_column_" + column, style);
}
cell.setCellStyle(style);
// }
} catch (Exception ex) {
logger.info("Set cell value [{},{}] error: {}",row.getRowNum(),column, ex.toString());
cell.setCellValue(val.toString());
}
return cell;
}
/**
* 添加数据(通过annotation.ExportField添加数据)
* @return list 数据列表
*/
public <E> ExcelExport setDataList(List<E> list){
for (E e : list){
int colunm = 0;
Row row = this.addRow();
StringBuilder sb = new StringBuilder();
for (Object[] os : annotationList){
ExcelField ef = (ExcelField)os[0];
Object val = null;
// Get entity value
try{
if (StrUtil.isNotBlank(ef.attrName())){
val = ReflectUtil.getFieldValue(e, ef.attrName());
}else{
if (os[1] instanceof Field){
val = ReflectUtil.getFieldValue(e, ((Field)os[1]).getName());
}else if (os[1] instanceof Method){
val = ReflectUtil.invoke(e, ((Method)os[1]).getName(), new Class[] {}, new Object[] {});
}
}
// If is dict, get dict label
if (StrUtil.isNotBlank(ef.dictType())){
Class<?> dictUtils = Class.forName("com.jeesite.modules.sys.utils.DictUtils");
val = dictUtils.getMethod("getDictLabel", String.class, String.class,
String.class).invoke(null, val==null?"":val.toString(), ef.dictType(), "");
//val = DictUtils.getDictLabel(val==null?"":val.toString(), ef.dictType(), "");
}
}catch(Exception ex) {
// Failure to ignore
logger.info(ex.toString());
val = "";
}
String dataFormat = ef.dataFormat();
this.addCell(row, colunm++, val, ef.align(), ef.fieldType(), dataFormat);
sb.append(val + ", ");
}
logger.debug("Write success: [{}] {}",row.getRowNum(),sb.toString());
}
return this;
}
/**
* 输出数据流
* @param os 输出数据流
*/
public ExcelExport write(OutputStream os){
try{
wb.write(os);
}catch(IOException ex){
logger.error(ex.getMessage(), ex);
} finally{
FortifyUtil.close(os);
}
return this;
}
/**
* 输出到客户端
* @param fileName 输出文件名
*/
public ExcelExport write(HttpServletResponse response, String fileName){
response.reset();
response.setContentType("application/octet-stream; charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+URLUtil.encode(fileName));
try {
write(response.getOutputStream());
} catch (IOException ex) {
logger.error(ex.getMessage(), ex);
}
return this;
}
/**
* 输出到文件
* @param fileName 输出文件名
*/
public ExcelExport writeFile(String name) throws FileNotFoundException{
FileOutputStream os = null;
try {
os = new FileOutputStream(name);
this.write(os);
} catch (FileNotFoundException e) {
throw e;
} finally {
FortifyUtil.close(os);
}
return this;
}
/**
* 清理临时文件
*/
public ExcelExport dispose(){
if (wb instanceof SXSSFWorkbook){
((SXSSFWorkbook)wb).dispose();
}
return this;
}
// /**
// * 导出测试
// */
// public static void main(String[] args) throws Throwable {
//
// List<String> headerList = CollUtil.newArrayList();
// for (int i = 1; i <= 10; i++) {
// headerList.add("表头"+i);
// }
//
// List<String> dataRowList = CollUtil.newArrayList();
// for (int i = 1; i <= headerList.size(); i++) {
// dataRowList.add("数据"+i);
// }
//
// List<List<String>> dataList = CollUtil.newArrayList();
// for (int i = 1; i <=100; i++) {
// dataList.add(dataRowList);
// }
//
// ExcelExport ee = new ExcelExport("表格标题", headerList);
//
// for (int i = 0; i < dataList.size(); i++) {
// Row row = ee.addRow();
// for (int j = 0; j < dataList.get(i).size(); j++) {
// ee.addCell(row, j, dataList.get(i).get(j));
// }
// }
//
// ee.writeFile("target/export.xlsx");
//
// ee.dispose();
//
// //log.debug("Export success.");
//
// }
}
ProjectExcel文件:
package com.glens.pwCloud.project.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import com.glens.common.excel.ExcelField;
public class ProjectExcel implements Serializable{
/**
*
*/
private static final long serialVersionUID = -504439323077191027L;
@ExcelField(title="项目名称", type= ExcelField.Type.ALL, sort=1)
private String projectName;
@ExcelField(title="预算", type= ExcelField.Type.ALL, sort=2)
private BigDecimal totalBudget;
@ExcelField(title="紧急程度", type= ExcelField.Type.ALL, sort=3)
private String emergencyExtName;
@ExcelField(title="施工队长", type= ExcelField.Type.ALL, sort=4)
private String constructionCaptainName;
@ExcelField(title="土建施工队长", type= ExcelField.Type.ALL, sort=5)
private String civilConstructionCaptainName;
@ExcelField(title="电气安装队长", type= ExcelField.Type.ALL, sort=6)
private String electricalInstallCaptainName;
@ExcelField(title="物资领料员", type= ExcelField.Type.ALL, sort=7)
private String materialPickerName;
@ExcelField(title="政处推进员", type= ExcelField.Type.ALL, sort=8)
private String politicalOfficePromoterName;
@ExcelField(title="资料归档员", type= ExcelField.Type.ALL, sort=9)
private String dataFilerName;
@ExcelField(title="结算编制员", type= ExcelField.Type.ALL, sort=9)
private String settlementCompilerName;
@ExcelField(title="设计变更员", type= ExcelField.Type.ALL, sort=9)
private String designChangerName;
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public BigDecimal getTotalBudget() {
return totalBudget;
}
public void setTotalBudget(BigDecimal totalBudget) {
this.totalBudget = totalBudget;
}
public String getEmergencyExtName() {
return emergencyExtName;
}
public void setEmergencyExtName(String emergencyExtName) {
this.emergencyExtName = emergencyExtName;
}
public String getConstructionCaptainName() {
return constructionCaptainName;
}
public void setConstructionCaptainName(String constructionCaptainName) {
this.constructionCaptainName = constructionCaptainName;
}
public String getCivilConstructionCaptainName() {
return civilConstructionCaptainName;
}
public void setCivilConstructionCaptainName(String civilConstructionCaptainName) {
this.civilConstructionCaptainName = civilConstructionCaptainName;
}
public String getElectricalInstallCaptainName() {
return electricalInstallCaptainName;
}
public void setElectricalInstallCaptainName(String electricalInstallCaptainName) {
this.electricalInstallCaptainName = electricalInstallCaptainName;
}
public String getMaterialPickerName() {
return materialPickerName;
}
public void setMaterialPickerName(String materialPickerName) {
this.materialPickerName = materialPickerName;
}
public String getPoliticalOfficePromoterName() {
return politicalOfficePromoterName;
}
public void setPoliticalOfficePromoterName(String politicalOfficePromoterName) {
this.politicalOfficePromoterName = politicalOfficePromoterName;
}
public String getDataFilerName() {
return dataFilerName;
}
public void setDataFilerName(String dataFilerName) {
this.dataFilerName = dataFilerName;
}
public String getSettlementCompilerName() {
return settlementCompilerName;
}
public void setSettlementCompilerName(String settlementCompilerName) {
this.settlementCompilerName = settlementCompilerName;
}
public String getDesignChangerName() {
return designChangerName;
}
public void setDesignChangerName(String designChangerName) {
this.designChangerName = designChangerName;
}
}
这篇博客探讨了Java后台处理文件的几个关键问题,包括如何处理文件后缀,实现图片传入前台,以及如何导出Excel文件。在文件后缀问题中,讲解了如何获取文件名和判断文件类型。图片获取部分介绍了通过文件流和FastDFS工具类实现文件下载,并指出如何调整以实现预览功能。最后,文章提到了Excel文件的导出过程。

被折叠的 条评论
为什么被折叠?



