请大家多帮忙~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
多谢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
一定有分送到的~~~~

解决方案 »

  1.   

    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没有……