In Npoi, it does not natively support the creation of advanced objects such as charts, but with the help of the L-template, you can use Excel's powerful perspective and charting capabilities in the following example.
First create the template file, define two columns, and the name "sales" that points to this area:
Create a data table where the data source fills in the area you just defined:
The last generated PivotTable report has the following style: Sheet.
So far, the template has been built and saved as "D:\MyProject\NPOIDemo\Chart\Book2.xls". We found that the template is the equivalent of an "empty shelf", there is no way to operate without any data. Next, we fill in the data in this "empty shelf". We write the data in this "empty shelf" by the following code:
StaticvoidMain (String[] args)
{
Hssfworkbook WB=NewHssfworkbook (NewFileStream (@"D:\MyProject\NPOIDemo\Chart\Book2.xls", FileMode.Open));
Hssfsheet Sheet1=Wb. Getsheet ("Sheet1");
Hssfrow row=Sheet1. CreateRow (1);
Row. Createcell (0). Setcellvalue ("Make the Fox rush");
Row. Createcell (1). Setcellvalue (50000);
Row=Sheet1. CreateRow (2);
Row. Createcell (0). Setcellvalue ("Ren Ying");
Row. Createcell (1). Setcellvalue (30000);
Row=Sheet1. CreateRow (3);
Row. Createcell (0). Setcellvalue ("Wind");
Row. Createcell (1). Setcellvalue (80000);
Row=Sheet1. CreateRow (4);
Row. Createcell (0). Setcellvalue ("Let me do it.");
Row. Createcell (1). Setcellvalue (20000
//write the Stream data of workbook to the root directory
filestream file = new filestream (@ "test.xls ", filemode.create);
    WB. Write (file);
file. Close ();
}
Open the generated Test.xls file and find that the data has been filled in:
Looking at the pivot table again, there are data:
Summarize:
Excel has a powerful report perspective and charting capabilities, and is easy to use, using Npoi to make the most of it. It is very useful to make graphical reports and pivot reports!
Excel Learning Tutorial: http://www.cnblogs.com/atao/archive/2009/10/25/1589606.html
3.5 using Npoi to manipulate excel--to use Excel Chart skillfully