*这么优秀的国产工具怎能错过呢!在线下单专享“一口价”,立即购买!想要获取更多福利的朋友可以咨询在线客服哦~
添加评论
import com.spire.xls.*;public class InsertComments { public static void main(String[] args){ //Create a Workbook instance Workbook workbook = new Workbook(); //Get the first worksheet Worksheet sheet = workbook.getWorksheets().get(0); //Create fonts ExcelFont font = workbook.createFont(); font.setFontName("Arial"); font.setSize(11); font.setKnownColor(ExcelColors.Orange); ExcelFont fontBlue = workbook.createFont(); fontBlue.setKnownColor(ExcelColors.LightBlue); ExcelFont fontGreen = workbook.createFont(); fontGreen.setKnownColor(ExcelColors.LightGreen); //Add regular comment to specific cell range CellRange range = sheet.getCellRange("A1"); range.setText("Regular comment"); range.getComment().setText("Regular comment"); range.autoFitColumns(); //Add rich text comment to specific cell range range = sheet.getCellRange("A2"); range.setText("Rich text comment"); range.getRichText().setFont(0, 16, font); range.autoFitColumns(); range.getComment().getRichText().setText("Rich text comment"); range.getComment().getRichText().setFont(0, 4, fontGreen); range.getComment().getRichText().setFont(5, 9, fontBlue); //Save the resultant file workbook.saveToFile("AddComments.xlsx", ExcelVersion.Version2013); }}
常规评论

富文本评论

阅读评论
import com.spire.xls.Workbook;import com.spire.xls.Worksheet;public class ReadComments { public static void main(String[] args){ //Load Excel file Workbook workbook = new Workbook(); workbook.loadFromFile("AddComments.xlsx"); //Get the first worksheet Worksheet sheet = workbook.getWorksheets().get(0); //Print out the comment System.out.println("A1 Comment = " + sheet.getCellRange("A1").getComment().getText()); System.out.println("A2 Comment = " + sheet.getCellRange("A2").getComment().getRichText().getRtfText()); }}

是E-iceblue官方友好合作伙伴,如果您对spire.xls,可以联系在线客服了解具体授权价格和使用机制
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!