冥界3大法王 发表于 2022-8-22 23:01

Delphi的GridEh控件导入CSV报错

unit Unit5;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
DBGridEhGrouping, ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh, EhLibVCL, GridsEh,
DBAxisGridsEh, DBGridEh, Vcl.StdCtrls;

type
TForm5 = class(TForm)
    DBGridEh1: TDBGridEh;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form5: TForm5;

implementation

{$R *.dfm}

uses
DBGridEhImpExp, ComObj, ActiveX, db;

procedure TForm5.Button1Click(Sender: TObject);
begin
try
    OpenDialog1.Filter := '*.csv|文本文件';
    OpenDialog1.FilterIndex := 1;
    if OpenDialog1.Execute then
    begin
      LoadDBGridEhFromImportFile(TDBGridEhImportAsText, DBGridEh1, OpenDialog1.FileName, True);
    end;
finally
    OpenDialog1.Free;
end;
end;

end.

yulinsoft 发表于 2022-8-23 03:01

homejun 发表于 2022-8-23 08:56

错误提示是什么?是不是字符编码的问题

冥界3大法王 发表于 2022-8-23 09:43

@homejun

本帖最后由 冥界3大法王 于 2022-8-23 09:44 编辑

homejun 发表于 2022-8-23 08:56
错误提示是什么?是不是字符编码的问题@homejun



unit Unit5;


interface


uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
DBGridEhGrouping, ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh, Vcl.StdCtrls,
EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh, DBGridEhImpExp;


type
TForm5 = class(TForm)
    DBGridEh1: TDBGridEh;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;


var
Form5: TForm5;


implementation


{$R *.dfm}


procedure TForm5.Button1Click(Sender: TObject);
begin
OpenDialog1.Filter := 'csv file|*.csv';
OpenDialog1.DefaultExt := 'csv';
if OpenDialog1.Execute then
    LoadDBGridEhFromImportFile(TDBGridEhImportAsUnicodeText, DBGridEh1, OpenDialog1.FileName, True);
end;


end.

sunsjw 发表于 2022-8-23 10:05

delphi版本是多少?

冥界3大法王 发表于 2022-8-23 10:32

sunsjw 发表于 2022-8-23 10:05
delphi版本是多少?@homejun
11   @sunsjw

sunsjw 发表于 2022-8-23 14:14

LoadDBGridEhFromImportFile 这个方法是你自己实现的?

冥界3大法王 发表于 2022-8-23 18:01

sunsjw 发表于 2022-8-23 14:14
LoadDBGridEhFromImportFile 这个方法是你自己实现的?

原生安了控件就有了。

skypaladin 发表于 2022-8-23 20:52

用Embarcadero Delphi感觉怎么样?

sunsjw 发表于 2022-8-24 09:06

把 你编译的程序打包上来看一下。包含你的csv文件. 把调试符号一起带上
页: [1]
查看完整版本: Delphi的GridEh控件导入CSV报错