Home > other >  Excel data import
Excel data import

Time:11-22

The MVC project Excel data into two methods:
Both methods need to introduce NPOI libraries can operate;
1. Manually import:
Step 1: need to export the data from the database query
Step 2: new workbook

Step 3: the new worksheet in the workbook

Step 4: create the title in the worksheet rows

4-1: set the header row style

4-2: create a cell in the header row

4-3: set the cell value

4-4: merge cells
Four Numbers represent the subscript: from row to row 0, 0 from 0 to 6 columns
Popular speaking: merge the first line of the first cell to the sixth cell
4-5: in the workbook in a new cell style

4-6: set the cell style

4-7: in the workbook new font style

4-8: set the font style

4-9: set set good style to the header row

Step 5: set the header lines
5-1: new header row in the worksheet, set the line height

5-2: new cell in the header row

5-3: in the workbook in a new cell style

5-4: set the cell style

5-5: bezel Settings

5-6: set the font style, font style into the cell style


5-7: use add header lines of each cell cycle style

Step 6: set the table content
6-1: new forms of cell style

6-2: set the cell style

6-3: create a line, to set up the cell contents and styles

6-4: set each cell width to adaptive

Step 7: to create good Excel output to the browser
7-1: joining together the file name: must be at the end. XLS, ensure compatibility

7-2: convert Excel to current output






2. Template import:
Step 1: need to export the data from the database query
Step 2: use the NPIO open template
1-1: read the template path

1-2: using the file open flow template Excel

Step 3: the file conversion into a workbook

Step 4: open the workbook first worksheet

Step 5: set the template header row content

Step 6: to fill in the template content
6-1: new data and set the cell style

6-2: create line cycle, to set up the cell contents and styles


6-3: set the cell width to adaptive

Step 7: to create good Excel output to the browser
7-1: joining together to save name

7-2: the Excel into current output

Conclusion: export ideas (without considering style)
1. Check out to export data
2. New workbook
2. New work table
3. New header row, header lines
4. Circulation add rows of data



  • Related