You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Joseph Price <jo...@numbersplace.com> on 2016/04/07 16:19:24 UTC
Validating office files without saving them
Hello,
I am using POI to determine whether or not an existing office file is valid. For Excel files, I am using
Workbook workbook = WorkbookFactory.create(java.io.File file);
If that succeeds without throwing an exception, I assume the file is valid, and then I close it in a finally block:
workbook.close();
The problem is that the close method is saving the file, which I don't want. Is there a way to close the workbook without modifying the file on disk?
Thanks,
Joe
Re: Validating office files without saving them
Posted by Dominik Stadler <do...@gmx.at>.
Yes, there are more and more indicators that the automatic save on close()
is counter-intuitive and we should start discussion about a write() method
that allows users to specifically choose this.
I have created https://bz.apache.org/bugzilla/show_bug.cgi?id=59287 to
allow for patches and discussions.
Dominik.
On Thu, Apr 7, 2016 at 5:31 PM, Joseph Price <jo...@numbersplace.com>
wrote:
> Thanks Timothy & Javen ... I should have seen that in the javadocs.
>
> -Joe
>
> ________________________________________
> From: Javen O'Neal <ja...@gmail.com>
> Sent: Thursday, April 7, 2016 11:04 AM
> To: POI Users List
> Subject: Re: Validating office files without saving them
>
> Another example that close's save behavior is surprising to users. At
> a minimum, this should not modify the file on disk, since nothing
> changes (besides last accessed date),
>
> Workbook wb = WorkbookFactory.create(aFile, null, false);
> wb.close();
> // for unit test, assertCloseDoesNotModifyFile(wb, aFilename);
>
> On Thu, Apr 7, 2016 at 7:35 AM, Allison, Timothy B. <ta...@mitre.org>
> wrote:
> > Thanks to Javen and Dominik, I just learned this one myself...
> >
> > Workbook workbook = WorkbookFactory.create(java.io.File file, null,
> true);
> >
> >
> > -----Original Message-----
> > From: Joseph Price [mailto:joseph.price@numbersplace.com]
> > Sent: Thursday, April 07, 2016 10:19 AM
> > To: user@poi.apache.org
> > Subject: Validating office files without saving them
> >
> > Hello,
> >
> >
> > I am using POI to determine whether or not an existing office file is
> valid. For Excel files, I am using
> >
> >
> > Workbook workbook = WorkbookFactory.create(java.io.File file);
> >
> >
> > If that succeeds without throwing an exception, I assume the file is
> valid, and then I close it in a finally block:
> >
> >
> > workbook.close();
> >
> >
> > The problem is that the close method is saving the file, which I don't
> want. Is there a way to close the workbook without modifying the file on
> disk?
> >
> >
> > Thanks,
> >
> > Joe
> >
> > ---------------------------------------------------------------------
> > 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Validating office files without saving them
Posted by Joseph Price <jo...@numbersplace.com>.
Thanks Timothy & Javen ... I should have seen that in the javadocs.
-Joe
________________________________________
From: Javen O'Neal <ja...@gmail.com>
Sent: Thursday, April 7, 2016 11:04 AM
To: POI Users List
Subject: Re: Validating office files without saving them
Another example that close's save behavior is surprising to users. At
a minimum, this should not modify the file on disk, since nothing
changes (besides last accessed date),
Workbook wb = WorkbookFactory.create(aFile, null, false);
wb.close();
// for unit test, assertCloseDoesNotModifyFile(wb, aFilename);
On Thu, Apr 7, 2016 at 7:35 AM, Allison, Timothy B. <ta...@mitre.org> wrote:
> Thanks to Javen and Dominik, I just learned this one myself...
>
> Workbook workbook = WorkbookFactory.create(java.io.File file, null, true);
>
>
> -----Original Message-----
> From: Joseph Price [mailto:joseph.price@numbersplace.com]
> Sent: Thursday, April 07, 2016 10:19 AM
> To: user@poi.apache.org
> Subject: Validating office files without saving them
>
> Hello,
>
>
> I am using POI to determine whether or not an existing office file is valid. For Excel files, I am using
>
>
> Workbook workbook = WorkbookFactory.create(java.io.File file);
>
>
> If that succeeds without throwing an exception, I assume the file is valid, and then I close it in a finally block:
>
>
> workbook.close();
>
>
> The problem is that the close method is saving the file, which I don't want. Is there a way to close the workbook without modifying the file on disk?
>
>
> Thanks,
>
> Joe
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Validating office files without saving them
Posted by Javen O'Neal <ja...@gmail.com>.
Another example that close's save behavior is surprising to users. At
a minimum, this should not modify the file on disk, since nothing
changes (besides last accessed date),
Workbook wb = WorkbookFactory.create(aFile, null, false);
wb.close();
// for unit test, assertCloseDoesNotModifyFile(wb, aFilename);
On Thu, Apr 7, 2016 at 7:35 AM, Allison, Timothy B. <ta...@mitre.org> wrote:
> Thanks to Javen and Dominik, I just learned this one myself...
>
> Workbook workbook = WorkbookFactory.create(java.io.File file, null, true);
>
>
> -----Original Message-----
> From: Joseph Price [mailto:joseph.price@numbersplace.com]
> Sent: Thursday, April 07, 2016 10:19 AM
> To: user@poi.apache.org
> Subject: Validating office files without saving them
>
> Hello,
>
>
> I am using POI to determine whether or not an existing office file is valid. For Excel files, I am using
>
>
> Workbook workbook = WorkbookFactory.create(java.io.File file);
>
>
> If that succeeds without throwing an exception, I assume the file is valid, and then I close it in a finally block:
>
>
> workbook.close();
>
>
> The problem is that the close method is saving the file, which I don't want. Is there a way to close the workbook without modifying the file on disk?
>
>
> Thanks,
>
> Joe
>
> ---------------------------------------------------------------------
> 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: Validating office files without saving them
Posted by "Allison, Timothy B." <ta...@mitre.org>.
Thanks to Javen and Dominik, I just learned this one myself...
Workbook workbook = WorkbookFactory.create(java.io.File file, null, true);
-----Original Message-----
From: Joseph Price [mailto:joseph.price@numbersplace.com]
Sent: Thursday, April 07, 2016 10:19 AM
To: user@poi.apache.org
Subject: Validating office files without saving them
Hello,
I am using POI to determine whether or not an existing office file is valid. For Excel files, I am using
Workbook workbook = WorkbookFactory.create(java.io.File file);
If that succeeds without throwing an exception, I assume the file is valid, and then I close it in a finally block:
workbook.close();
The problem is that the close method is saving the file, which I don't want. Is there a way to close the workbook without modifying the file on disk?
Thanks,
Joe
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org