假设存在这样一张表A (audience),观众表
id,zjhm,name,gender,address
表B(seat),座位表,表明这个观众主动坐过哪些座位
id,
表C(check),校核表,表明这个观众被系统管理人员校核过哪些座位
id
Excel中插入图片方法
参数1: 工作薄
参数2: 工作表名
参数3: 网络图片地址
参数4: 图片插入到哪一行
参数5: 图片插入到哪一列
public static void insertImage(XSSFWorkbook workbook, String sheetName,String imageUrl,int row,int col) {try {URL url = new URL(imageUrl);HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.setRequestMethod("GET");conn.setConnectTimeout(5000);InputStream inputStream = InputStream();XSSFSheet sheet = Sheet(sheetName);XSSFDrawing patriarch = ateDrawingPatriarch();XSSFClientAnchor anchor = new XSSFClientAnchor(0,0,255,255,col,row,col+1,row+1);// 图片自适应单元格大小anchor.setAnchorType(AnchorType.byId(0));atePicture(anchor,workbook.addPicture(inputStream,XSSFWorkbook.PICTURE_TYPE_WPG));} catch (Exception e) {e.printStackTrace();}}
调用
int startRowIndex = 2;int endRowIndex = 1;for (Audience audience : audienceList) {int checkSize = CheckList().size();int seatSize = SeatList().size();if (checkSize >= seatSize) {endRowIndex += checkSize;} else {endRowIndex += seatSize;}for (int i = 0; i < SeatList().size(); i++) {AliPersonFace child = SeatList().get(i);ExcelUtil.insertImage(xssfWorkbook, sheetName, ImageUrl(), startRowIndex + i, 10);}startRowIndex = endRowIndex + 1;}
待加:
本文发布于:2024-01-28 09:50:36,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17064066426564.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |