POI中操作PPT获得每页的TABLE
HSLFSlideShow slideShow = new HSLFSlideShow(bufferInputUtil.getBufferedInputStream()); logger.info("正在脱敏:每页幻灯片的文本和表格内容"); for (HSLFSlide slide : slideShow.getSlides()) { for (HSLFShape hslfShape : slide.getShapes()) { if (hslfShape instanceof HSLFTable) { hslfTable = (HSLFTable) hslfShape; rowSize = hslfTable.getNumberOfRows(); columnSize = hslfTable.getNumberOfColumns(); for (int i = 0; i < rowSize; i++) { for (int j = 0; j < columnSize; j++) { cellValue = hslfTable.getCell(i, j).getText(); if (StringUtils.isNotBlank(cellValue) && StringUtils.isNotEmpty(cellValue)) { hslfTable.getCell(i, j).setText(this.getReplace(cellValue)); } } } } else if (hslfShape instanceof HSLFTextShape) { textShape = (HSLFTextShape) hslfShape; cellValue = textShape.getText(); if (StringUtils.isNotBlank(cellValue) && StringUtils.isNotEmpty(cellValue)) { textShape.setText(this.getReplace(cellValue)); } } } }
请见红色代码!
本文来自博客园,作者:huiy_小溪,转载请注明原文链接:https://www.cnblogs.com/huiy/p/6000873.html