You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Troll <nu...@mail.ru> on 2010/11/29 12:12:40 UTC

Can't obtain the input stream from /docProps/app.xml

Hello, i'm using POI-3.7 
and i need to delete sheet and save xlsm file. I do next : 


XSSFWorkbook workbook = new XSSFWorkbook(OPCPackage.open(filePath));
		List<String> list = Arrays.asList(new String[]{"TRSCN_LOG ", "MAIN_SHEET
sedol", "INDICES", "CURNCY", "INITIAL_VALUES"});
		for(int i=0; i<10; i++){
			try{
			Sheet sheet = workbook.getSheetAt(i);
			if(sheet != null && !list.contains(sheet.getSheetName()))
				workbook.removeSheetAt(i);
			}catch (Exception e) {}
		}
		workbook.write(new FileOutputStream(filePath));


and after i get: 

Can't obtain the input stream from /docProps/app.xml 

what do i do wrong?? help please! 

Thanks! 

-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-t-obtain-the-input-stream-from-docProps-app-xml-tp3284222p3284222.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Can't obtain the input stream from /docProps/app.xml

Posted by Troll <nu...@mail.ru>.
no no, i don't use.

Try to delete last sheet from the attached file, save and after open saved
file using Excel. And i'm sure u'll see the error! 
http://apache-poi.1045710.n5.nabble.com/file/n3288157/RAW_DATA_CONVERTED.xlsm
RAW_DATA_CONVERTED.xlsm 

Actually in delete methos i have next:

		OPCPackage opcPackage = OPCPackage.open(filePath);
		XSSFWorkbook workbook = new XSSFWorkbook(opcPackage)
workbook.removeSheetAt(number);
workbook.write(new
FileOutputStream("c://BloombergData/CONVERTED/tmp.xlsm"));



-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-t-obtain-the-input-stream-from-docProps-app-xml-tp3284222p3288157.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Can't obtain the input stream from /docProps/app.xml

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Had a look through the stack trace and was interested to see this;

        at bc.Converter.deleteAsposeSheet(Converter.java:131)
	at bc.Converter.convertToRawData(Converter.java:55)
	at bc.SchedulerEvent$1.run(SchedulerEvent.java:50)

paritularly the deleteAsposeSheet() method class. Does that mean that you
are using Aspose to manipulate the workbooks and that they have embedded
code from POI to actually perform the processing I guess? If so, would not
Aspose be the best place to ask this question, I guess they have a similar
forum.

Yours

Mark B

-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-t-obtain-the-input-stream-from-docProps-app-xml-tp3284222p3286026.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Can't obtain the input stream from /docProps/app.xml

Posted by Troll <nu...@mail.ru>.
yes u right with it. But when i delete sheet from *.xlsm file and save. After
i open in Excel and i see the dialog that part of content was losted at part 
/xl/workbook.xml.

How to delete sheet ?
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-t-obtain-the-input-stream-from-docProps-app-xml-tp3284222p3285816.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Can't obtain the input stream from /docProps/app.xml

Posted by Gabriel Molina <sk...@gmail.com>.
Hello,

I think the problem here is that you are using the same filePath for
opening and saving the file.
You need an InputStream for read and work with your file, but this
stream becames unaccessible when you create an
OutputStream under the same path and file name.
I think the solution is to make a copy (say myFile.tmp) before start
working, open the copy to work, save in the original path
(myFile.xslx) and delete the copy.

Regards.


On Mon, Nov 29, 2010 at 5:58 AM, Troll <nu...@mail.ru> wrote:
>
> yes, even if i didn't change file: just open and save i get anyway
>
> SEVERE: java.io.IOException: Can't obtain the input stream from
> /docProps/app.xml
> org.apache.poi.POIXMLException: java.io.IOException: Can't obtain the input
> stream from /docProps/app.xml
>        at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:172)
>        at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:208)
>        at bc.Converter.deleteAsposeSheet(Converter.java:131)
>        at bc.Converter.convertToRawData(Converter.java:55)
>        at bc.SchedulerEvent$1.run(SchedulerEvent.java:50)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at bc.SchedulerEvent.run(SchedulerEvent.java:36)
>        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>        at
> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
>        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:662)
> Caused by: java.io.IOException: Can't obtain the input stream from
> /docProps/app.xml
>        at
> org.apache.poi.openxml4j.opc.PackagePart.getInputStream(PackagePart.java:468)
>        at org.apache.poi.POIXMLProperties.<init>(POIXMLProperties.java:75)
>        at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:170)
>        ... 15 more
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-t-obtain-the-input-stream-from-docProps-app-xml-tp3284222p3284276.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>



-- 
ちりも積もれば山となる

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Can't obtain the input stream from /docProps/app.xml

Posted by Troll <nu...@mail.ru>.
yes, even if i didn't change file: just open and save i get anyway 

SEVERE: java.io.IOException: Can't obtain the input stream from
/docProps/app.xml
org.apache.poi.POIXMLException: java.io.IOException: Can't obtain the input
stream from /docProps/app.xml
	at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:172)
	at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:208)
	at bc.Converter.deleteAsposeSheet(Converter.java:131)
	at bc.Converter.convertToRawData(Converter.java:55)
	at bc.SchedulerEvent$1.run(SchedulerEvent.java:50)
	at java.security.AccessController.doPrivileged(Native Method)
	at bc.SchedulerEvent.run(SchedulerEvent.java:36)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Can't obtain the input stream from
/docProps/app.xml
	at
org.apache.poi.openxml4j.opc.PackagePart.getInputStream(PackagePart.java:468)
	at org.apache.poi.POIXMLProperties.<init>(POIXMLProperties.java:75)
	at org.apache.poi.POIXMLDocument.getProperties(POIXMLDocument.java:170)
	... 15 more


-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-t-obtain-the-input-stream-from-docProps-app-xml-tp3284222p3284276.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Can't obtain the input stream from /docProps/app.xml

Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 29 Nov 2010, Troll wrote:
> and after i get:
>
> Can't obtain the input stream from /docProps/app.xml
>
> what do i do wrong?? help please!

If you just open and save the file, without edits, does that work? Does 
your file contain a /docProps/app.xml in it? Or is that xml file missing?

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org