原創(chuàng)|使用教程|編輯:張瑩心|2021-10-15 14:56:33.420|閱讀 779 次
概述:本文將介紹如何使用Spire.XLS for Java 以編程方式編輯現(xiàn)有注釋以及刪除注釋。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Spire.XLS for Java是專業(yè)的Java Excel API,使開發(fā)人員無需使用Microsoft Office或Microsoft Excel即可創(chuàng)建,管理,操作,轉(zhuǎn)換和打印Excel工作表。
*這么優(yōu)秀的國產(chǎn)工具怎能錯過呢!在線下單專享“一口價”,立即購買!想要獲取更多福利的朋友可以哦~
<repositories> <repository> <id>com.e-iceblue</id> <name>e-iceblue</name> <url>//repo.e-iceblue.com/nexus/content/groups/public/</url> </repository> </repositories> <dependencies> <dependency> <groupId>e-iceblue</groupId> <artifactId>spire.xls</artifactId> <version>4.9.0</version> </dependency> </dependencies>
名稱 | 描述 |
ExcelCommentObject 類 | 表示 Excel 文檔中的注釋。 |
CellRange.getComment() 方法 | 返回表示特定單元格范圍內(nèi)的注釋的注釋對象。 |
ExcelCommentObject.setText() 方法 | 設(shè)置注釋文本。 |
ExcelCommentObject.setHeight() 方法 | 設(shè)置評論的高度。 |
ExcelCommentObject.setWidth() 方法 | 設(shè)置評論的寬度。 |
ExcelCommentObject.setAutoSize() 方法 | 設(shè)置是否自動更改指定對象的大小以適合其邊界內(nèi)的文本。 |
以下是在 Excel 中編輯注釋的步驟:
import com.spire.xls.*; public class ModifyComment { public static void main(String[] args) { //Create a Workbook instance Workbook wb = new Workbook(); //Load an Excel file wb.loadFromFile("Comments.xlsx"); //Get the first worksheet Worksheet sheet = wb.getWorksheets().get(0); //Get comments in specific cells and set new comments sheet.getRange().get("A8").getComment().setText("Frank has left the company."); sheet.getRange().get("F6").getComment().setText("Best sales."); //Set the height and width of the new comments sheet.getRange().get("A8").getComment().setHeight(50); sheet.getRange().get("A8").getComment().setWidth(100); sheet.getRange().get("F6").getComment().setAutoSize(true); //Save to file. wb.saveToFile("ModifyComment.xlsx",ExcelVersion.Version2013); wb.dispose(); } }
以下是在 Excel 中刪除注釋的步驟:
import com.spire.xls.*; public class DeleteComment { public static void main(String[] args) { //Create a Workbook instance Workbook wb = new Workbook(); //Load an Excel file wb.loadFromFile("Comments.xlsx"); //Get the first worksheet Worksheet sheet = wb.getWorksheets().get(0); //Get the comment in a specific cell and remove it sheet.getRange().get("F6").getComment().remove(); //Save to file. wb.saveToFile("DeleteComment.xlsx", ExcelVersion.Version2013); wb.dispose(); } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn