Use npoi1.2.5 to create an xls document with a link

Source: Internet
Author: User
Using  Npoi. hssf. usermodel;  Using  Npoi. Ss. usermodel;  Using  System. IO;  Public   Partial  Program {  Public   Static   Void Main ( String  [] ARGs) {hssfworkbook = New Hssfworkbook (); isheet Sheet = Hssfworkbook. createsheet ( "  Sheet1  " ); //  Create a worksheet Irow ROW = sheet. createrow ( 0 ); //  Create row Row. createcell ( 0 ). Setcellvalue ( "  File URL  " );//  Create and set the first column value of the first row Row. createcell ( 1 ). Setcellvalue (datetime. Now. tow.datestring ()); //  Second column Value  Hssfhyperlink Link = New Hssfhyperlink (hyperlinktype. url ); //  Link type. hyperlinktype. File cannot open local files. It can only be processed through URLs. Link. Address = "  File: // D:/test.exe  " ;//  The file or URL to open, such as "http:  //  Cnblogs. com" Row. cells [ 0 ]. Hyperlink = link; //  Open this link in the first row column  //  Write an xls file              Using (Filestream file = New Filestream ( @"  D: \ Npoi-test.xls  " , Filemode. Create) {hssfworkbook. Write (File); file. Close ();}}} 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.