如何合并Excel单元格(急) 请大家多帮忙~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~多谢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~一定有分送到的~~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.启动Excel 在Uses中加入Comobj;var v:Variant;begin v:=CreateOleobject(‘Excel.Application’); v.Visible:=true;end; 其中,Comobj中包含了用来检索OLE的对象和向其传发命令的例程,第一行代码启动Excel,执行后Excel会在内存中出现,因此第二行代码使之可见。2.关闭Excel 在创建了Excel Application对象后,调用它的Quit方法完成关闭事件。If not varIsEmpty(v) then v.quit; 如果需要在关闭前确定是否存盘,加入:v.DisplayAlert:=true; //确定存盘v.DisplayAlert:=false;//不存盘,直接退出3.加入工作表及对其表格内容的操作var Sheet: Variant;begin v.workbook.add; v.Workbooks.Add; v.Workbooks[1].WorkSheets[1].Name := '数据录入'; Sheet:= v.Workbooks[1].WorkSheets['数据录入']; Sheet.Cells[1,1] :='试验'; Label1.Caption:=Sheet.Cells[1,1];End; Sheet对象是很多页的集合,其他的Workbooks是工作薄的集合,WorkSheets对象是工作表的集合,Charts对象是图表的集合。4.格式的设置var Range: Variant;begin Range := v.Workbooks[1].WorkSheets['数据录入'].Range['A2:M2’]; //单元格从A2到M2 Range.Merge; //合并单元格 Range.Rows.RowHeight := 20; //设置行高 Range.Borders.LineStyle := 1; //加边框 Range.Columns[2].ColumnWidth := 12; // 设置列宽 Range.FormulaR1C1 := '标题'; Range.HorizontalAlignment := xlCenter; //水平对齐方式 Range.VerticalAlignment := xlCenter; //垂直对齐方式 Range.Characters.Font.Name := '宋体'; //字体 Range.Characters.Font.FontStyle := '加粗'; Range.Characters.Font.Size := 12; Range.Characters.Font.OutlineFont := False; //是否有下划线 Range.Characters.Font.ColorIndex := xlAutomatic; //颜色end; 其他的属性可以察看MSDN或者其他资料。5. 打印的设置var Sheet: Variant;begin Sheet := XLApp1.Workbooks[1].WorkSheets['数据录入']; Sheet.PageSetup.PrintTitleRows :='$1:$3'; //页眉 Sheet.PageSetup.PrintTitleColumns := ''; Sheet.PageSetup.LeftFooter := ' 注:页脚'+' 总共&N页'+'--第&P页'; //页脚 Sheet.PageSetup.LeftMargin := 30; //设置边距 Sheet.PageSetup.RightMargin := 30; Sheet.PageSetup.TopMargin := 30; Sheet.PageSetup.BottomMargin := 50; Sheet.PageSetup.PrintQuality := 400; //分辨率 Sheet.PageSetup.CenterHorizontally := True;//是否水平居中 Sheet.PageSetup.CenterVertically := True; //是否垂直居中 Sheet.PageSetup.Orientation := 2; //横向打印 Sheet.PageSetup.Draft := False; //非草稿模式 Sheet.PageSetup.FirstPageNumber := xlAutomatic; Sheet.PageSetup.BlackAndWhite := True; //黑白稿 Sheet.PageSetup.Zoom := 100; //缩放 sheet.PrintPreView; //打印预览end; 也是从网上COPY的,但是感觉还是不错的. 好了,到这,我已经介绍了大部分常用的控制方法,试试吧。提醒你,你的机子装了Excel没有…… 在Remote data module模块中能使用Constructor(构造函数)吗? mscomm控件问题 求救,十万火急!在线等答案! 大侠救命:如何把28828800000这样的整数转化为1971-12-1号? 在我想重载DBGrid组件.一些问题请教. 串口通讯 cport返回值问题!!在线等待 问点简单的问题,不过需要准确的方向! ???delphi5中键盘上的键(包括单键和组合键)如何识别??? 痴心不改'流合并'!!! 请问如何使Delphi+ADO分发做到最小?? ==用ExpressBars建菜单的问题?== 关于数据库连接超时问题
v:Variant;
begin
v:=CreateOleobject(‘Excel.Application’);
v.Visible:=true;
end; 其中,Comobj中包含了用来检索OLE的对象和向其传发命令的例程,第一行代码启动Excel,执行后Excel会在内存中出现,因此第二行代码使之可见。2.关闭Excel 在创建了Excel Application对象后,调用它的Quit方法完成关闭事件。If not varIsEmpty(v) then v.quit; 如果需要在关闭前确定是否存盘,加入:v.DisplayAlert:=true; //确定存盘
v.DisplayAlert:=false;//不存盘,直接退出3.加入工作表及对其表格内容的操作var
Sheet: Variant;
begin
v.workbook.add;
v.Workbooks.Add;
v.Workbooks[1].WorkSheets[1].Name := '数据录入';
Sheet:= v.Workbooks[1].WorkSheets['数据录入'];
Sheet.Cells[1,1] :='试验'; Label1.Caption:=Sheet.Cells[1,1];
End; Sheet对象是很多页的集合,其他的Workbooks是工作薄的集合,WorkSheets对象是工作表的集合,Charts对象是图表的集合。4.格式的设置var
Range: Variant;
begin
Range := v.Workbooks[1].WorkSheets['数据录入'].Range['A2:M2’]; //单元格从A2到M2
Range.Merge; //合并单元格
Range.Rows.RowHeight := 20; //设置行高
Range.Borders.LineStyle := 1; //加边框
Range.Columns[2].ColumnWidth := 12; // 设置列宽
Range.FormulaR1C1 := '标题';
Range.HorizontalAlignment := xlCenter; //水平对齐方式
Range.VerticalAlignment := xlCenter; //垂直对齐方式
Range.Characters.Font.Name := '宋体'; //字体
Range.Characters.Font.FontStyle := '加粗';
Range.Characters.Font.Size := 12;
Range.Characters.Font.OutlineFont := False; //是否有下划线
Range.Characters.Font.ColorIndex := xlAutomatic; //颜色
end; 其他的属性可以察看MSDN或者其他资料。5. 打印的设置var
Sheet: Variant;
begin
Sheet := XLApp1.Workbooks[1].WorkSheets['数据录入'];
Sheet.PageSetup.PrintTitleRows :='$1:$3'; //页眉
Sheet.PageSetup.PrintTitleColumns := '';
Sheet.PageSetup.LeftFooter := ' 注:页脚'+' 总共&N页'+'--第&P页'; //页脚
Sheet.PageSetup.LeftMargin := 30; //设置边距
Sheet.PageSetup.RightMargin := 30;
Sheet.PageSetup.TopMargin := 30;
Sheet.PageSetup.BottomMargin := 50;
Sheet.PageSetup.PrintQuality := 400; //分辨率
Sheet.PageSetup.CenterHorizontally := True;//是否水平居中
Sheet.PageSetup.CenterVertically := True; //是否垂直居中
Sheet.PageSetup.Orientation := 2; //横向打印
Sheet.PageSetup.Draft := False; //非草稿模式
Sheet.PageSetup.FirstPageNumber := xlAutomatic;
Sheet.PageSetup.BlackAndWhite := True; //黑白稿
Sheet.PageSetup.Zoom := 100; //缩放
sheet.PrintPreView; //打印预览
end;
也是从网上COPY的,但是感觉还是不错的.
好了,到这,我已经介绍了大部分常用的控制方法,试试吧。提醒你,你的机子装了Excel没有……