在我的应用程序中,我使用POI API生成Excel文件.文档的左上角之一保留图像.我得到的问题是图像被拉伸以填充容纳它的单元格.
根据我在Picture对象上使用的调整大小的方法,图像以各种大小显示,但它始终具有其所在单元格所具有的水平 – 垂直比率,换句话说,它不会保持自己的比例.
这是我的代码:
titleRow = sheet.createRow(0);
titleRow.setHeightInPoints(25f);
titleRow.createCell(0);
sheet.getRow(0).getCell(0).setCellStyle(defaultTitleStyle(wb));
WebApplicationContext webCtx = ((WebApplicationContext)AtlasApplicationUtils.getCurrentApplication().getContext());
ServletContext sc = webCtx.getHttpSession().getServletContext();
String contextPath = sc.getContextPath();
// sc.getResourceAsStream(contextPath + "/VAADIN/themes/m2m/../m2m/img/gnd_logo_white.png")
String f = new File("").getAbsolutePath();
InputStream is = new FileInputStream(System.getProperty("user.dir") + "/src/main/webapp/VAADIN/themes/m2m/img/gnd_logo_white.png