Home > Back-end >  Delphi to Excel after sorting, background unable to exit Excel. The exe process!
Delphi to Excel after sorting, background unable to exit Excel. The exe process!

Time:09-19

If inscribe
The code is as follows:
Var
Excelapp: Variant;
I, temp: integer;
Key1: oleVariant;
STR: string;
The begin
ExcelApp:=CreateOleObject (' Excel. Application);
ExcelApp. WorkBooks. Open (' c: \ 1. XLS);
ExcelApp. Visible:=true;
ExcelApp. DisplayAlerts:=false;
ExcelApp. Worksheets [1]. Activate;
Temp:=0;
For I:=1 to 200 do
The begin
STR:=ExcelApp. Cells [I, 1);
If str<> "' then
Temp:=temp + 1;
end;
ExcelApp. Range [' a2: X14]. Select;
ExcelApp. Selection. Sort (Key1:=ExcelApp range [' h1 ']);
ExcelApp. ActiveWorkbook. Save;
ExcelApp. Quit;
end;





CodePudding user response:

Direct operation EXCEL file, file to be saved, to quit, even when saved "confirm",
, it is best to read EXCEL data, in the sorting, then write EEXCEL,
If is to generate a new EXCEL file, there will not be your problem,

CodePudding user response:

It is recommended to use third party controls, a quick two convenient three take up less memory,

CodePudding user response:

Excelapp:=the Unassigned; Have a try?

CodePudding user response:

1. ActiveWorkbook. Save
2. ActiveWorkbook. Close;
3. ExcelApp. Quit;
4. ExcelApp:=the Unassigned;

CodePudding user response:

Thank you for your attention! I try first! In the process of debugging the ExcelApp. Selection. Sort (Key1:=ExcelApp range [' h1 ']); This block can be quit!!!!!!
It is confusing!!!!!

CodePudding user response:

reference 5 floor zhou_yang12 reply:
thank you! I try first! In the process of debugging the ExcelApp. Selection. Sort (Key1:=ExcelApp range [' h1 ']); This block can be quit!!!!!!
It is confusing!!!!!

In the execution of that sort in, usually is sorting through,

CodePudding user response:

Sorting can be! No problem! The key is the range of parameters problem! If previous programming with range [a1, b2] will appear can't quit! With range [a1, b2] can quit!!

CodePudding user response:

The Range parameter:
The tail end of the range specified a full table, or table
Designated area range [A1: C20]

the location on the range [A1]

CodePudding user response:

The visible set to FALSE

CodePudding user response:

Normal operation, I usually will EXCEL import CLIENTDATASET to operate

CodePudding user response:

The excelApp. Don't quit close excel. Exe, I also met before, haven't find a solution, go away,

CodePudding user response:

The name, broken up into two sentences. Try ExcelApp selection. The Sort (Key1:=ExcelApp range [' h1 ']);
Key1:=ExcelApp. Range [' h1 ']);
ExcelApp. Selection. Sort (Key1);
  • Related