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. Save2. 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: