athrunwang

纪元
数据加载中……
java操作excel 插入 读取 超链接
import com.smartxls.HyperLink;
import com.smartxls.WorkBook;

public class HyperlinkReadSample
{

    public static void main(String args[])
    {

        WorkBook workBook = new WorkBook();
        String version = workBook.getVersionString();
        System.out.println("Ver:" + version);
        try
        {
            workBook.read("..\\template\\book.xls");

            // get the first index from the current sheet
            HyperLink hyperLink = workBook.getHyperlink(0);
            if(hyperLink != null)
            {
                System.out.println(hyperLink.getType());
                System.out.println(hyperLink.getLinkURLString());
                System.out.println(hyperLink.getLinkShowString());
                System.out.println(hyperLink.getToolTipString());
                System.out.println(hyperLink.getRange());
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

import com.smartxls.HyperLink;
import com.smartxls.WorkBook;

public class HyperlinkWriteSample
{

    public static void main(String args[])
    {
        WorkBook workBook = new WorkBook();
        try
        {
            //add a url link to F6
            workBook.addHyperlink(5,5,5,5,"http://www.smartxls.com/", HyperLink.kURLAbs,"Hello,web url hyperlink!");

            //add a file link to F7
            workBook.addHyperlink(6,5,6,5,"c:\\",HyperLink.kFileAbs,"file link");

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

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


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


网站导航: