zoukankan      html  css  js  c++  java
  • DBGridEh导出EXCEL2

    procedure TFrmdbGridEh.ToolButton2Click(Sender: TObject);

    var
      ExpClass:TDBGridEhExportClass;
      Ext:String;
      lssavedialog: tsavedialog;

    begin

    try
         lssavedialog := tsavedialog.Create(nil);
         lssavedialog.Filter := '*.xls|*.xls|*.csv|*.csv|*.htm|*.htm|*.rtf|*.rtf|*.txt|*.txt';
         lssavedialog.FileName := 'file1';
         if lssavedialog.Execute then
         begin
           case lssavedialog.FilterIndex of
             1: begin ExpClass := TDBGridEhExportAsText; Ext := 'xls'; end;
             2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
             3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
             4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
             5: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'txt'; end;
           else
             ExpClass := nil; Ext := '';
           end;
           if ExpClass <> nil then
           begin
             if UpperCase(Copy(lssavedialog.FileName, Length(lssavedialog.FileName) - 2, 3)) <> UpperCase(Ext) then
               lssavedialog.FileName := lssavedialog.FileName + '.' + Ext;
             if FileExists(lssavedialog.FileName) then
             begin
               if application.MessageBox('文件名已存在,是否覆盖', '提示', MB_ICONASTERISK or MB_OKCANCEL) <> idok then
               begin
                 exit;
               end;
             end;
             Screen.Cursor := crHourGlass;
             try
             SaveDBGridEhToExportFile(ExpClass, DBGridEh1, lssavedialog.FileName, true);
             except
               ShowMessage('NO');
             end;
             Screen.Cursor := crDefault;
           end;
         end;
       finally
         lssavedialog.Free;
       end;

    end;

  • 相关阅读:
    计算机组成原理实验总结
    Matlab图像匹配问题
    局域网实验
    信号量与共享存储区(操作系统实验三)
    路由器配置及IP设置及ping命令使用
    自我介绍是一门学问
    数据库管理系统的维护与管理
    高数讲课教后感
    node Unexpected token import(node 目前默认不支持es6 的模块 import解决方法有2)
    Cookie/Session机制详解
  • 原文地址:https://www.cnblogs.com/mingdep/p/2565845.html
Copyright © 2011-2022 走看看