setCellFormula("HYPERLINK(\"www.google.com\",\"google\");");

解决方案 »

  1.   

    活活,谢谢楼上的,我也会了,不过你写的还是有点问题,应改在写成“http://www.google.com".不过我要做的是链接到本地workbook里面的sheet。这个问题我也解决了,谢谢!
      

  2.   

    package test;import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;/**
     * @author hy-he
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    public class TestHyperlink {    public static void main(String[] args) throws IOException {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet sheet = workbook.createSheet();
            HSSFSheet sheet2 = workbook.createSheet();
            HSSFRow row = sheet.createRow(0);
            HSSFCell cell = row.createCell((short)1);
    //        cell.setCellFormula("HYPERLINK(\"http://www.sina.com\",\"www.google.com\");");
            cell.setCellFormula("HYPERLINK(\"[hyper.xls]Sheet1!A1\", \"safafsd\");");
            FileOutputStream out = new FileOutputStream("hyper.xls");
    workbook.write(out);
    out.flush();
    out.close();
        }
    }