Import: First use Tunifileupload to upload the file from the client to the server, and then complete the import.
Tunifileupload Demo code for uploading files:
Unifileupload1.execute;
UniFileUpload1.ScreenMask.Target: = self;
UniFileUpload1.ScreenMask.Enabled: = True;
Use Tqimport3xls to import the demo code to upload a file:
Map the relationship between a dataset field and an Excel column:
QImport3XLS1.Map.Clear;
QIMPORT3XLS1.MAP.ADD (' empid=a2-colfinish ');
QIMPORT3XLS1.MAP.ADD (' empname=b2-colfinish ');
To perform an import:
Procedure tfrmemployee.unifileupload1completed (Sender:tobject;
Astream:tfilestream);
Begin
inherited;
Qimport3xls1.filename: = Unifileupload1.filename;
Qimport3xls1.execute;
End
Export: First export the data to a file, then download the file from the server to the client, and then open the file on the client.
Demo code to export data using Tqexport4xls:
Procedure Tfrmemployee.btnexportclick (Sender:tobject);
Var
f:string;
Begin
inherited;
F: = ' staff file. xls ';
Qexport4xls1.filename: = f;
Try
Qexport4xls1.execute;
Except
Qexport4xls1.execute;
End
MainForm.uniApplication.UniSession.SendFile (F, f);
End
Unigui Import and Export data