Bug 58557 - Shift hyperlinks when shifting rows in XSSFSheet
Summary: Shift hyperlinks when shifting rows in XSSFSheet
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.14-dev
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks: 46742 52903
  Show dependency tree
 
Reported: 2015-10-27 08:39 UTC by Javen O'Neal
Modified: 2015-10-29 08:54 UTC (History)
2 users (show)



Attachments
shift hyperlinks in XSSFSheet.shiftRows (12.55 KB, patch)
2015-10-27 12:20 UTC, Javen O'Neal
Details | Diff
Excel spreadsheet test case - before shifting rows (4.60 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2015-10-27 12:27 UTC, Javen O'Neal
Details
Excel spreadsheet test case - after shifting rows (4.60 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2015-10-27 12:28 UTC, Javen O'Neal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Javen O'Neal 2015-10-27 08:39:22 UTC
(In reply to Alessandro Guarascio from comment #3)
> Created attachment 31626 [details]
> Proposed patch for hyperlink shift
> 
> Here is a patch proposal to support hyperlink shift.
> It is based on POI 3.10 and it works only for XSSF
Comment 1 Javen O'Neal 2015-10-27 12:20:59 UTC
Created attachment 33227 [details]
shift hyperlinks in XSSFSheet.shiftRows

Thanks Alessandro for putting together a patch for XSSFRows.shiftRows for shifting the anchor points of hyperlinks.
I wrote a unit test for your code to make sure it won't cause problems with existing and future projects.

Two minor changes:
1. Hyperlinks on rows that are getting deleted (overwritten by the shifted rows) also need to be deleted.
2. I made XSSFHyperlink.setCellReference internal-public rather than using  XSSFHyperlink.getCTHyperlink method (which is unfortunately already public--probably need to do some refactoring to get that back to protected--for now I'm making getCTHyperlink internal-public). In general, no one should need to know about the CT* classes.

Please take a look at the code and let me know if I'm missing anything.
Comment 2 Javen O'Neal 2015-10-27 12:27:28 UTC
Created attachment 33228 [details]
Excel spreadsheet test case - before shifting rows

The test case creates a XSSFWorkbook object from scratch rather than reading in .xlsx files from test-data. This spreadsheet is for reference only.
Comment 3 Javen O'Neal 2015-10-27 12:28:24 UTC
Created attachment 33229 [details]
Excel spreadsheet test case - after shifting rows

This spreadsheet was created by saving the workbook immediately after shiftRows.
Comment 4 Javen O'Neal 2015-10-29 07:34:57 UTC
Deployed to trunk in r1711185
Updated docs in r1711187

Thanks for the patch!