function funDR():boolean;
var
iRow,iCol,iSheet:integer;
SoursceExcel:OleVariant;
DRCfgInfo:TDRCfgInfo;
begin
with frmShJDR do
begin
if DRCfgInfo.fieldname='' then DRCfgInfo.fieldname:='项目';
ShJDR_SourceData_TEMPtb:=TTable.Create(frmShJDR);
if opendialog1.Execute then
begin
DRCfgInfo.filename:=opendialog1.FileName;
SoursceExcel:=CreateOleObject('Excel.application');
SoursceExcel.visible:=false;
SoursceExcel.WorkBooks.Open(DRCfgInfo.filename);
DRCfgInfo.WordsheetsCount:=SoursceExcel.Worksheets.count;
for iSheet:=1 to DRCfgInfo.WordsheetsCount do
begin
DRCfgInfo.RowsCount:=SoursceExcel.Worksheets[iSheet].UsedRange.Rows.Count;
DRCfgInfo.ColsCount:=SoursceExcel.Worksheets[iSheet].UsedRange.Columns.Count;
PrgBar^.Max:=DRCfgInfo.RowsCount;
PrgBar^.Min:=0;
PrgBar^.Step:=1;
PrgBar^.Position:=0;
ShJDR_SourceData_TEMPtb.DatabaseName:=ConfigInfo.dbName;
with ShJDR_SourceData_TEMPtb do
begin
if Active then Close;
TableName:='ShJDR_SourceData_TEMPtb';
//取消动态创建数据库
if Exists then DeleteTable;
with FieldDefs do
begin
Clear;
with AddFieldDef do begin
Name := 'id';
DataType := ftString;
Size := 5;
Required := false;
end;//with AddFieldDef do begin
for iCol:=1 to DRCfgInfo.ColsCount do
begin
with AddFieldDef do begin
Name :=DRCfgInfo.fieldname+IntToStr(iCol);
DataType := ftString;
Size := 15;
Required := false;
end;//with AddFieldDef do begin
// Add('logoic',ftString,25,false);
end;//for iCol:=1 to DRCfgInfo.ColsCount do
end;//with FieldDefs do
{为计算完成率临时表}
CreateTable;
AutoRefresh:=false;
IndexFieldNames:='id';
ReadOnly:=false;
Active:=true;
end;
for iRow:=1 to DRCfgInfo.RowsCount do
begin
ShJDR_SourceData_TEMPtb.Insert;
ShJDR_SourceData_TEMPtb.FieldByName('id').AsString:=IntToStr(iRow);
for iCol:=1 to DRCfgInfo.ColsCount do
begin
ShJDR_SourceData_TEMPtb.FieldByName(DRCfgInfo.fieldname+IntToStr(iCol)).AsString:=
SoursceExcel.Worksheets[iSheet].UsedRange.Cells[iRow,iCol].text;
end;//for iCol:=1 to DRCfgInfo.ColsCount do
ShJDR_SourceData_TEMPtb.Post;
PrgBar^.StepIt;
end;//for iRow:=1 to DRCfgInfo.RowsCount do
end;//for iSheet:=1 to DRCfgInfo.WordsheetsCount do
//关闭并退出execel对象.
SoursceExcel.ActiveWorkBook.Close;
SoursceExcel.Quit;
SoursceExcel.visible:=true;
SoursceExcel:=Unassigned;
end;// if opendialog1.Execute then
ShJDR_SourceData_TEMPtb_DataSource.DataSet:=ShJDR_SourceData_TEMPtb;
result:=false;
end;
end;