Home > Back-end >  Delphi export import XLS, WPS.
Delphi export import XLS, WPS.

Time:09-24

in the existing system can export and import XLS file type, now requires can export import for WPS document type, and I saw the WPS form XLS table format is the same, please master teach, I now is just at the time of export or import increase WPS type of option is ok? Part of the source code is as follows:


//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 other

In 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:

refer to the second floor m617105 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,

What you said is right, but now the salesman asked import and export must have the WPS,
What business department said, we are like dogs,, have to do,
They put the WPS machine, not necessarily to excel. I tried to import and export for code format. Et is can import the WPS, but now both support, mainly the following code
SDG. Filter:='EXCEL (*. XLS) | *. XLS';
SDG. FileName:='I EXCEL document. XLS';
Only excel, how the WPS also added??????

CodePudding user response:

reference 4 floor wozengcong response:
only export to excel format, use the WPS can still open,
import and export should have, they put the machine does not necessarily excel,,,, but will hold the WPS, so still have to write both in, just don't know how to add multiple type
SDG. Filter:='EXCEL (*. XLS) | *. XLS';
SDG. FileName:='I EXCEL document. XLS';
How does this change?

CodePudding user response:





reference nicol1980 reply: 3/f
WPS form remember can be saved for multiple formats, you have to do is save as compatible with excel, it is not necessary to consider other

In addition, I use ado connection, another new system machine to pack what drivers to use?



They installed WPS, EXCEL,, I can't call an business department nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related