articles from jbp74c37ad170 Excel programming statements there are those.
Full Control of Excel
First create the Excel object, using Comobj:
Dim Excelid as Excel.Application
Set Excelid as New Excel.Application
1) Display the current window:
Excelid.visible: = True;
2) Change the Excel title bar:
Excelid.caption: = ' application calls Microsoft Excel ';
3) Add a new workbook:
EXCELID.WORKBOOKS.ADD;
4) Open a workbook that already exists:
ExcelID.WorkBooks.Open (' C:\Excel\Demo.xls ');
5) Set the 2nd worksheet as the active sheet:
EXCELID.WORKSHEETS[2]. Activate;
or excelid.worksheets[' Sheet2 '). Activate;
6) Assign a value to the cell:
excelid.cells[1,4]. Value: = ' first row fourth column ';
7) Set the width of the specified column (in number of characters), in the first column as an example:
EXCELID.ACTIVESHEET.COLUMNS[1]. Columnswidth: = 5;
8) Set the height of the specified line (in points) (1 lbs = 0.035 cm), with the second behavior example:
EXCELID.ACTIVESHEET.ROWS[2]. RowHeight: = 1/0.035; 1 cm
9) Insert a page break before line 8th:
EXCELID.WORKSHEETS[1]. ROWS[8]. PageBreak: = 1;
10) Delete the page break before the 8th column:
EXCELID.ACTIVESHEET.COLUMNS[4]. PageBreak: = 0;
11) Specify the width of the border line:
excelid.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 for column Fourth of the first row:
excelid.activesheet.cells[1,4]. clearcontents;
13) Set the first line font properties:
EXCELID.ACTIVESHEET.ROWS[1]. Font.Name: = ' official script ';
EXCELID.ACTIVESHEET.ROWS[1]. Font.Color: = Clblue;
EXCELID.ACTIVESHEET.ROWS[1]. Font.Bold: = True;
EXCELID.ACTIVESHEET.ROWS[1]. Font.underline: = True;
14) make Page setup:
A. Header:
ExcelID.ActiveSheet.PageSetup.CenterHeader: = ' report presentation ';
B. Footer:
ExcelID.ActiveSheet.PageSetup.CenterFooter: = ' &p page ';
C. Header to top margin 2cm:
ExcelID.ActiveSheet.PageSetup.HeaderMargin: = 2/0.035;
D. Footer End margin 3cm:
ExcelID.ActiveSheet.PageSetup.HeaderMargin: = 3/0.035;
E. Top margin 2cm:
ExcelID.ActiveSheet.PageSetup.TopMargin: = 2/0.035;
F. Bottom margin 2cm:
ExcelID.ActiveSheet.PageSetup.BottomMargin: = 2/0.035;
G. Left margin 2cm:
ExcelID.ActiveSheet.PageSetup.LeftMargin: = 2/0.035;
H. Right margin 2cm:
ExcelID.ActiveSheet.PageSetup.RightMargin: = 2/0.035;
I. The page is centered horizontally:
ExcelID.ActiveSheet.PageSetup.CenterHorizontally: = 2/0.035;
J. The page is centered vertically:
ExcelID.ActiveSheet.PageSetup.CenterVertically: = 2/0.035;
K. Print the Cell network cable:
ExcelID.ActiveSheet.PageSetup.PrintGridLines: = True;
15) Copy operation:
A. Copy the entire worksheet:
ExcelID.ActiveSheet.Used.Range.Copy;
B. Copy the specified area:
excelid.activesheet.range[' A1:e2 '. Copy;
C. Start pasting from A1 position:
ExcelID.ActiveSheet.Range. [' A1 ']. PasteSpecial;
D. Start pasting from the tail of the file:
ExcelID.ActiveSheet.Range.PasteSpecial;
16) Insert one row or column:
A. excelid.activesheet.rows[2]. Insert;
B. excelid.activesheet.columns[1]. Insert;
17) Delete one row or column:
A. excelid.activesheet.rows[2]. Delete;
B. excelid.activesheet.columns[1]. Delete;
18) Print Preview worksheet:
ExcelID.ActiveSheet.PrintPreview;
19) Print out worksheet:
ExcelID.ActiveSheet.PrintOut;
20) Worksheet Save:
If not ExcelID.ActiveWorkBook.Saved Then
ExcelID.ActiveSheet.PrintPreview
End if
21) Save the worksheet as:
Excelid.saveas (' C:\Excel\Demo1.xls ');
22) Discard the disk:
ExcelID.ActiveWorkBook.Saved: = True;
23) Close Workbook:
ExcelID.WorkBooks.Close;
24) Exit Excel:
Excelid.quit;
25) Set the worksheet password:
ExcelID.ActiveSheet.Protect "123", Drawingobjects:=true, Contents:=true, scenarios:=true
Excel is displayed in a way that maximizes
ExcelID.Application.WindowState = xlmaximized
27) The working thin display mode is maximized
ExcelID.ActiveWindow.WindowState = xlmaximized
28) Set the number of open default workbooks
Excelid.sheetsinnewworkbook = 3
29) ' Prompt to save when closed (true save; false not Saved)
Excelid.displayalerts = False
30) Set splitter window, and fixed line position
ExcelID.ActiveWindow.SplitRow = 1
ExcelID.ActiveWindow.FreezePanes = True
31) Set the print content to be fixed when printing
ExcelID.ActiveSheet.PageSetup.PrintTitleRows = "$1:$1"
32) Set the print title
ExcelID.ActiveSheet.PageSetup.PrintTitleColumns = ""
33) Set the display mode (display by pagination)
ExcelID.ActiveWindow.View = Xlpagebreakpreview
34) Set the display scale
ExcelID.ActiveWindow.Zoom = 100
35) Let Excel respond to DDE requests
Ex.Application.IgnoreRemoteRequests = False
Other specific content, you can learn VBA.
[Go] C # operations Excel file