Bug 62222 - getLabel for Hyperlink returns always null for xlsx files
Summary: getLabel for Hyperlink returns always null for xlsx files
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.17-FINAL
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-27 07:01 UTC by Alexander Vitkovskiy
Modified: 2018-04-02 06:46 UTC (History)
0 users



Attachments
Java class (1.23 KB, text/plain)
2018-03-27 07:01 UTC, Alexander Vitkovskiy
Details
xls file (22.50 KB, application/vnd.ms-excel)
2018-03-27 07:01 UTC, Alexander Vitkovskiy
Details
xlsx file (8.08 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-03-27 07:01 UTC, Alexander Vitkovskiy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Vitkovskiy 2018-03-27 07:01:10 UTC
Created attachment 35813 [details]
Java class

hyperlink.getLabel() returns null instead of display text for hyperlink.

But in normally works for xls files and HSSF.

See attached example that shows bug.
Comment 1 Alexander Vitkovskiy 2018-03-27 07:01:42 UTC
Created attachment 35814 [details]
xls file
Comment 2 Alexander Vitkovskiy 2018-03-27 07:01:58 UTC
Created attachment 35815 [details]
xlsx file
Comment 3 Nick Burch 2018-03-27 07:42:23 UTC
The XSSF code (for XLSX) is returning the "display" property of the underlying CT Hyperlink xml.

Could you try renaming your .xlsx file to .zip, unzipping it, and looking in the XML to see what your version of Excel decided to store the label as/in?
Comment 4 Alexander Vitkovskiy 2018-03-27 07:49:32 UTC
File created in Excel 2013.

Sheet looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><dimension ref="A1"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/><sheetData><row r="1" spans="1:1" x14ac:dyDescent="0.25"><c r="A1" s="1" t="s"><v>0</v></c></row></sheetData><hyperlinks><hyperlink ref="A1" r:id="rId1"/></hyperlinks><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/></worksheet>

that points to hyperlynk (but there no display text):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="pom.xml" TargetMode="External"/></Relationships>

Found it ("MavenPom") in sharedStrings.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>MavenPom</t></si></sst>


I attached XLSX file to bug.
Comment 5 Alexander Vitkovskiy 2018-03-27 07:57:09 UTC
Also there same issue if you writing Hyperlink to Excel file. Setting address works, but label not shows in MS Excel (cell will have blank text, but style will be hyperlink and navigation will work)
Comment 6 Dominik Stadler 2018-03-31 15:51:04 UTC
What do you get if you read the column-value? I think that will return the text of the hyperlink.
Comment 7 Alexander Vitkovskiy 2018-04-02 06:46:26 UTC
Yes, string Cell velue gives display text for hyperlink (not sure that always will match hyperlynk label from hyperlink properties).

But if you trying to create hyperlink from code and save it to xlsx, there no way to save Label. If you creating hyperlink with Label Excel will show blank display text\cell and setting string Cell value replacing hyperlink in cell.