Npoi-excel Series-1002. Create an Excel file with document Summary information and Summary information

Source: Internet
Author: User

1.

1 usingNpoi. HSSF. Usermodel;2 usingNpoi. HPSF;3 usingNpoi. Poifs. FileSystem;4 usingMicrosoft.VisualStudio.TestTools.UnitTesting;5 usingSystem.IO;6 usingSystem;7 namespaceNpoi. Sample18 {9     /// <summary>Ten     ///Create an Excel file One     /// </summary> A [TestClass] -      Public classCreateexcelfile -     { the         /// <summary> -         ///Create an Excel file with document Summary information and Summary information -         /// </summary> - [TestMethod] +          Public voidcreateexcelandsummary () -         { +             //1. First create a workbook AHssfworkbook Workbook =NewHssfworkbook (); at  -             //2. Create summary information for Excel files (documentsummaryinformation) -Documentsummaryinformation dsi =propertysetfactory.createdocumentsummaryinformation (); -Dsi.company ="Npoi Study Team";//Unit name -  -             //3. Create SummaryInformation inSummaryInformation si =propertysetfactory.createsummaryinformation (); -  toSi. Author ="Wang Guangxu";//author +Si. Createdatetime = DateTime.Now;//creation Time -Si. Subject ="Create an Excel document with Npoi and document summary information";//Theme the              *             //Set Document information for a workbook $Workbook. Documentsummaryinformation =DSi;Panax NotoginsengWorkbook. SummaryInformation =si; -  the             //Create a worksheet (note: A standard Excel file needs to create 3 sheet) +Workbook. Createsheet ("Sheet1"); A              the             //Create a file stream +FileStream FileStream =NewFileStream (@"C:demo1.xls", FileMode.Create); -              $             //to write a workbook to an Excel file by using a file stream $ workbook. Write (fileStream); -             //Close File Stream - filestream.close (); the         } - Wuyi     } the}

2. The effect is as follows:

Npoi-excel Series-1002. Create an Excel file with document Summary information and Summary information

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.