The processing of form (report) is often used in programming in programming. Here are a method of writing data with java to Excel table method:
1. Add jar file
Java introduces the export Excel file to introduce the JXL.JAR package. The most important thing is that this API is pure Java, which does not rely on the Windows system. Even if it runs under Linux, it can also handle the excel file correctly. Download address: http://www.andykhan.com/jexcelapi/
2.jxl's understanding of the excel table
See: //www.vevb.com/article/68631.htm
As shown in the figure below, the Excel file T.XLS is preparing to be established. Coordinates (columns, lines): characters (0,0), teaching assistant (0,3), function description (3,0), UC22 (1,4).
3. Java code generates the T.XLS file shown in the above picture according to the data in the program
Import java.io.file; Import JXL.*; Import JXL.Write.label; Import JXL.Write.writSheet; Import JXL.Writableworkbook; Riter_excel {Public Static void main (string [] args) {// Title line string title [] = {"character", "number", "function name", "function description"}; content string context [] [] = {"uc11", "Setting course", "Create Creation", "Create Create" Course "}, {" uc12 "," Set the list of student "," Give the list of students associated with the course "}, {" uc21 "," View Student List ","}, {"UC22", "View Group "Information", "Display the Teachers' House List of List Information"}}; // Operation executing TRY {//t.xls as a new file name WritableWorkbook = Workbook.createworkBook (New File ("T.XLS") // Generate a worksheet named "First Page", parameter 0 means that this is the first page. ; I <4; I ++) // Title Sheet.addcell (New Label (I, 0, Title [i])); for (int i = 0; i <4; i ++) // context {for (int j = 0; j <3; j ++) {sheet.addcell (new label (J+1, I+1, Context [i] [j]); ); Sheet.addcell (new label (0,3, "" assistant instructor "); /*merged cell grid. Combine can be both horizontal or vertical*WritableSheet.Mergecells p, int q); Reinforcement area consisting of unit grids consisting of unit grids from (m, n) to (p, q) is merged * */ sheet.mergecells (0,1,0,2); sheet.mergecells (0,3 , 0,4); // Write the data book.write (); // Close the file book.close ();} Catch (Exception E) {}}}}}