Could not auto-size column. Make sure the column was tracked prior to auto-s......
注释ExportExcel.java中
sheet.autoSizeColumn(i);
加密方法,记录:
public static byte[] getByteDataSource(String title,List<?> list, String password, Class<?> pojoClass) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ExportExcel(title, pojoClass, 1).setDataList(list).write(baos).dispose();
//创建excel解析对象
POIFSFileSystem fs = new POIFSFileSystem();
EncryptionInfo info = new EncryptionInfo(EncryptionMode.standard);
Encryptor enc = info.getEncryptor();
//设置密码
enc.confirmPassword(password);
//加密文件
OPCPackage opc = OPCPackage.open(new ByteArrayInputStream(baos.toByteArray()));
baos.close();
OutputStream os = enc.getDataStream(fs);
opc.save(os);
opc.close();
fs.writeFilesystem(out); //把加密后的文件写回到流
fs.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return out.toByteArray();
}
其他:maven-shade-plugin可以解决依赖包多版本引用