个性化阅读
专注于IT技术分析

apache poi超链接

本文概述

Apache POI允许我们在电子表格中创建超链غ 5;。在单元格中设置网址并单击后重 ;定向到服务器非常有用。

请参见下面的示例,在该示例中࿰ c;我们创建了重定向到srcmini02.com的超链接 002;

Apache POI超链接示例

package poiexample;
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;
import org.apache.poi.ss.usermodel.CellType;
public class HyperlinkFormula {
 public static void main(String[] args) throws IOException {
 	try (HSSFWorkbook wb = new HSSFWorkbook()) {
         HSSFSheet sheet = wb.createSheet("new sheet");
         HSSFRow row = sheet.createRow(0);
         HSSFCell cell = row.createCell(0);
         cell.setCellType(CellType.FORMULA);
         cell.setCellFormula("HYPERLINK(\"http://https://www.srcmini02.com/apache-poi-tutorial\", \"click here\")");
         try (FileOutputStream fileOut = new FileOutputStream("srcmini.xls")) {
             wb.write(fileOut);
         }
     }
 }
}

输出:

赞(0)
未经允许不得转载:srcmini » apache poi超链接

评论 抢沙发

评论前必须登录!