📄 uiwflexcel.pas
字号:
unit UIwFlexCel;
interface
uses
Classes, SysUtils, IWAppForm, IWApplication, IWTypes, Controls,
IWBaseControl, IWControl, IWCompButton, UExcelAdapter, XLSAdapter,
UCustomFlexCelReport, UFlexCelReport, DB, DBTables, IWCompText, IWGrids,
IWDBGrids, IWCompLabel, IWCompEdit, UFlexCelImport, UFlxNumberFormat;
type
TIWForm1 = class(TIWAppForm)
Report: TFlexCelReport;
XLSAdapter: TXLSAdapter;
IWButton1: TIWButton;
Cust: TTable;
IWButton2: TIWButton;
IWLabel2: TIWLabel;
IWText1: TIWText;
DataSource1: TDataSource;
IWButton3: TIWButton;
IWFile1: TIWFile;
FlexCelImport: TFlexCelImport;
IWLabel1: TIWLabel;
procedure IWButton1Click(Sender: TObject);
procedure IWButton2Click(Sender: TObject);
procedure IWButton3Click(Sender: TObject);
public
end;
implementation
{$R *.dfm}
uses
ServerController;
//Note that on linux we can't save to streams.
//The only way there is save the report to a temporary file, and then use
//WebApplication.SendFile instead of WebApplication.SendStream
procedure TIWForm1.IWButton1Click(Sender: TObject);
var
MemStream: TMemoryStream;
begin
MemStream:=TMemoryStream.Create;
try
Report.SavetoStream(MemStream);
WebApplication.SendStream(MemStream,'application/vnd.ms-excel','report.xls');
MemStream:=nil; //If we actually sent the stream, WebApplication.SendStream will free it.
finally
FreeAndNil(MemStream);
end; //finally
end;
procedure TIWForm1.IWButton2Click(Sender: TObject);
var
MemStream: TMemoryStream;
begin
MemStream:=TMemoryStream.Create;
try
Report.SavetoStream(MemStream);
WebApplication.SendStream(MemStream,'','report.xls', true); //save as an attachment
MemStream:=nil; //If we actually sent the stream, WebApplication.SendStream will free it.
finally
FreeAndNil(MemStream);
end; //finally
end;
procedure TIWForm1.IWButton3Click(Sender: TObject);
var
MemStream: TMemoryStream;
Color: integer;
begin
MemStream:=TMemoryStream.Create;
try
IWFile1.SaveToStream(MemStream);
MemStream.Position:=0;
FlexCelImport.LoadFromStream(MemStream);
WebApplication.ShowMessage('Cell A1: "'+XlsFormatValue(FlexCelImport.CellValue[1,1],FlexCelImport.CellFormatDef[1, 1].Format,Color)+'"',
smAlert);
finally
FreeAndNil(MemStream);
end; //finally
end;
initialization
TIWForm1.SetAsMainForm
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -