You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Crocuta <bf...@gmail.com> on 2011/10/04 21:17:53 UTC
XSSF: JRun locking document
I'm attempting to get our system to read not only xls but xlsx files and have
it reading the xlsx files fine, however, once they've been touched by the
system the files get locked by JRun until the service is restarted.
Effectively I'm just creating a workbook object, then reading from it.
Here's some code:
LOCAL.FileInputStream = CreateObject( "java", "java.io.FileInputStream"
).Init( ARGUMENTS.FilePath );
LOCAL.WorkBook = CreateObject(
"java",
"org.apache.poi.xssf.usermodel.XSSFWorkbook"
).Init(
ARGUMENTS.FilePath
);
LOCAL.Sheets = ReadExcelSheet(
LOCAL.WorkBook,
ARGUMENTS.SheetIndex,
ARGUMENTS.HasHeaderRow
);
LOCAL.FileInputStream.Close();
So, once this runs I'm no longer able to modify the xlsx document. The
first thing that I notice is that I'm not creating the workbook with the
fileInputStream variable. When I try to use it, as opposed to the filepath
variable, it throws an error so the fileInputStream open and close doesn't
actually do anything. I removed both and it still worked, however JRun
still locks the file. What do I need to do to close the stream or whatever
it is that's locking the document
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-JRun-locking-document-tp4870023p4870023.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: XSSF: JRun locking document
Posted by Leigh <cf...@yahoo.com>.
Can you post a small, self-contained example that duplicates the problem in JRUN so I can try it out?
-Leigh
Re: XSSF: JRun locking document
Posted by Leigh <cf...@yahoo.com>.
> I've gotten rid of the file input stream and the code functionality still
> works, however JRun is still locking the file as well.
Weird. Just calling init() on XSSFWorkbook seems to do it. Might try using the WorkBookFactory instead.
WorkbookFactory = CreateObject("java", "org.apache.poi.ss.usermodel.WorkbookFactory");
LOCAL.FileInputStream = CreateObject( "java", "java.io.FileInputStream").Init( ARGUMENTS.FilePath );
LOCAL.WorkBook = WorkbookFactory.create(LOCAL.FileInputStream);
-Leigh
Re: XSSF: JRun locking document
Posted by Crocuta <bf...@gmail.com>.
Nick Burch-11 wrote:
>
> You're much better off opening from the File object directly, rather than
> going via an input stream - it's much faster and lower memory
>
> Switching to that may well solve your problem too
>
I've gotten rid of the file input stream and the code functionality still
works, however JRun is still locking the file as well.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-JRun-locking-document-tp4870023p4873167.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: XSSF: JRun locking document
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 4 Oct 2011, Crocuta wrote:
> Here's some code:
>
> LOCAL.FileInputStream = CreateObject( "java", "java.io.FileInputStream"
> ).Init( ARGUMENTS.FilePath );
You're much better off opening from the File object directly, rather than
going via an input stream - it's much faster and lower memory
Switching to that may well solve your problem too
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org