Set objexcelapp = Createobject ("Excel. application ")
2objexcelapp. displayalerts = false
3objexcelapp. application. Visible = false
4objexcelapp. workbooks. Add
5 set objexcelbook = objexcelapp. activeworkbook
6 set objexcelsheets = objexcelbook. worksheets
7 set objspreadsheet = objexcelbook. Sheets (1)
8
9dim objfield, icol, irow
10 icol = 1' get the column number
11 irow = 1' get the row number
12objspreadsheet. cells (irow, icol). value = "use ASP to import data from access to an Excel file -- Western e" 'insert data into cells
13objspreadsheet. Columns (icol). shrinktofit = true' sets whether to automatically adapt to the table unit size (the cell width remains unchanged)
14' set the font in the Excel table
15objspreadsheet. cells (irow, icol). Font. Bold = true 'cell font bold
16objspreadsheet. cells (irow, icol). Font. italic = false' cell font skew
17objspreadsheet. cells (irow, icol). Font. size = 20 'set the cell font size
18objspreadsheet. cells (irow, icol). paragraphformat. Alignment = 1' sets the cell alignment format: Center
19objspreadsheet. cells (irow, icol). Font. Name = "'"' set the cell font
20objspreadsheet. cells (irow, icol). Font. colorindex = 2' sets the color of the cell text. The color can be queried, and 2 is white.
21objspreadsheet. Range ("A1: F1"). merge' merge cells (unit area)
22objspreadsheet. Range ("A1: F1"). Interior. colorindex = 1' background color of the design unit Network
23 'objspreadsheet. Range ("A2: F2"). wraptext = true' sets character rollback (automatic line feed)
24 irow = irow + 1
25for each objfield in objrs. Fields
26 'objspreadsheet. Columns (icol). shrinktofit = true
27objspreadsheet. cells (irow, icol). value = objfield. Name
28' set the font in the Excel table
29objspreadsheet. cells (irow, icol). Font. Bold = true
30objspreadsheet. cells (irow, icol). Font. italic = false
31objspreadsheet. cells (irow, icol). Font. size = 20
32objspreadsheet. cells (irow, icol). halignment = 2' Center
33 icol = icol + 1