POI中操作PPT获得每页的TABLE

时间:2025-01-21 13:03:21
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));
}
}
}
}
 
请见红色代码!