- 19
- 0
- 约8.29千字
- 约 7页
- 2018-12-29 发布于四川
- 举报
( 一 ) 使用动态创建的方法
首先创建 Excel 对象,使用ComObj :
Var
ExcelApp : Variant ;
ExcelApp := CreateOleObject ( Excel.Application ) ;
1 ) 显示当前窗口:
ExcelApp.Visible := True ;
2 ) 更改 Excel 标题栏:
ExcelApp.Caption := 应用程序调用 Microsoft Excel ;
3 ) 添加新工作簿:
ExcelApp.WorkBooks.Add ;
4 ) 打开已存在的工作簿:
ExcelApp.WorkBooks.Open ( C : \Excel\Demo.xls ) ;
5 ) 设置第2个工作表为活动工作表:
ExcelApp.WorkSheets [ 2 ] .Activate ;
或
ExcelApp.WorksSheets [ Sheet2 ] .Activate ;
6 ) 给单元格赋值:
ExcelApp.Cells [ 1 , 4 ] .Value := 第一行第四列 ;
7 ) 设置指定列的宽度(单位:字符个数),以第一列为例:
ExcelApp.ActiveSheet.Columns [ 1 ] .ColumnsWidth
原创力文档

文档评论(0)