Public class simpleexcelwrite {
Public void createexcel (outputstream OS) throws writeexception, ioexception {
// Create a workbook
Writableworkbook workbook = Workbook. createworkbook (OS );
// Create a new page
Writablesheet sheet = Workbook. createsheet ("first sheet", 0 );
// Create the specific content to be displayed
Label xuexiao = new label (0, 0, "school ");
Sheet. addcell (xuexiao );
Label zhuanye = new label (1, 0, "professional ");
Sheet. addcell (zhuanye );
Label jingzhengli = new label (2, 0, "competitive ");
Sheet. addcell (jingzhengli );
Label Qinghua = new label (0, 1, "Tsinghua University ");
Sheet. addcell (QingHua );
Label jisuanji = new label (1, 1, "Computer Major ");
Sheet. addcell (jisuanji );
Label Gao = new label (2, 1, "high ");
Sheet. addcell (GAO );
Label Beida = new label (, "Peking University ");
Sheet. addcell (Beida );
Label falv = new label (1, 2, "Legal Major ");
Sheet. addcell (falv );
Label Zhong = new label (2, 2, "medium ");
Sheet. addcell (Zhong );
Label ligong = new label (, "Beijing Institute of Technology ");
Sheet. addcell (ligong );
Label hangkong = new label (1, 3, "Aviation Major ");
Sheet. addcell (hangkong );
Label di = new label (2, 3, "low ");
Sheet. addcell (DI );
// Write the created content to the output stream and close the output stream
Workbook. Write ();
Workbook. Close ();
OS. Close ();
}
}
<%
String fname = "professional competitiveness of Schools ";
Outputstream OS = response. getoutputstream ();
Response. Reset ();
// Process the Chinese file name
Response. setcharacterencoding ("UTF-8"); // sets the encoding format for the corresponding content
Fname = java.net. urlencoder. encode (fname, "UTF-8 ");
Response. setheader ("content-disposition", "attachment; filename =" + new string (fname. getbytes ("UTF-8"), "GBK") + ". xls ");
Response. setcontenttype ("application/msexel"); // defines the output type.
Simpleexcelwrite Sw = new simpleexcelwrite ();
Sw. createexcel (OS );
%>