Bug 52576

Summary: [PATCH] Change external file reference while preserving the formular itself
Product: POI Reporter: SunGard Global Services Germany <cs.fra.community>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal Keywords: PatchAvailable
Priority: P2    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: changeExternalReference.patch - Patch to implement this feature
changeExternalReference.patch - Patch to implement this feature
ChangeExternalReferenceWithTest.patch

Description SunGard Global Services Germany 2012-02-01 22:58:15 UTC
Created attachment 28249 [details]
changeExternalReference.patch - Patch to implement this feature

In our setup, we have a main XLS which references other (>10) XLS files.
The original author of the main XLS referenced some dummy files to create the formulars in the main XLS.

During our program execution, we generate the "real" XLS files with should be referenced by the main XLS.
The formular itself shouldn't be changed.


The attached patch introduces a new public method on HSSFWorkbook (As the OOXML is completly different and not in our scope I skipped it).

This allows the caller to change the file reference while preserving the formular itself.

As the file-notation is quite strange in the XLS lookup table I'm not 100% sure wether all kind of absolute/relative paths are interpreted corretly.
I tested with
* Relative paths
* Absolute paths with windows drive letters
* Absolute paths with windows UNC path (\\server\share)

I have not signed any kind of NDA from Microsoft and used only the public availible file format information.
Comment 1 SunGard Global Services Germany 2012-02-01 23:06:40 UTC
Created attachment 28250 [details]
changeExternalReference.patch - Patch to implement this feature

SVN diff patch
Comment 2 Yegor Kozlov 2012-02-03 10:14:51 UTC
Please provide unit tests, both low-level for SupBookRecord and usermodel-level that involve calling HSSFWorkbook.changeExternalReference(). If the test requires input workbooks then attach them too.

Regards,
Yegor
Comment 3 SunGard Global Services Germany 2012-02-07 22:09:21 UTC
Created attachment 28280 [details]
ChangeExternalReferenceWithTest.patch

Please find attached the patch applied against the latest SVN revision (trunk).

It includes the feature and unit tests for the user model and the internal translation logic.
Comment 4 Yegor Kozlov 2012-02-10 08:27:25 UTC
Thanks for the patch, applied in r1242701

Regards,
Yegor