Nopi User Manual

Source: Internet
Author: User

Summary: Analyze a Nopi manual that can help us make better use of Nopi to operate office

Some customers export or import, the format of Excel is very high, you need to use the Nopi. Code Sample:

ImportsSystemImportssystem.webImportsSystem.Web.UIImportsSystem.Web.UI.WebControlsImportsSystem.IOImportsNpoi. HSSF. UsermodelImportsNpoi. HPSFImportsNpoi. Poifs. FileSystemImportsNpoi. Ss. UsermodelPartial  Public Class_defaultInheritsSystem.Web.UI.PageProtected SubPage_Load (ByValSender as Object,ByValE asEventArgs)End Sub    'output file data stream after clicking the button    Protected SubButton1_Click (ByValSender as Object,ByValE asEventArgs)DimFileName as String="Test.xls"Response.ContentType="Application/vnd.ms-excel"Response.AddHeader ("content-disposition",String. Format ("attachment;filename={0}", filename)) Response.Clear ()'Call Initialize Excel fileInitializeworkbook ()'Generate DataGeneratedata ()'output Excel file streamResponse.BinaryWrite (WriteToStream (). GetBuffer ()) Response. [End]()    End Sub    'Define Workbook    PrivateHssfworkbook asHssfworkbook'    Private FunctionWriteToStream () asMemoryStream'Write The stream data of workbook to the root directory        DimFile as NewMemoryStream () Hssfworkbook. Write (file)ReturnfileEnd Function    'Generate Data    Private SubGeneratedata ()'Generate a sheet        DimSheet1 asIsheet = Hssfworkbook. Createsheet ("Sheet1")        'Loop adds data to sheetSheet1. CreateRow (0). Createcell (0). Setcellvalue ("This is a Sample")        DimX as Integer=1         forI as Integer=1  to  the            DimRow asIRow =Sheet1. CreateRow (i) forJ as Integer=0  to  -row. Createcell (j). Setcellvalue (System.Math.Max (System.Threading.Interlocked.Increment (x), x-1))            Next        Next    End Sub    'Initialize a workbook (active worksheet)    Private SubInitializeworkbook () Hssfworkbook=NewHssfworkbook ()" "/create A entry of documentsummaryinformation        DimDsi asDocumentsummaryinformation =propertysetfactory.createdocumentsummaryinformation () Dsi.company="Npoi Team"Hssfworkbook. Documentsummaryinformation=DSi" "/create A entry of SummaryInformation        DimSi asSummaryInformation =propertysetfactory.createsummaryinformation () si. Subject="Npoi SDK Example"Hssfworkbook. SummaryInformation=siEnd SubEnd Class

Http://files.cnblogs.com/files/KingUp/npoi%E5%AE%9E%E4%BE%8B.rar

Nopi User Manual

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.