athrunwang

纪元
数据加载中……
java操作excel 插入 读取 备注 需要smartxls jar包
import com.smartxls.CommentShape;
import com.smartxls.WorkBook;

public class CommentReadSample
{

    public static void main(String args[])
    {

        WorkBook workBook = new WorkBook();
        try
        {
            workBook.read("..\\template\\book.xls");

            // get the first index from the current sheet
            CommentShape commentShape = workBook.getComment(1, 1);
            if(commentShape != null)
            {
                System.out.println("comment text:" + commentShape.getText());
                System.out.println("comment author:" + commentShape.getAuthor());
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

import com.smartxls.WorkBook;

public class CommentWriteSample
{

    public static void main(String args[])
    {
        WorkBook workBook = new WorkBook();
        try
        {
            //add a comment to B2
            workBook.addComment(1, 1, "comment text here!", "author name here!");

            workBook.write(".\\comment.xls");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

posted on 2011-12-28 19:01 AthrunWang 阅读(715) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: