Two objects used: Documentsummaryinformation and summaryinformation.
The code is as follows:
Static voidMain (string[] args) { //Create an Excel objectHssfworkbook Hssfworkbook =NewHssfworkbook (); //Create Excel properties in the source and description, etc.Documentsummaryinformation dsi =propertysetfactory.createdocumentsummaryinformation (); Dsi.company="NPOI-1"; Dsi. Category="NPOI-2"; Dsi. Manager="NPOI-3"; //The created object is assigned to Hssfworkbook to ensure that the information is written to the fileHssfworkbook.documentsummaryinformation =DSi; SummaryInformation si=propertysetfactory.createsummaryinformation (); Si. Subject="npoi SDK Example 1"; Si. Title="npoi SDK Example 2"; Si. ApplicationName="npoi SDK Example 3"; Si. Author="npoi SDK Example 4"; Si. Lastauthor="npoi SDK Example 5"; Si.comments="npoi SDK Example 6"; Si. Createdatetime= DateTime.Now.AddMonths (-2); //The created object is assigned to Hssfworkbook to ensure that the information is written to the fileHssfworkbook.summaryinformation =si; //create a file and writeFileStream file =NewFileStream (@"Demo.xls", FileMode.Create); Hssfworkbook.write (file); File. Close (); }
The following information can be seen in the generated Excel properties:
Npoi_2.1.3_ Learning Record (1)-Create Excel details such as: Author, title, tags, notes, topics, and more.