bcb生成excel表并实现表格的设置数据的填写.doc_第1页
bcb生成excel表并实现表格的设置数据的填写.doc_第2页
bcb生成excel表并实现表格的设置数据的填写.doc_第3页
bcb生成excel表并实现表格的设置数据的填写.doc_第4页
bcb生成excel表并实现表格的设置数据的填写.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

/将数据导入excel表中201010 /保存数据到excel文件中 SaveDialog1-FileName =s_ReportName+EDt.FormatString(yyyymmdd); if(SaveDialog1-Execute() AnsiString filenamex=SaveDialog1-FileName+.xls; Variant Wb,Sh1; Wb=CreateOleObject(Excel.Sheet); int i=0; AnsiString cc; Sh1=Wb.OlePropertyGet(ActiveSheet); /设置1行1列单元格属性 /设置字号为18,粗体 Sh1.PG(Cells,1,1).PG(Font).PS(Size,18); Sh1.PG(Cells,1,1).PG(Font).PS(Bold,true); Sh1.PG(Cells,1,1).PG(Font).PS(Name,宋体); /设置行高 Sh1.PG(Rows,1).PS(RowHeight,1.155/0.035); / 1/0.035=1cm /合并单元格 Sh1.PG(Range, A1:K1 ).PR(Merge); /水平对齐 1:顶端对齐,2:居中, 3:底端对齐 Sh1.PG(Cells,1,1).PS(HorizontalAlignment,3); /垂直对齐 2:左端对齐,3:居中, 4:右端对齐 Sh1.PG(Cells,1,1).PS(VerticalAlignment,2); /设置2行1列单元格属性 /设置字号为18,粗体 Sh1.PG(Cells,2,1).PG(Font).PS(Size,16); Sh1.PG(Cells,2,1).PG(Font).PS(Bold,true); Sh1.PG(Cells,2,1).PG(Font).PS(Name,宋体); Sh1.PG(Rows,2).PS(RowHeight,1.155/0.035); / 1/0.035=1cm Sh1.PG(Range, A2:K2 ).PR(Merge); Sh1.PG(Cells,2,1).PS(HorizontalAlignment,3); Sh1.PG(Cells,2,1).PS(VerticalAlignment,2); /设置3行1列单元格属性 Sh1.PG(Cells,3,1).PG(Font).PS(Size,10); Sh1.PG(Cells,3,1).PG(Font).PS(Bold,true); Sh1.PG(Cells,3,1).PG(Font).PS(Name,宋体); Sh1.PG(Range, A3:H3).PR(Merge); /设置3行9列单元格属性 Sh1.PG(Cells,3,9).PG(Font).PS(Size,10); Sh1.PG(Cells,3,9).PG(Font).PS(Bold,true); Sh1.PG(Cells,3,9).PG(Font).PS(Name,宋体); Sh1.PG(Rows,3).PS(RowHeight,1/0.035); / 1/0.035=1cm /设置列宽 Sh1.PG(Columns,1).PS(ColumnWidth,5.2); Sh1.PG(Columns,2).PS(ColumnWidth,8); Sh1.PG(Columns,3).PS(ColumnWidth,8.4); Sh1.PG(Columns,4).PS(ColumnWidth,7.6); Sh1.PG(Columns,5).PS(ColumnWidth,7.2); Sh1.PG(Columns,6).PS(ColumnWidth,7.2); Sh1.PG(Columns,7).PS(ColumnWidth,7.2); Sh1.PG(Columns,8).PS(ColumnWidth,7.2); Sh1.PG(Columns,9).PS(ColumnWidth,7.2); Sh1.PG(Columns,10).PS(ColumnWidth,7.2); Sh1.PG(Columns,11).PS(ColumnWidth,6); /填写标题栏 Sh1.OlePropertyGet(Cells,1,1).OlePropertySet(Value,s_StationName); /填写报表名称 Sh1.OlePropertyGet(Cells,2,1).OlePropertySet(Value,s_ReportName); /填写日期栏 Sh1.OlePropertyGet(Cells,3,1).OlePropertySet(Value,报表日期:+s_ReportDate); Sh1.OlePropertyGet(Cells,3,9).OlePropertySet(Value,单位:RMB 元); /填写列名称 Sh1.PG(Cells,4,1).PG(Font).PS(Size,10); Sh1.PG(Cells,4,1).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,1).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,1).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,1).PS(VerticalAlignment,2); cc=序号; Sh1.OlePropertyGet(Cells,4,1).OlePropertySet(Value,cc); Sh1.PG(Cells,4,2).PG(Font).PS(Size,10); Sh1.PG(Cells,4,2).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,2).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,2).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,2).PS(VerticalAlignment,2); cc=车牌号码; Sh1.OlePropertyGet(Cells,4,2).OlePropertySet(Value,cc); Sh1.PG(Cells,4,3).PG(Font).PS(Size,10); Sh1.PG(Cells,4,3).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,3).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,3).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,3).PS(VerticalAlignment,2); cc=车队小号; Sh1.OlePropertyGet(Cells,4,3).OlePropertySet(Value,cc); Sh1.PG(Cells,4,4).PG(Font).PS(Size,10); Sh1.PG(Cells,4,4).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,4).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,4).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,4).PS(VerticalAlignment,2); cc=车主名称; Sh1.OlePropertyGet(Cells,4,4).OlePropertySet(Value,cc); Sh1.PG(Cells,4,5).PG(Font).PS(Size,10); Sh1.PG(Cells,4,5).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,5).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,5).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,5).PS(VerticalAlignment,2); cc=交费次数; Sh1.OlePropertyGet(Cells,4,5).OlePropertySet(Value,cc); Sh1.PG(Cells,4,6).PG(Font).PS(Size,10); Sh1.PG(Cells,4,6).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,6).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,6).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,6).PS(VerticalAlignment,2); cc=验票次数; Sh1.OlePropertyGet(Cells,4,6).OlePropertySet(Value,cc); Sh1.PG(Cells,4,7).PG(Font).PS(Size,10); Sh1.PG(Cells,4,7).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,7).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,7).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,7).PS(VerticalAlignment,4); cc=单次收费金额; Sh1.OlePropertyGet(Cells,4,7).OlePropertySet(Value,cc); Sh1.PG(Cells,4,8).PG(Font).PS(Size,10); Sh1.PG(Cells,4,8).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,8).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,8).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,8).PS(VerticalAlignment,4); cc=通过次数合计; Sh1.OlePropertyGet(Cells,4,8).OlePropertySet(Value,cc); Sh1.PG(Cells,4,9).PG(Font).PS(Size,10); Sh1.PG(Cells,4,9).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,9).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,9).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,9).PS(VerticalAlignment,4); cc=收费金额合计; Sh1.OlePropertyGet(Cells,4,9).OlePropertySet(Value,cc); Sh1.PG(Cells,4,10).PG(Font).PS(Size,10); Sh1.PG(Cells,4,10).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,10).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,10).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,10).PS(VerticalAlignment,4); cc=卡内余额; Sh1.OlePropertyGet(Cells,4,10).OlePropertySet(Value,cc); Sh1.PG(Cells,4,11).PG(Font).PS(Size,10); Sh1.PG(Cells,4,11).PG(Font).PS(Bold,true); Sh1.PG(Cells,4,11).PG(Font).PS(Name,宋体); Sh1.PG(Cells,4,11).PS(HorizontalAlignment,3); Sh1.PG(Cells,4,11).PS(VerticalAlignment,2); cc=备注; Sh1.OlePropertyGet(Cells,4,11).OlePropertySet(Value,cc); i=4; cardcnt=0; while (!DataModules-ADOQuery-Eof) i+; cardcnt+; /填写列内容 Sh1.PG(Cells,i,1).PG(Font).PS(Size,10); Sh1.PG(Cells,i,1).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,1).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,1).PS(VerticalAlignment,2); cc= IntToStr(cardcnt); Sh1.OlePropertyGet(Cells,i,1).OlePropertySet(Value,cc); Sh1.PG(Cells,i,2).PG(Font).PS(Size,10); Sh1.PG(Cells,i,2).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,2).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,2).PS(VerticalAlignment,2); cc= DataModules-ADOQuery-Fields-FieldByName(CPUVLPNumber)-AsString.Trim(); Sh1.OlePropertyGet(Cells,i,2).OlePropertySet(Value,cc); Sh1.PG(Cells,i,3).PG(Font).PS(Size,10); Sh1.PG(Cells,i,3).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,3).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,3).PS(VerticalAlignment,2); cc= DataModules-ADOQuery-Fields-FieldByName(CPUSVLPNumber)-AsString.Trim(); Sh1.OlePropertyGet(Cells,i,3).OlePropertySet(Value,cc); Sh1.PG(Cells,i,4).PG(Font).PS(Size,10); Sh1.PG(Cells,i,4).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,4).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,4).PS(VerticalAlignment,2); cc= DataModules-ADOQuery-Fields-FieldByName(CardOwnerName)-AsString.Trim(); Sh1.OlePropertyGet(Cells,i,4).OlePropertySet(Value,cc); Sh1.PG(Cells,i,5).PG(Font).PS(Size,10); Sh1.PG(Cells,i,5).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,5).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,5).PS(VerticalAlignment,2); TotalJFCnt+=DataModules-ADOQuery-Fields-FieldByName(AutoType)-AsInteger; cc= IntToStr(DataModules-ADOQuery-Fields-FieldByName(AutoType)-AsInteger); Sh1.OlePropertyGet(Cells,i,5).OlePropertySet(Value,cc); Sh1.PG(Cells,i,6).PG(Font).PS(Size,10); Sh1.PG(Cells,i,6).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,6).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,6).PS(VerticalAlignment,2); TotalYPCnt+=DataModules-ADOQuery-Fields-FieldByName(YapCount)-AsInteger; cc= IntToStr(DataModules-ADOQuery-Fields-FieldByName(YapCount)-AsInteger); Sh1.OlePropertyGet(Cells,i,6).OlePropertySet(Value,cc); Sh1.PG(Cells,i,7).PG(Font).PS(Size,10); Sh1.PG(Cells,i,7).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,7).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,7).PS(VerticalAlignment,4); cc= IntToStr(DataModules-ADOQuery-Fields-FieldByName(Price)-AsInteger); Sh1.OlePropertyGet(Cells,i,7).OlePropertySet(Value,cc); Sh1.PG(Cells,i,8).PG(Font).PS(Size,10); Sh1.PG(Cells,i,8).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,8).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,8).PS(VerticalAlignment,2); TotalTGCnt+=DataModules-ADOQuery-Fields-FieldByName(AutoType)-AsInteger+DataModules-ADOQuery-Fields-FieldByName(YapCount)-AsInteger; cc= IntToStr(DataModules-ADOQuery-Fields-FieldByName(AutoType)-AsInteger+DataModules-ADOQuery-Fields-FieldByName(YapCount)-AsInteger); Sh1.OlePropertyGet(Cells,i,8).OlePropertySet(Value,cc); Sh1.PG(Cells,i,9).PG(Font).PS(Size,10); Sh1.PG(Cells,i,9).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,9).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,9).PS(VerticalAlignment,2); TotalJFPrice+=DataModules-ADOQuery-Fields-FieldByName(AutoType)-AsInteger*DataModules-ADOQuery-Fields-FieldByName(Price)-AsInteger; cc= IntToStr(DataModules-ADOQuery-Fields-FieldByName(AutoType)-AsInteger*DataModules-ADOQuery-Fields-FieldByName(Price)-AsInteger); Sh1.OlePropertyGet(Cells,i,9).OlePropertySet(Value,cc); Sh1.PG(Cells,i,10).PG(Font).PS(Size,10); Sh1.PG(Cells,i,10).PG(Font).PS(Name,宋体); Sh1.PG(Cells,i,10).PS(HorizontalAlignment,3); Sh1.PG(Cells,i,10).PS(VerticalAlignment,2); cc= IntToStr(DataModules-ADOQuery-Fields-FieldByName(RestCost)-AsInteger); Sh1.OlePropertyGet(Cells,i,10).OlePropertySet(Value,cc); DataModules-ADOQuery-Next(); /交费次数合计 Sh1.PG(Cells,cardcnt+5,5).PG(Font).PS(Size,10); Sh1.PG(Cells,cardcnt+5,5).PG(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论