You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/02/01 23:45:47 UTC

DO NOT REPLY [Bug 52575] New: [PATCH] Ignore missing workbook references

https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

             Bug #: 52575
           Summary: [PATCH] Ignore missing workbook references
           Product: POI
           Version: 3.7
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: cs.fra.community@sungard.com
    Classification: Unclassified


Created attachment 28248
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28248
ignoreMissingWorkbooks.patch - Patch to implement this feature

In our project we have one XLS file referencing > 10 other XLS files.
Setting up a workbook environment works as expected and a formular
recalculation works.

In our project, we sometimes do not have all referenced XLS files but want to
recalculate those values for which we have the referenced XLS files.
For those situations we are absolutly fine with the cached values which exists
already in the main XLS.

This might be a quite dedicated setup: Therefore I introduced a system property
to change the behavoir:
The old behavoir is to fail as before.
Setting the property to true issues an INFO log message and continues with the
cached value.


Currently I'm a little bit unhappy about the brute-force approach to get the
cell type to access the cached value - but I didn't found another way to handle
it.


Please let me know your thoughts - Feel free to take this patch as an
insipration for a feature request and implement it in a more POI-standard way.

I have not signed any kind of NDA from Microsoft and used only the public
availible documentation about the XLS file format.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #9 from Yegor Kozlov <ye...@dinom.ru> 2012-02-07 08:10:28 UTC ---
I removed configuring IGNORE_MISSING_WORKBOOKS from a system property and added
a public setter HSSFFormulaEvaluator.setIgnoreMissingWorkbooks(boolean ignore).

Client code:

HSSFFormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();
evaluator.setIgnoreMissingWorkbooks(true); 

For now setIgnoreMissingWorkbooks is in HSSF only because evaluation across
multiple workbooks is not yet implemented in XSSF. 

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

SunGard Global Services Germany <cs...@sungard.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable
         OS/Version|                            |All

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2012-02-03 08:46:48 UTC ---
Thanks for the patch. There two things to do before check it in svn:

1. It lacks a unit test(s). Can you write sample code that demonstrates that
the code throws  WorkbookNotFoundException if IGNORE_MISSING_WORKBOOKS=false
and uses cached formula values otherwise. If the test requires input workbooks
then attached them along with the test.

2. What about loading IGNORE_MISSING_WORKBOOKS from a poi.properties file?
First lookup poi.properties in the classpath and then load default config
bundled in the jar. 
My concern is that in many environments users cannot change JVM system
properties, for example, think of a web application that cannot change JVM
settings of the server (Tomcat or whatever). With poi.properties, you can
simply put in the classpath (WEB-INF/classes) and POI will initialize from it 
-  pretty much like log4j searches its config file. 

Regards,
Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

SunGard Global Services Germany <cs...@sungard.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #28248|0                           |1
        is obsolete|                            |

--- Comment #5 from SunGard Global Services Germany <cs...@sungard.com> 2012-02-05 22:48:58 UTC ---
Created attachment 28271
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28271
IgnoreWorkbooks with Testcases

Attached a new patch containing the original one (with some simplifications)
and testcases.
The attached XLS are also required for the testcase execution.

I would like to keep track of the "configuration infrastructure" in a different
ticket.
I will post a patch within another bug.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Yegor Kozlov <ye...@dinom.ru> 2012-02-06 07:49:42 UTC ---
Applied in r1240903 with minor tweaks:
 - you forgot to implement getCachedFormulaResultType() in ForkedEvaluationCell
 - I changed the unit test to utilize POI infrastructure to read test files:
instead of direct reading from FileInputStream it is recommended to use
HSSFTestDataSamples.openSampleWorkbook (filename)
 - added a prefix to the test files and put them in ./test-data/spreadsheet. I
would like to keep all spreadsheet samples in the same directory and avoid
extra sub-folders. 

Regards,
Yegor

(In reply to comment #4)
> On the settings thing, might it be worth copying what ExtractorFactory does for
> the usermodel vs event streaming setting?

(In reply to comment #6)
> Created attachment 28272 [details]
> ZIP of the XLS (2003) sheets to execute the testcases

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #6 from SunGard Global Services Germany <cs...@sungard.com> 2012-02-05 22:51:03 UTC ---
Created attachment 28272
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28272
ZIP of the XLS (2003) sheets to execute the testcases

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #3 from Yegor Kozlov <ye...@dinom.ru> 2012-02-03 11:54:55 UTC ---
(In reply to comment #2)
> Thanks for the feedback Yegor.
> 
> Providing a test with workbook is quite simple.
> 
> RE 2.: I tried to keep the impact as low as possible.
> Is there some poi.properties infrastructure? I didn't noticed something like
> this.

No, for now poi.properties exists only in my dreams :)

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #4 from Nick Burch <ni...@alfresco.com> 2012-02-03 12:13:56 UTC ---
On the settings thing, might it be worth copying what ExtractorFactory does for
the usermodel vs event streaming setting?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #10 from SunGard Global Services Germany <cs...@sungard.com> 2012-02-07 08:24:29 UTC ---
(In reply to comment #9)
> I removed configuring IGNORE_MISSING_WORKBOOKS from a system property and added
> a public setter HSSFFormulaEvaluator.setIgnoreMissingWorkbooks(boolean ignore).
Ok, this makes my patch submission unnecessary. 
Thanks :)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #2 from SunGard Global Services Germany <cs...@sungard.com> 2012-02-03 11:50:48 UTC ---
Thanks for the feedback Yegor.

Providing a test with workbook is quite simple.

RE 2.: I tried to keep the impact as low as possible.
Is there some poi.properties infrastructure? I didn't noticed something like
this.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 52575] [PATCH] Ignore missing workbook references

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52575

--- Comment #8 from Yegor Kozlov <ye...@dinom.ru> 2012-02-06 07:59:09 UTC ---
I think that the simplest (and the best) solution would be to add a setter for
this property right in the formula evaluator. The client code would look as
follows:

FormulaEvaluator ev = workbook.getCreationHelper().createFormulaEvaluator();
ev.setIgnoreMissingWorkbooks(true);

This way this setting can be changed in a very flexible way. 

Yegor

(In reply to comment #4)
> On the settings thing, might it be worth copying what ExtractorFactory does for
> the usermodel vs event streaming setting?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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