public class XMLDrawings extends Object implements Drawings
drawing.xml和cellimages.xml,
后者是WPS自定义的嵌入图片,内嵌图片是整个工作薄全局共享的所以无法不包含单元格信息,
为了和Excel图片图片统一接口需要先解析工作表然后再和内嵌图片的ID进行映射,由于会对工作表
进行两次读取所以对性能有一定影响,行数小于1万影响不大可放心使用,当然你也可以直接
调用本类的listCellImages(ZipFile, ZipEntry)方法获取图片ID映射,然后在读取
工作表时自己进行ID和单元格行列映射,这样做只会进行一次工作表读不会影响正常的读取性能。
参考文档:
Drawings.Picture| 限定符和类型 | 字段和说明 |
|---|---|
protected ExcelReader |
excelReader
ExcelReader
|
protected org.slf4j.Logger |
LOGGER
LOGGER
|
protected boolean |
parsed
是否已解析,保证数据只被解析一次
|
protected List<Drawings.Picture> |
pictures
临时保存所有工作表包含的图片
|
| 构造器和说明 |
|---|
XMLDrawings(ExcelReader reader) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected static int[] |
dimEle(org.dom4j.Element e,
org.dom4j.Namespace xdr) |
protected boolean |
ignoreHiddenPicture()
是否忽略隐藏图片
|
Map<String,Path> |
listCellImages(ZipFile zipFile,
ZipEntry entry)
拉取WPS单元格内嵌图片
|
List<Drawings.Picture> |
listPictures()
列出所有工作表包含的图片
|
protected List<Drawings.Picture> |
parse()
解析图片
|
protected static int[][] |
parseDimension(org.dom4j.Element e,
org.dom4j.Namespace xdr) |
protected List<Drawings.Picture> |
parseDrawings(ZipFile zipFile,
ZipEntry entry,
Path imagesPath) |
protected List<Drawings.Picture> |
quickFindCellImages(Sheet sheet,
Map<String,Path> cellImageMapper)
快整查询内嵌图片在工作表中的位置
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitlistPicturesprotected final org.slf4j.Logger LOGGER
protected final ExcelReader excelReader
protected List<Drawings.Picture> pictures
protected boolean parsed
public XMLDrawings(ExcelReader reader)
public List<Drawings.Picture> listPictures()
listPictures 在接口中 DrawingsPicture数组, 不存在图片返回null.protected List<Drawings.Picture> parse()
Pictureprotected List<Drawings.Picture> parseDrawings(ZipFile zipFile, ZipEntry entry, Path imagesPath)
protected static int[][] parseDimension(org.dom4j.Element e,
org.dom4j.Namespace xdr)
protected static int[] dimEle(org.dom4j.Element e,
org.dom4j.Namespace xdr)
public Map<String,Path> listCellImages(ZipFile zipFile, ZipEntry entry)
zipFile - xlsx源entry - cellImagesprotected List<Drawings.Picture> quickFindCellImages(Sheet sheet, Map<String,Path> cellImageMapper) throws IOException
sheet - 工作表cellImageMapper - 图片ID映射关系IOException - if I/O error occurprotected boolean ignoreHiddenPicture()
true忽略Copyright © 2025. All rights reserved.