* @param url
* The target URL
*/
private void addHyperlink(UIHyperlink uiHyperlink) {
if (worksheet == null) {
throw new ExcelWorkbookException(
"Can't add a hyperlink before creating a worksheet");
}
int useStartColumn = uiHyperlink.getStartColumn() == null ? currentColumnIndex
: uiHyperlink.getStartColumn();
int useStartRow = uiHyperlink.getStartRow() == null ? currentRowIndex
: uiHyperlink.getStartRow();
int useEndColumn = uiHyperlink.getEndColumn() == null ? useStartColumn
: uiHyperlink.getEndColumn();
int useEndRow = uiHyperlink.getEndRow() == null ? useStartRow
: uiHyperlink.getEndRow();
String useDescription = uiHyperlink.getDescription() == null ? uiHyperlink
.getURL()
: uiHyperlink.getDescription();
URL useURL = null;
try {
useURL = new URL(uiHyperlink.getURL());
} catch (MalformedURLException e) {
throw new ExcelWorkbookException("Bad url", e);
}
try {
worksheet.addHyperlink(new WritableHyperlink(useStartColumn,
useStartRow, useEndColumn, useEndRow, useURL,
useDescription));
} catch (Exception e) {
throw new ExcelWorkbookException("Could not add hyperlink", e);
}
}