预览加载中,请您耐心等待几秒...
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

DEPHI操作EXCEL的例子varForm1:TForm1;ExcelApp:Variant;implementation{$R*.dfm}procedureTForm1.FormCreate(Sender:TObject);beginExcelApp:=CreateOleObject(‘Excel.Application’);end;procedureTForm1.Button1Click(Sender:TObject);begin//ExcelApp.WorkBooks.Open(‘c:\1.xls’);ExcelApp.WorkBooks.Open(ExtractFileDir(application.ExeName)+’\2.xls’);ExcelApp.Visible:=True;end;procedureTForm1.Button2Click(Sender:TObject);beginexcelapp.workbooks.close;end;procedureTForm1.Button3Click(Sender:TObject);beginExcelApp.ActiveWorkBook.Sheets['Sheet2'].Selectend;procedureTForm1.Button4Click(Sender:TObject);beginexcelapp.activeworkbook.sheets[edit1.Text].select;excelapp.activeworkbook.sheets[edit1.Text].range[edit2.Text].select;edit3.Text:=excelapp.ActiveCell.value;//取公式excelapp.ActiveCell.FormulaR1C1//取值excelapp.ActiveCell.valueend;procedureTForm1.Button5Click(Sender:TObject);beginmemo1.Clear;excelapp.activeworkbook.sheets[edit4.Text].select;excelapp.activeworkbook.sheets[edit4.Text].range[edit5.Text].select;memo1.Lines.Add(‘字体:’+excelapp.Selection.Font.name);ifnotVarIsNull(excelapp.Selection.Font.size)thenmemo1.Lines.Add(‘字号:’+inttostr(excelapp.Selection.Font.size));memo1.Lines.Add(‘字形:’+excelapp.Selection.Font.FontStyle);ifnotVarIsNull(excelapp.Selection.Font.Underline)thenmemo1.Lines.Add(‘下划线:’+inttostr(excelapp.Selection.Font.Underline));ifnotVarIsNull(excelapp.Selection.Font.ColorIndex)thenmemo1.Lines.Add(‘字体颜色:’+inttostr(excelapp.Selection.Font.ColorIndex));ifnotVarIsNull(excelapp.Selection.Interior.ColorIndex)thenmemo1.Lines.Add(‘填充颜色:’+inttostr(excelapp.Selection.Interior.ColorIndex));ifnotVarIsNull(excelapp.Selection.HorizontalAlignment)thenmemo1.Lines.Add(‘文本水平对齐方式:’+inttostr(excelapp.Selection.HorizontalAlignment));ifnotVarIsNull(excelapp.Selection.VerticalAlignment)thenmemo1.Lines.Add(‘文本垂直对齐方式:’+inttostr(excelapp.Selection.VerticalAlignment));ifnotVarIsNull(excelapp.Selection.MergeCells)thenmemo1.Lines.Add(‘合并单元格:’+inttostr(excelapp.Selection.MergeCells));ifnotVarIsNull(excelapp.Selecti