Don't talk nonsense, post code
Introduction Rack Pack: Poi-3.12-20150511.jar Poi-ooxml-3.12-20150511.jar
Pipe network can be downloaded
Try{ flogicdataset<fdatainfodevicebrowserunit> unitlist = _devicebrowserconsole.select (Logiccontext); //Create a new Excel workbook HSSFWorkbook Workbook = new hssfworkbook (); hssfsheet sheet = workbook.createsheet ("Sheet1"); / /create a row at index 0 (the topmost row) string[] headers = new string[]{"header information", "Device Information"}; Hssfrow headerrow = sheet.createrow (0); Hssfcell cell = headerrow.createcell (0); Cell.setcelltype (Xssfcell.cell_type_string); cell.setcellvalue (Headers[0]); hssfcell cell0 = headerrow.createcell (1); cell0.setcelltype (xssfcell.cell_type_string); cell0.setcellvalue (headers[1]); int index = 0; for ( Fdatainfodevicebrowserunit unit : unitlist) { index++; Hssfrow row = sheet.createrow (Index); hssfcell cell1 = row.createcell (0); //defines a cell as a string type &Nbsp; cell1.setcelltype ( xssfcell.cell_type_string); // Enter some content in the cell Cell1.setcellvalue (Unit.agentcode ()); Hssfcell cell2 = row.createcell (1); //defines a cell as a string type Cell2.setcelltype (xssfcell.cell_type_string); //enter some content in the cell Cell2.setcellvalue (Unit.content ()); } string filepath = "D:/devicelist_" + rdatetime.currentdatetime () + ". xls"; //new file output stream fileoutputstream fout = new fileoutputstream (FilePath); //writes data to excel Workbook.write (FOut); fout.close (); basepage.ajax (1, filepath); _logger.debug (this, "expend", "expend succeed. (Path={1})", filePath); }catch (exception e) { e.printstacktrace (); basepage.ajax (0, E.getmessage ()); &nbsP; _logger.debug (this, "expend", "expend fail. (Message={1})" , e); }
Java Apache POI export Excel