如何PackPart获取OLEObject行和列索引

时间:2019-02-18 10:33:12

标签: java apache-poi

我在Java 1.8中使用POI在excel中读取OLEObject。在下面的代码中我读取OLEObject 并存储在文件夹中。我需要excel读取部分以获取OLEObject行位置 (即)getAllEmbedds packpart方法到OLEObject行位置。

if (workbook instanceof XSSFWorkbook)
{
try
{
XSSFWorkbook fWorkbook = (XSSFWorkbook) workbook;
PackagePart pPart = null;
Iterator<PackagePart> pIter = null;
List<PackagePart> embeddedDocs = fWorkbook.getAllEmbedds();
int index=1;

OutputStream outputStream = null;

if (embeddedDocs != null && !embeddedDocs.isEmpty())
{
pIter = embeddedDocs.iterator();

while (pIter.hasNext())
{
pPart = pIter.next();

try
{

outputStream = new FileOutputStream(new File("...filestorepath/"+index+".pdf"));
index++;
}
catch (FileNotFoundException ex)
{
Logger.getLogger(packaeParExample.class.getName()).log(Level.SEVERE, null, ex);
}

int read = 0;
byte[] bytes = new byte[1024];

try
{
while ((read = inputStream.read(bytes)) != -1)
{
outputStream.write(bytes, 0, read);
}
}
catch (IOException ex)
{
Logger.getLogger(packaeParExample.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
catch (OpenXML4JException ex)
{
Logger.getLogger(packaeParExample.class.getName()).log(Level.SEVERE, null, ex);
}
}

0 个答案:

没有答案