| | |
| | | // if (Files.exists(Paths.get(imagePath))) { |
| | | // byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath)); |
| | | // 将byte数组转换成inputstream,以便插入到Excel中 |
| | | ClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 100, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 5), |
| | | cell.getRow().getRowNum() + 1); |
| | | ClientAnchor anchor = new HSSFClientAnchor(813, 0, 787, 71, (short) 2, 0, (short) 4, |
| | | 1); |
| | | |
| | | |
| | | |
| | | // ClientAnchor anchor = new HSSFClientAnchor(813, 0, 787, 71, (short) 2, 0, (short) 4, |
| | | // 2); |
| | | // 设置锚点类型为MOVE_AND_RESIZE,使图片可以随单元格调整大小 |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE); |
| | | // 计算居中位置 |
| | | int col1 = 3; // 中间列 |
| | | int col2 = col1 + 2; |
| | | anchor.setCol1(col1); |
| | | anchor.setCol2(col2); |
| | | anchor.setRow1(0); |
| | | anchor.setRow2(1); |
| | | // int col1 = 3; // 中间列 |
| | | // int col2 = col1 + 2; |
| | | // anchor.setCol1(col1); |
| | | // anchor.setCol2(col2); |
| | | // anchor.setRow1(0); |
| | | // anchor.setRow2(1); |
| | | // anchor.set |
| | | // anchor.setHorizontallyCenter(true); |
| | | |
| | |
| | | HSSFSheet hssfSheet = hssfWb.getSheetAt(index); |
| | | HSSFHeader header = hssfSheet.getHeader(); |
| | | // 设置页眉字体 |
| | | // header.setFontName("宋体"); |
| | | // header.setFontName("宋体");4 |
| | | // header.setFontSize((short) 10); |
| | | // 设置页眉内容 |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 2.1); |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 1.34); |
| | | header.setRight("&\"宋体,Bold\"共 &N 页 第 &P 页"); |
| | | } |
| | | // 如果是index为1的sheet,设置顶端标题行 |