Microsoft. Office. InterOP. Excel usage

Source: Internet
Author: User
1) applicationclass excelapp = new applicationclass (); 2) Change the Excel title bar: excelapp. caption: = 'application 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 a value to the cell: excelapp. cells [1, 4]. value: = 'column 4 in the first row '; 7) set the width of the specified column (unit: number of characters). The first column is used as an example: excelapp. activesheet. columns [1]. columnswidth: = 5; 8) set the height of the specified row (unit: lbs) (1 lb = 0.035 cm). Take the second behavior as an example: excelapp. activesheet. rows [2]. rowheight: = 1/0. 035; // 1 cm 9) insert a page break before the first line: excelapp. worksheets [1]. rows [8]. pagebreak: = 1; 10) Delete the page break 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: = 'shanghaishu '; excelapp. activesheet. rows [1]. font. color: = clblue; excelapp. activesheet. rows [1]. font. bold: = true; excelapp. activesheet. rows [1]. font. underline: = true; 14) page settings:. header: excelapp. activesheet. pagesetup. centerheader: = 'report demo'; B. footer: excelapp. activesheet. pagesetup. centerfooter: = 'page & P '; C. header-to-top margin 2 cm: excelapp. activesheet. pagesetup. headermargin := 2/0. 035; D. the footer end margin is 3 cm: excelapp. activesheet. pagesetup. headermargin := 3/0. 035; E. top margin 2 cm: excelapp. activesheet. pagesetup. topmargin: = 2/0. 035; F. bottom margin 2 cm: excelapp. activesheet. pagesetup. bottommargin: = 2/0. 035; G. 2 cm left: excelapp. activesheet. pagesetup. leftmargin := 2/0. 035; H. 2 cm from the right: excelapp. activesheet. pagesetup. rightmargin := 2/0. 035; I. page horizontal center: 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:. copy the entire Worksheet: excelapp. activesheet. used. range. copy; B. copy the specified region: excelapp. activesheet. range ['a1: e2']. copy; C. paste from 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:. excelapp. activesheet. rows [2]. insert; B. excelapp. activesheet. columns [1]. insert; 17) delete a row or column:. excelapp. activesheet. rows [2]. delete; B. excelapp. activesheet. columns [1]. delete; 18) print 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: excelapp. saveas ('C: \ Excel \ demo1.xls '); 22) discard storage: excelapp. activeworkbook. saved: = true; 23) Close the workbook: excelapp. workbooks. close; 24) Exit Excel: excelapp. quit;

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.