the following code works OK to me with the latest build from trunk:
Workbook wb = new XSSFWorkbook(); // or new HSSFWorkbook();
CreationHelper helper = wb.getCreationHelper();
Sheet sheet1 = wb.createSheet();
Cell cell1 = sheet1.createRow(0).createCell(0);
cell1.setCellValue("Document Link");
//create a target sheet and cell
Sheet sheet2 = wb.createSheet();
Cell cell2 = sheet2.createRow(0).createCell(0);
cell2.setCellValue("Target Cell");
// a li nke from sheet1 to sheet2
Hyperlink link = helper.createHyperlink(Hyperlink.LINK_DOCUMENT);
String targetUri = "'" + sheet2.getSheetName() + "'!" + new
CellReference(cell2).formatAsString();
link.setAddress(targetUri);
cell1.setHyperlink(link);
FileOutputStream out = new FileOutputStream("/temp/link.xlsx");
wb.write(out);
out.close();
Yegor
On Sat, Oct 20, 2012 at 12:18 AM, Nile, Russell
<[email protected]> wrote:
> Folks,
>
> For the life of me I cannot get an intra-document link to work properly. The
> code is pretty straight forward:
> CreationHelper createHelper = wb.getCreationHelper();
> Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT);
> link.setAddress(docLink);
> hssfCell.setHyperlink(link);
>
> but if I send it "Sheet1!A1" it complains that there is no file name and if I
> include the hash; "#Sheet1!A1" it tries to open itself up again. BTW:It
> always seems to create a http:// reference even though I specified
> LINK_DOCUMENT.
>
> Jxls 0.9 and 1.0.0
> Poi 3.2, 3.6, 3.8
>
> Any ideas?
>
>
> Russell J. Nile
> Vice President
> Morgan Stanley | Corporate Technology | Legal and Compliance
> 1 New York Plaza, 12th floor | New York, NY, 10004
> Phone: +1 212-276-8962
> Fax: +1 212-507-4633
> [email protected]<mailto:[email protected]>
> BE CARBON CONSCIOUS. PLEASE CONSIDER OUR ENVIRONMENT BEFORE PRINTING THIS
> E-MAIL.
>
>
> ________________________________
>
> NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions
> or views contained herein are not intended to be, and do not constitute,
> advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform
> and Consumer Protection Act. If you have received this communication in
> error, please destroy all electronic and paper copies and notify the sender
> immediately. Mistransmission is not intended to waive confidentiality or
> privilege. Morgan Stanley reserves the right, to the extent permitted under
> applicable law, to monitor electronic communications. This message is subject
> to terms available at the following link:
> http://www.morganstanley.com/disclaimers If you cannot access these links,
> please notify us by reply message and we will send the contents to you. By
> messaging with Morgan Stanley you consent to the foregoing.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]