• <menu id="w2i4a"></menu>
  • logo Spire.XLS 系列教程

    文檔首頁>>Spire.XLS 系列教程>>Spire.XLS教程:在Java中以編程方式在Excel中添加和閱讀注釋

    Spire.XLS教程:在Java中以編程方式在Excel中添加和閱讀注釋


    Spire.XLS for Java是專業(yè)的Java Excel API,使開發(fā)人員無需使用Microsoft Office或Microsoft Excel即可創(chuàng)建,管理,操作,轉(zhuǎn)換和打印Excel工作表。

    本文演示了如何將常規(guī)注釋和富文本注釋添加到Excel文件,以及如何使用Spire.XLS for Java閱讀注釋。

    免費下載Spire.XLS最新版


    添加評論

    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);
        }
    }

    常規(guī)評論

    Excel開發(fā)組件Spire.XLS教程:在Java中以編程方式在Excel中添加和閱讀注釋

    富文本評論

    Excel開發(fā)組件Spire.XLS教程:在Java中以編程方式在Excel中添加和閱讀注釋

    閱讀評論

    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());
        }
    }
    Excel開發(fā)組件Spire.XLS教程:在Java中以編程方式在Excel中添加和閱讀注釋


    慧都是E-iceblue官方友好合作伙伴,如果您對spire.xls,可以聯(lián)系在線客服了解具體授權價格和使用機制

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();