JAVA POI 如何编写代码实现在EXCEL2007的页眉中插入图片,JAVA新手求解 20
2个回答
展开全部
你好,可以试试以下代码,我用是没问题的:
WritableSheet s = w.createSheet("Report", 0);
BufferedImage input = ImageIO.read(new URL("http://example.com/image.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(input, "PNG", baos);
s.addImage(new WritableImage(0,0,input.getWidth() / CELL_DEFAULT_WIDTH, input.getHeight() / CELL_DEFAULT_HEIGHT,baos.toByteArray()));
s.mergeCells(0,0,0,2);
WritableSheet s = w.createSheet("Report", 0);
BufferedImage input = ImageIO.read(new URL("http://example.com/image.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(input, "PNG", baos);
s.addImage(new WritableImage(0,0,input.getWidth() / CELL_DEFAULT_WIDTH, input.getHeight() / CELL_DEFAULT_HEIGHT,baos.toByteArray()));
s.mergeCells(0,0,0,2);
更多追问追答
追问
我这是用POI 定义XSSFWorkbook workBook = new XSSFWorkbook();
XSSFSheet sheet=workBook.createSheet("信息");的,好像用不了你的方法
追答
用我发给你的累
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询