原創|其它|編輯:郝浩|2012-06-27 22:31:32.000|閱讀 1875 次
概述:Aspose.Cells允許您在運行時添加圖片的超鏈接到電子表格中。你可以設置/修改成你所需要的屏幕提示和鏈接地址。本文,通過使用Aspose.Cells API,僅需一些簡單的代碼便可在工作表中添加圖片的超鏈接。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Cells允許您在運行時添加圖片的超鏈接到電子表格中。你可以設置/修改成你所需要的屏幕提示和鏈接地址。本文,通過使用Aspose.Cells API,僅需一些簡單的代碼便可在工作表中添加圖片的超鏈接。
[Java]
//Instantiate a new workbook
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
//Insert a string value to a cell
worksheet.getCells().get("C2").setValue("Image Hyperlink");
//Set the 4th row height
worksheet.getCells().setRowHeight(3, 100);
//Set the C column width
worksheet.getCells().setColumnWidth(2, 21);
//Add a picture to the C4 cell
int index = worksheet.getPictures().add(3, 2, 3, 2, "f:\\test\\school.jpg");
//Get the picture object
com.aspose.cells.Picture pic = worksheet.getPictures().get(index);
//Set the placement type
pic.setPlacement(PlacementType.FREE_FLOATING);
//Add an image hyperlink
pic.addHyperlink("//www.aspose.com/");
com.aspose.cells.Hyperlink hlink = pic.getHyperlink();
//Specify the screen tip
hlink.setScreenTip("Click to go to Aspose site");
//Save the excel file
workbook.save("f:\\test\\ImageHyperlink.xls");
執行上述代碼后,結果如下:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網