We usually put the file into a dedicated server or cluster, complex points such as Fastdfs, HDFs cluster. Simple point to operate the disk file directly via FTP. This article focuses on demonstrating how to play Excel, so put applications and files directly into the same machine.
Let's look at an effect chart and draw out the requirements:
According to the static information of the line site, the adjacency matrix of the starting and ending sites is generated, the fare of XX station to XX station is the matrix value, and the style is generated according to the color rules of the fare, so as to facilitate the visual observation of its jump result. How do we implement the diagram requirements? can be implemented using Java POI operations Excel files.
Need data: ① line code, site code, site name, ② site-> site: ticket price;
Ideas:
① first, generate the row title bar, which is the first three line headings;
② which, the first three rows three columns of information is static (fixed value), followed by rows of dynamic values (from the DTO assigned);
③ establishes the line-> style hashmap, assigns the color to the line area;
After the ④ is established, the horizontal & vertical title bar should be merged into the cell by the line number;
⑤ also need to consider the horizontal & vertical title bar freeze rolling problem;
⑥ vertical title bar and content area, synthesized from DTO object;
⑦ each Dto object needs to contain vertical title bar properties and value sequences;
⑧ Vertical title bar using rule 1, Value sequence using rule 2;
⑨ the cells in turn to produce the Excel file as shown above.
requirements: fixed static information, which is pieced together according to the site order of metro lines, is used to assist the adjacency matrix of production rules. In the subway line map, the site and site is a map, according to the different algorithm types, you can calculate the site to the site of the lowest ticket prices, the shortest path, time is minimal ...
public void Saveexcel (string title, list<list<stationexceldto>> result, list<string> headers, string
Docpath, String fileName) {OutputStream stream = null;
The file's parent path String FilePath = Docpath + fileName;
File Excelparentpath = new file (Docpath);
File Excelfile = new file (FilePath);
try {///first determine that the directory in which Excel is stored does not exist, but first create an if (!excelparentpath.exists ()) {excelparentpath.mkdirs ();
//To determine that the file does not exist, then create an if (!excelfile.exists ()) {excelfile.createnewfile ();
///Create write file stream = new FileOutputStream (FilePath);
Call the method that generates Excel Exportexcel (title, headers, result, stream);
catch (FileNotFoundException e) {e.printstacktrace ();
catch (IOException e) {e.printstacktrace ();
}finally {if (stream!= null) {try {stream.close (); catch (IOException e) {E.prinTstacktrace (); }
}
}
}
To be Continued ...
Fastdfs+nginx (single point of deployment) case
Https://www.cnblogs.com/cnmenglang/p/6251696.html
Author: @nanphonfy
Reprint Source: Http://blog.csdn.net/nanphonfy