//get the EXCEL file filename and path,
The function TDbConnXLS. GetXLSFileName: String;
Var
OpenXLS: TOpenDialog;
The begin
Result:=';
OpenXLS:=TOpenDialog. Create (nil);
OpenXLS. Filter:='EXCEL (*. XLS) | *. XLS';
If openXLS. Execute then
Result:=openXLS. FileName;
//else Cap_error (' file open failed! ');
end;
//initialize
The Function TDbConnXLS. Init (cap_ShowHand: Tcap_ShowHandle) : Boolean;
Var
Resval: Rblstr;
The begin
Result:=false;
FileName:=getXLSFileName;
If fileName="' then the exit;
If the copy (fileName, length (fileName) - 2, length (fileName)) & lt;> 'like' then
The begin
Cap_ShowHand. Cap_error (' you the selected file is not.xls files, please choose again! ');
The exit;
end;
Resval:=cap_ShowHand Cap_Inbox (' open the table ', 'please enter the table name in the EXCEL file:', 'Sheet1);
If resval. Bool=false then the exit;
TableName:=resval. Restr;
If tableName="' then
The begin
Cap_ShowHand. Cap_error (' table name cannot be empty! Please enter the name of the table! ');
The exit;
end;
Connstr:=';
Connstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; ';
Connstr:=connstr + + fileName 'Data Source=' + '; ';
Connstr:=connstr + 'Extended Properties=8.0 Excel; ';
Connstr:=connstr + 'Persist Security Info=False; ';
AdoConn:=TADOConnection. Create (nil);
AdoConn. The ConnectionString:=connstr;
AdoConn. LoginPrompt:=false;
AdoQuery:=TADOQUery. Create (nil);
AdoQuery. Connection:=adoConn;
Result:=true;
end;
//title in the Excel table column name
//to save the contents of a listView to Excel in the
The function TDbConnXLS. SavetoExcel (title: WideString; Lv: TListView; Cap_ShowHand: Tcap_ShowHandle) : Boolean;
Var
I: integer;
SDG: TSaveDialog;
Issave: Boolean;
Titlelist, templist: Tstrings;
The begin
SDG:=TSaveDialog. Create (nil);
Templist:=Tstringlist. Create;
Titlelist:=Tstringlist. Create;
Try
If lv. The Items. The Count=0 then
The begin
Cap_ShowHand. Cap_error (' current no data! ');
The exit;
end;
If the title="' then//is empty export all columns
For I:=0 to lv. Columns. Do the Count - 1//collect the EXCEL table column name
Titlelist. Add (lv. The Columns [I] Caption)
Else//no is empty, the export only the specified column
Titlelist.Com maText:=title;
SDG. Filter:='EXCEL (*. XLS) | *. XLS';
SDG. FileName:='I EXCEL document. XLS';
If SDG. Execute=true then
The begin
IsSave:=true;
If FileExists (SDG) FileName) then
Issave:=cap_ShowHand Cap_warn (' file already exists, whether to replace! ');
End
The else exit;
If issave then
The begin
Templist:=(getListViewValue (titlelist, lv));
Templist. SaveToFile (SDG) FileName);
Cap_ShowHand. Cap_succeed (' export success! ');
End
The else exit;
The finally
Templist. Free;
end;
end;
Haven't put through, etc. Will return to refine, try to ask, I just need to open or save to increase the WPS type? And how to increase? And there's a link above.xls files link onnstr:=' ';
Connstr:='. The Provider=Microsoft Jet. The OLEDB. 4.0; ';
Connstr:=connstr + + fileName 'Data Source=' + '; ';
Connstr:=connstr + 'Extended Properties=8.0 Excel; ';
Connstr:=connstr + 'Persist Security Info=False; ';
This thing, if I link for WPS types of how do I change,,,,,!!!!!! Urgent urgent,,,,,,,
CodePudding user response:
No one will be?CodePudding user response:
WPS itself is compatible with excel, so there's no need for WPS do,Export to excel format, only use the WPS can still open,
CodePudding user response:
WPS form, remember to save for multiple formats, you have to do is save as compatible with excel, no need to go to consider otherIn addition, I use ado connection, another new system machine to pack what drivers to use?
CodePudding user response:
Export to excel format, only use the WPS can still open,CodePudding user response: