云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Delphi操作EXCEL函数整理

Delphi操作EXCEL函数整理

  • 62 次阅读
  • 3 次下载
  • 2025/5/3 13:06:02

2. 页脚:

Sheet.PageSetup.CenterFooter := '第&P页'; 3页眉到顶端边距2cm:

Sheet.PageSetup.HeaderMargin := 2/0.035; 4.页脚到底端边距3cm:

Sheet.PageSetup.HeaderMargin := 3/0.035; 5.顶边距2cm:

Sheet.PageSetup.TopMargin := 2/0.035; 6.底边距2cm:

Sheet.PageSetup.BottomMargin := 2/0.035; 7.左边距2cm:

Sheet.PageSetup.LeftMargin := 2/0.035; 8.右边距2cm:

Sheet.PageSetup.RightMargin := 2/0.035; 9.页面水平居中:

Sheet.PageSetup.CenterHorizontally := 2/0.035; 10.页面垂直居中:

Sheet.PageSetup.CenterVertically := 2/0.035; 11.打印单元格网线:

Sheet.PageSetup.PrintGridLines := True; 12缩放比例

Sheet.PageSetup.zoom := 75; 13横向打印

Sheet.PageSetup.Orientation:= xllandscape; 14 纵向打印

Sheet.PageSetup.Orientation:=xlportrait; 15.设置打印标题行

Sheet.PageSetup.PrintTitleRows := Sheet.Rows['1:3'].Address ; Sheet.PageSetup.PrintTitleColumns := Sheet.Rows[3].Address; 16.打印预览工作表: Sheet.PrintPreview; 17 打印输出工作表: Sheet.PrintOut; 十三、拷贝操作: 1. 拷贝整个工作表: Sheet.Used.Range.Copy; 2. b.拷贝指定区域:

Sheet.Range[ 'A1:E2' ].Copy;

3. 从A1位置开始粘贴: Sheet.Range.[ 'A1' ].PasteSpecial; 4. 从文件尾部开始粘贴: Sheet.Range.PasteSpecial; 十四、行列的插入删除 1. 插入一行或一列:

a. ExcelApp.ActiveSheet.Rows[2].Insert; b. ExcelApp.ActiveSheet.Columns[1].Insert; 2. 删除一行或一列:

a. ExcelApp.ActiveSheet.Rows[2].Delete; b. ExcelApp.ActiveSheet.Columns[1].Delete; 十五、Excel保存关闭 1. 工作表保存:

if not ExcelApp.ActiveWorkBook.Saved then ExcelApp.ActiveSheet.PrintPreview; 2. 工作表另存为:

ExcelApp. SaveAs ( filepath); 3 放弃存盘:

ExcelApp.ActiveWorkBook.Saved := True; 4. 关闭工作簿:

ExcelApp.WorkBooks.Close; 5. 退出 Excel: ExcelApp.Quit; 6. 工作表关闭

ExcelApp.WorkBooks.Close ; 十六、其他

1. 已经使用的行数

Sheet.UsedRange.Rows.Count;

(三) 使用Delphi 控制Excle二维图

在Form中分别放入ExcelApplication, ExcelWorkbook和ExcelWorksheet var asheet1,achart, range:variant;

1)选择当第一个工作薄第一个工作表

asheet1:=ExcelApplication1.Workbooks[1].Worksheets[1];

2)增加一个二维图

achart:=asheet1.chartobjects.add(100,100,200,200);

3)选择二维图的形态 achart.chart.charttype:=4;

4)给二维图赋值

series:=achart.chart.seriescollection; range:=sheet1!r2c3:r3c9; series.add(range,true);

5)加上二维图的标题

achart.Chart.HasTitle:=True;

achart.Chart.ChartTitle.Characters.Text:=’ Excle二维图’

6)改变二维图的标题字体大小 achart.Chart.ChartTitle.Font.size:=6;

7)给二维图加下标说明

achart.Chart.Axes(xlCategory, xlPrimary).HasTitle := True;

achart.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text := '下标说明';

8)给二维图加左标说明

achart.Chart.Axes(xlValue, xlPrimary).HasTitle := True;

achart.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := '左标说明';

9)给二维图加右标说明

achart.Chart.Axes(xlValue, xlSecondary).HasTitle := True;

achart.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text := '右标说明';

10)改变二维图的显示区大小 achart.Chart.PlotArea.Left := 5; achart.Chart.PlotArea.Width := 223; achart.Chart.PlotArea.Height := 108;

11)给二维图坐标轴加上说明

achart.chart.seriescollection[1].NAME:='坐标轴说明';

在delphi中对单元格(集),区域,工作表等所有对象的操作都是要Variant来实现的。 自己的程序中选定区域赋给Range: Var range,sheet:Variant; Range:= olecon.OleObject.application.Range['A1:C3']; 或者: Sheet:= olecon.OleObject.application.Activesheet; Range:= olecon.OleObject.application.Range[sheet.cells[1,1],sheet.cells[3,3]]; 对上面的Range合并单元格: Range. FormulaR1C1:=’合并区’;//合并后写入文本 注意以后要读合并的单元格里面的文本就是读合并区域的左上角的那个单元格的文本 在excel表中选定区域赋给range: range:=excel_grid1.OleObject.application.selection; 拆分单元格: Range.unmerge; 合并后设定单元格(集)的格式: Range.HorizontalAlignment:= xlCenter;// 文本水平居中方式 Range.VerticalAlignment:= xlCenter//文本垂直居中方式 Range.WrapText:=true;//文本自动换行 Range.Borders.LineStyle:=1//加边框 Range.Interior.ColorIndex:=39;//填充颜色为淡紫色 Range.Font.name:=’ 隶书’;//字体 Range.Font.Color:=clBlue;//字体颜色 Range.merge;

搜索更多关于: Delphi操作EXCEL函数整理 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

2. 页脚: Sheet.PageSetup.CenterFooter := '第&P页'; 3页眉到顶端边距2cm: Sheet.PageSetup.HeaderMargin := 2/0.035; 4.页脚到底端边距3cm: Sheet.PageSetup.HeaderMargin := 3/0.035; 5.顶边距2cm: Sheet.PageSetup.TopMargin := 2/0.035; 6.底边距2cm: Sheet.PageSetup.BottomMargin := 2/0.035; 7.左边距2cm: Sheet.PageSetup.LeftMargin := 2/0.035; 8.右边距2cm: Sheet.PageSetup.RightMargin := 2/0

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com