F
fjharmer
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure dc_excel(DBG: TDbgrideh);<br>var<br> I: Integer;<br> ExcelApp: variant;<br> SourceDataSet: tdataset;<br>begin<br> SourceDataSet := Tdataset(DBG.DataSource.DataSet);<br> if (SourceDataSet.IsEmpty) or (not SourceDataSet.active) or<br> (DBG.VisibleColumns.Count = 0) then<br> begin<br> application.MessageBox(pchar('无法导出数据到Excel,可能是系统中未安装Excel。'), '导出错误', mb_ok + mb_iconstop);<br> Abort;<br> end;<br> //<br> for I := 1 to 100 do<br> begin<br> if not IsFileInUse(main.one_path + '/file' + Inttostr(I) + '.xls') then<br> begin<br> SaveDBGridEhToExportFile(TDBGridEhExportAsXLSTile, DBG, main.one_path +<br> '/file' +Inttostr(I) + '.xls', True);<br> ExcelApp := CreateOleObject('Excel.Application');<br> ExcelApp.visible := true;<br> ExcelApp.WorkBooks.Open(main.one_path + '/file' + Inttostr(I) + '.xls');<br> Exit;<br> end;<br> end;<br>end;