import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.*; public class Sample8_1{ public static void main(String[] args){ Workbook wb = new HSSFWorkbook(); CreationHelper ch = wb.getCreationHelper(); Hyperlink link1 = ch.createHyperlink(Hyperlink.LINK_URL); link1.setAddress("http://www.example.jp/"); Hyperlink link2 = ch.createHyperlink(Hyperlink.LINK_DOCUMENT); link2.setAddress("Sheet0!A1"); Sheet sheet = wb.createSheet(); Row row = sheet.createRow(1); Cell cell1 = row.createCell(1); Cell cell2 = row.createCell(2); cell1.setCellValue("abc"); cell2.setCellValue("def"); cell1.setHyperlink(link1); cell2.setHyperlink(link2); CellStyle style = wb.createCellStyle(); Font font = wb.createFont(); font.setUnderline(Font.U_SINGLE); style.setFont(font); cell2.setCellStyle(style); FileOutputStream out = null; try{ out = new FileOutputStream("sample8_1.xls"); wb.write(out); }catch(IOException e){ System.out.println(e.toString()); }finally{ try { out.close(); }catch(IOException e){ System.out.println(e.toString()); } } } }