How to get hyperlink address from a cell in excel by using java?


I know how to use JavaExcelApi (jxl) or Apache POI to read string information of a cell in an excel file by writing some java code. But now I got a problem:

A cell contains a string with a hyperlink on it. I can read the string in this cell, but I don't know how to read the hyperlink address through java.


The method you're looking for is <a href="http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Cell.html#getHyperlink%28%29" rel="nofollow">Cell.getHyperlink()</a>, which returns either null (cell has no hyperlink) or a <a href="http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Hyperlink.html" rel="nofollow">Hyperlink object</a>

If you wanted to fetch the hyperlink URL of cell B2 of test.xls, you'd do something like:

Workbook wb = WorkbookFactory.create(new File("test.xls")); Sheet s = wb.getSheetAt(0); Row r2 = s.getRow(1); // Rows in POI are 0 based Cell cB2 = r2.getCell(1); // Cells are 0 based Hyperlink h = cB2.getHyperlink(); if (h == null) { System.err.println("Cell B2 didn't have a hyperlink!"); } else { System.out.println("B2 : " + h.getLabel() + " -> " + h.getAddress()); }


  • Why isn't page jQuery .focus event changing background-color style to green in Google Chrome af
  • Use a ListProperty or custom tuple property in App Engine?
  • How to programatically add a hyperlink to a cell in a worksheet using office-js?
  • UIBarButtonItem's action is not called when in a view with a UIGestureRecognizer
  • C++/CLI Thread synchronization including managed and unmanaged code
  • Create a link to a web page that runs a Javascript function on the page
  • Julia: How to give multiple workers access to functions that are 'include(…)' into a modul
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • JPA flush vs commit
  • Center align outputs in ipython notebook
  • Alternative to overridePendingTransition() - Android
  • custom UITableViewCell with image for highlighting
  • Meteor: Do Something On Email Verification Confirmation
  • Can I check if a recipient has an automatic reply before I send an email?
  • Cannot resolve symbol 'MyApi'
  • Handling un-mapped Rest path
  • Using jQuery closest() method with class selector
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Regex thinks I'm nesting, but I'm not
  • Sending data from AppleScript to FileMaker records
  • Fill an image in a square container while keeping aspect ratio
  • Join two tables and save into third-sql
  • Trying to switch camera back to front but getting exception
  • vba code to select only visible cells in specific column except heading
  • htaccess rewriting URLs with multiple forward slashes
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Free memory of cv::Mat loaded using FileStorage API
  • using HTMLImports.whenReady not working in chrome
  • Angular 2 constructor injection vs direct access
  • How do I configure my settings file to work with unit tests?
  • Is it possible to post an object from jquery to bottle.py?
  • Programmatically clearing map cache
  • Reading document lines to the user (python)
  • Converting MP3 duration time