ApplicationClass ExcelApp = New ApplicationClass ();
2) Change the Excel title bar: ExcelApp. Caption: = 'app calls Microsoft Excel '; 3) Add a new workbook: ExcelApp. WorkBooks. Add; 4) open an existing workbook: ExcelApp. WorkBooks. Open ('C: \ Excel \ Demo.xls '); 5) set 2nd worksheets as active worksheets: ExcelApp. WorkSheets [2]. Activate; or ExcelApp. WorksSheets ['sheet2']. Activate; 6) assign values to cells: ExcelApp. Cells []. Value: = 'column 4 in the first row '; 7) set the width of the specified column (unit: number of characters). Take the first column as an example: ExcelApp. ActiveSheet. Columns [1]. ColumnsWidth: = 5; 8) set the height of the specified row (unit: lbs) (1 lbs = 0.035 cm). Take the second behavior as an example: ExcelApp. ActiveSheet. Rows [2]. RowHeight: = 1/0. 035; // 1 cm 9) insert a paging character before Row 3: ExcelApp. WorkSheets [1]. Rows [8]. PageBreak: = 1; 10) Delete the paging character before the 8th column: ExcelApp. ActiveSheet. Columns [4]. PageBreak: = 0; 11) Specify the border line width: ExcelApp. ActiveSheet. Range ['b3: D4 ']. Borders [2]. Weight: = 3; 1-left 2-Right 3-Top 4-bottom 5-oblique (\) 6-oblique (/) 12) Clear the cell formula in the fourth column of the first row: ExcelApp. ActiveSheet. Cells [1, 4]. ClearContents; 13) set the font attribute of the first line: ExcelApp. ActiveSheet. Rows [1]. Font. Name: = 'shanghai '; ExcelApp. ActiveSheet. Rows [1]. Font. Color: = clBlue; ExcelApp. ActiveSheet. Rows [1]. Font. Bold: = True; ExcelApp. ActiveSheet. Rows [1]. Font. UnderLine: = True; 14) set the page: A. header: ExcelApp. ActiveSheet. PageSetup. CenterHeader: = 'report demo '; B. footer: ExcelApp. ActiveSheet. PageSetup. CenterFooter: = 'page & P '; C. The header to the top margin is 2 cm: ExcelApp. ActiveSheet. PageSetup. HeaderMargin: = 2/0. 035; D. footer end margin 3 cm: ExcelApp. ActiveSheet. PageSetup. HeaderMargin: = 3/0. 035; E. Top margin 2 cm: ExcelApp. ActiveSheet. PageSetup. TopMargin: = 2/0. 035; F. The bottom margin is 2 cm: ExcelApp. ActiveSheet. PageSetup. BottomMargin: = 2/0. 035; G. The left side is 2 cm: ExcelApp. ActiveSheet. PageSetup. LeftMargin: = 2/0. 035; H. Right side: 2 cm: ExcelApp. ActiveSheet. PageSetup. RightMargin: = 2/0. 035; I. horizontal center of pages: ExcelApp. ActiveSheet. PageSetup. CenterHorizontally: = 2/0. 035; J. Center the page vertically: ExcelApp. ActiveSheet. PageSetup. CenterVertically: = 2/0. 035; K. Print the cell network cable: ExcelApp. ActiveSheet. PageSetup. PrintGridLines: = True; 15) copy operation: A. Copy the entire Worksheet: ExcelApp. ActiveSheet. Used. Range. Copy; B. Copy the Specified Region: ExcelApp. ActiveSheet. Range ['a1: e2']. Copy; C. paste the file at A1: ExcelApp. ActiveSheet. Range. ['a1']. PasteSpecial; D. paste it from the end of the file: ExcelApp. ActiveSheet. Range. PasteSpecial; 16) insert a row or column: A. ExcelApp. ActiveSheet. Rows [2]. Insert; B. ExcelApp. ActiveSheet. Columns [1]. Insert; 17) delete a row or column: A. ExcelApp. ActiveSheet. Rows [2]. Delete; B. ExcelApp. ActiveSheet. Columns [1]. Delete; 18) print the preview Worksheet: ExcelApp. ActiveSheet. PrintPreview; 19) print the output Worksheet: ExcelApp. ActiveSheet. PrintOut; 20) Save the worksheet: If not ExcelApp. ActiveWorkBook. Saved then ExcelApp. ActiveSheet. PrintPreview; 21) Save the worksheet as follows: ExcelApp. SaveAs ('C: \ Excel \ Demo1.xls '); 22) discard the storage: ExcelApp. ActiveWorkBook. Saved: = True; 23) Close the workbook: ExcelApp. WorkBooks. Close; 24) Exit Excel: ExcelApp. Quit;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.