JSD-9277 导出excel文件属性自定义
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

/**
* Copyright (C), 2015-2020
* FileName: PageExcelPlusExporter
* Author: Louis
* Date: 2020/3/22 20:36
* Description: PageExcelPlusExporter
* History:
* <author> <time> <version> <desc>
*/
package com.fr.plugin.ibgq.export;
import com.fr.io.exporter.AppExporter;
import com.fr.io.exporter.PageExcelExporter;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.page.PaperSettingProvider;
import com.fr.plugin.ibgq.utils.ExcelHandler;
import com.fr.third.v2.org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.List;
/**
* Function Description<br>
* PageExcelPlusExporter
*
* @author fr.open
* @since 1.0.0
*/
public class PageExcelPlusExporter extends PageExcelExporter {
public PageExcelPlusExporter(List list) {
super(list);
}
@Override
protected void exportFor2003(OutputStream outputStream, ResultWorkBook resultWorkBook, boolean b, boolean b1) throws Exception {
File file = File.createTempFile("ibgq", ".xls");
FileOutputStream fileOutputStream = new FileOutputStream(file);
super.exportFor2003(fileOutputStream, resultWorkBook, b, b1);
fileOutputStream.close();
FileInputStream fileInputStream = new FileInputStream(file);
HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
ExcelHandler.setCustomProperties(resultWorkBook, workbook);
workbook.write(outputStream);
outputStream.flush();
}
@Override
protected AppExporter getExporterFor2007(List<PaperSettingProvider> list) throws ClassNotFoundException {
return new PageExcel2007PlusExporter(list);
}
}