delphi excel spreadsheet operation several controls for use

Were placed in the Form ExcelApplication, ExcelWorkbook and ExcelWorksheet.
1) Open the Excel
ExcelApplication1.Connect;
2) the current window display:
ExcelApplication1.Visible [0]: = True;
3) change the Excel title bar:
ExcelApplication1.Caption: = 'Excel application calls in the Microsoft';
4) add new workbook :
ExcelWorkbook1.ConnectTo (ExcelApplication1.Workbooks.Add (EmptyParam, 0));
. 5) to add a new worksheet:
var Temp_Worksheet: _Worksheet;
the begin
Temp_Worksheet:. = ExcelWorkbook1
Worksheets.Add (EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0) AS _Worksheet;
ExcelWorkSheet1.ConnectTo (Temp_WorkSheet);
End;
6) to open an existing workbook:
ExcelApplication1.Workbooks.Open (c: /a.xls
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0)
. 7) is provided for the second sheet active sheet:
ExcelApplication1.WorkSheets [2] .Activate; or
ExcelApplication1.WorksSheets [ 'Sheet2']. the Activate;
. 8) assigned to the cells:
ExcelApplication1.Cells [l, 4] .Value: = 'a first column of the fourth row';
9) sets the width (in the specified column: number of characters), as a first Example:
ExcelApplication1.ActiveSheet.Columns [. 1] .ColumnsWidth: =. 5;
10) sets the height of the specified row (units: lb) (1 lb = 0.035 cm), a second Example behavior:
ExcelApplication1.ActiveSheet.Rows [2] .RowHeight: = 1 / 0.035; // 1 cm
11) prior to insert page breaks, line 8:
ExcelApplication1.WorkSheets [. 1] .Rows [8] .PageBreak: =. 1;
12 is) delete page break before column 8 :
ExcelApplication1.ActiveSheet.Columns [. 4] .PageBreak: = 0;
13 is) specified border width:
ExcelApplication1.ActiveSheet.Range [ 'B3: D4'] .Borders [2] .Weight: =. 3;
l- 2- left top and right bottom 4-5- swash 3- (/) 6- oblique (/)
14) Clear The first row of the fourth column of cells formula:
ExcelApplication1.ActiveSheet.Cells [l, 4] .ClearContents;
15) is provided a first row font attributes:
ExcelApplication1.ActiveSheet.Rows [. 1] .Font.Name: = 'official script';
ExcelApplication1.ActiveSheet.Rows [. 1] .Font.Color: = clBlue;
ExcelApplication1.ActiveSheet.Rows [. 1] .Font.Bold: = True;
ExcelApplication1.ActiveSheet.Rows [. 1] .Font.UnderLine: = True;
16) page setup:
A header:.
ExcelApplication1.ActiveSheet.PageSetup.CenterHeader: = 'reports demonstrate';
B footer:.
ExcelApplication1.ActiveSheet.PageSetup.CenterFooter: = 'on page & P';
C header to the top edge. from 2cm:
ExcelApplication1.ActiveSheet.PageSetup.HeaderMargin: = 2 / 0.035;
. footer in the end D side margins 3cm:
ExcelApplication1.ActiveSheet.PageSetup.HeaderMargin: =. 3 / 0.035;
E top margin 2cm:.
ExcelApplication1.ActiveSheet.PageSetup.TopMargin: = 2 / 0.035;
F 2cm bottom margin:
ExcelApplication1.ActiveSheet.PageSetup.BottomMargin: = 2 / 0.035;
G left margin 2cm:.
ExcelApplication1.ActiveSheet.PageSetup.LeftMargin: = 2 / 0.035;
H right margin 2cm:.
ExcelApplication1.ActiveSheet.PageSetup.RightMargin: = 2 / 0.035 ;
I is centered horizontally page:.
ExcelApplication1.ActiveSheet.PageSetup.CenterHorizontally: = 2 / 0.035;
J page vertically centered:.
ExcelApplication1.ActiveSheet.PageSetup.CenterVertically: = 2 / 0.035;
K printing unit grid line:.
ExcelApplication1.ActiveSheet. PageSetup.PrintGridLines: = True;
. 17) copy operation:
. A copy of the entire sheet:
ExcelApplication1.ActiveSheet.Used.Range.Copy;
B copies designated areas:.
ExcelApplication1.ActiveSheet.Range [ 'A1: E2 of'] .Copy;
C from the paste start position A1:.
ExcelApplication1.ActiveSheet.Range [ 'A1']. .PasteSpecial;
. D beginning from the end of the file and paste:
ExcelApplication1.ActiveSheet.Range.PasteSpecial;
18 is) insert a row or column:
a ExcelApplication1.ActiveSheet.Rows [2] .Insert;.
B ExcelApplication1.ActiveSheet.Columns [. 1].. INSERT;
. 19) to delete a row or column:
. ExcelApplication1.ActiveSheet.Rows a [2] .Delete;
B ExcelApplication1.ActiveSheet.Columns [. 1] .Delete;.
20 is) Print preview worksheet:
ExcelApplication1.ActiveSheet.PrintPreview;
21 is) printout worksheet:
ExcelApplication1.ActiveSheet.PrintOut;
22 is) save a worksheet:
Not the then ExcelApplication1.ActiveWorkBook.Saved IF
ExcelApplication1.ActiveSheet.PrintPreview;
23 is) worksheet Save as:
ExcelApplication1.SaveAs ( 'C: /Excel/Demo1.xls');
24) to abandon Save:
ExcelApplication1.ActiveWorkBook.Saved: = True ;
25) closes the workbook:
ExcelApplication1.WorkBooks.Close;
26 is) exit Excel:
ExcelApplication1.Quit;
ExcelApplication1.Disconnect;
(iii) using the two-dimensional map Excle Delphi control
were placed in the Form ExcelApplication, ExcelWorkbook and ExcelWorksheet
var asheet1, achart, Range: Variant;
. 1) to select the first job when the first thin sheet
asheet1: ExcelApplication1.Workbooks = [. 1] .Worksheets [. 1];
2) adding a two-dimensional map
achart: = asheet1.chartobjects.add (100,100,200,200);
3) selecting a two-dimensional form in FIG
achart.chart.charttype: = 4;
4) assigned to the two-dimensional map
Series: = achart.chart.seriescollection;
Range: = Sheet1 R2C3: r3c9;!
Series.add (Range, to true);
. 5) two-dimensional map of the captioned
achart.Chart.HasTitle: = true;
achart.Chart.ChartTitle.Characters.Text: = 'Excle dimensional map'
6) changing the two-dimensional map of the headline font size
achart.Chart.ChartTitle.Font.size: = 6;
. 7) to the two Weitu Jia standard Description
achart.Chart.Axes (xlCategory, xlPrimary) .HasTitle: = True;
achart.Chart.Axes (xlCategory, xlPrimary) .AxisTitle.Characters.Text: = 'described subscript';
8) to the two left Weitu Jia standard Description
achart.Chart.Axes (xlValue, xlPrimary) .HasTitle: = True;
achart.Chart.Axes (xlValue, xlPrimary) .AxisTitle.Characters.Text: = 'left scale described';
9) to the right two Weitu Jia standard Description
achart.Chart.Axes (xlValue, xlSecondary) .HasTitle: = True;
achart.Chart.Axes (xlValue, xlSecondary) .AxisTitle.Characters.Text: = ' right scale described';
10) to change the size of the two-dimensional map display area
achart.Chart.PlotArea.Left: =. 5;
achart.Chart.PlotArea .Width: = 223;
achart.Chart.PlotArea.Height: = 108;
. 11) coupled to the two-dimensional coordinate axes DESCRIPTION FIG
achart.chart.seriescollection [1] .NAME: = 'axes Definitions';

Published 30 original articles · won praise 2 · views 50000 +

Guess you like

Origin blog.csdn.net/khzide/article/details/499765