티스토리 뷰
NOTE
http://www.tmssoftware.biz/flexcel/doc/vcl/samples/firemonkey-desktop/gettingstarted/index.html
Getting started (FireMonkey Desktop) | FlexCel Studio for VCL and FireMonkey documentation
Getting started (FireMonkey Desktop) Overview How to create a file in FireMonkey. Concepts Shown: This demo is similar to the VCL demo of the same name. We won't be repeating every demo for FireMonkey, so you should also take a look at the VCL demos. Only
www.tmssoftware.biz
이 데모는 FlexCel 설치시 <FlexCel Install Folder>\Demo\FireMonkey Desktop\Modules\10.GettingStarted and also at https://github.com/tmssoftware/TMS-FlexCel.VCL-demos/tree/master/FireMonkey Desktop/Modules/10.GettingStarted 에 있습니다.
Overview
How to create a file in FireMonkey.
Concepts Shown:
이 데모는 같은 이름의 VCL 데모와 비슷합니다 .FireMonkey에 대한 모든 데모를 반복하지는 않으므로 VCL 데모도 살펴보십시오 Firefire에서 다른 항목 만 FM 데모에 포함됩니다.
Files
UGettingStarted.pas
unit UGettingStarted;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.StdCtrls, FMX.Controls, FMX.Forms, FMX.Dialogs,
{$if CompilerVersion >= 31} //Delphi 10.1 Berlin deprecated MessageDlg
FMX.DialogService.Sync,
{$endif}
FMX.FlexCel.Core, FlexCel.XlsAdapter, FMX.FlexCel.DocExport,
FMX.Controls.Presentation;
type
TFGettingStarted = class(TForm)
BtnCreateFile: TButton;
SaveDialog: TSaveDialog;
DocExport: TFlexCelDocExport;
procedure btnCreateFileClick(Sender: TObject);
private
procedure AddData(const Xls: TExcelFile);
procedure CreateFile;
procedure ShowOpenDialog(const Xls: TExcelFile);
{ Private declarations }
public
{ Public declarations }
end;
var
FGettingStarted: TFGettingStarted;
implementation
{$R *.fmx}
procedure TFGettingStarted.CreateFile;
var
Xls: TExcelFile;
begin
Xls := TXlsFile.Create(true);
try
AddData(Xls);
ShowOpenDialog(Xls);
finally
FreeAndNil(Xls);
end;
end;
procedure TFGettingStarted.AddData(const Xls: TExcelFile);
var
Img: TResourceStream;
fmt: TFlxFormat;
XF, XF2: integer;
begin
//Create a new file. We could also open an existing file with Xls.Open
Xls.NewFile(1, TExcelFileFormat.v2019);
//Set some cell values.
Xls.SetCellValue(1, 1, 'Hello to the world');
Xls.SetCellValue(2, 1, 3);
Xls.SetCellValue(3, 1, 2.1);
Xls.SetCellValue(4, 1, TFormula.Create('=Sum(A2, A3)')); //Note that formulas always are in English. This means use "," to separate arguments, not ";".
//Add a new image on cell F2
Img := TResourceStream.Create(hinstance, 'FlexCelLogo', RT_RCDATA);
try
Xls.AddImage(Img,
TImageProperties_Create(
TClientAnchor.Create(TFlxAnchorType.MoveAndResize, 2, 0, 6, 0, 4, 0, 8, 0),
'', 'My image'));
finally
Img.Free;
end;
//Add a comment on cell a2
Xls.SetComment(2, 1, 'This is a comment');
//Custom Format cells a2 and a3
fmt := Xls.GetDefaultFormat; //Always initialize the record with an existing format.
fmt.Font.Name := 'Times New Roman';
fmt.Font.Color := TColorRec.Red;
fmt.FillPattern.Pattern := TFlxPatternStyle.LightDown;
fmt.FillPattern.FgColor := TColorRec.Blue;
fmt.FillPattern.BgColor := TColorRec.White;
//You can call AddFormat as many times as you want, it will never add a format twice.
//But if you know the format you are going to use, you can get some extra CPU cycles by
//calling addformat once and saving the result into a variable.
XF := Xls.AddFormat(fmt);
Xls.SetCellFormat(2, 1, XF);
Xls.SetCellFormat(3, 1, XF);
fmt.Rotation := 45;
fmt.Font.Size20 := 400;
fmt.FillPattern.Pattern := TFlxPatternStyle.Solid;
XF2 := Xls.AddFormat(fmt);
//Apply a custom format to all the row.
Xls.SetRowFormat(1, XF2);
//Merge cells
Xls.MergeCells(5, 1, 10, 6);
//Note how this one merges with the previous range, creating a final range (5,1,15,6)
Xls.MergeCells(10, 6, 15, 6);
//Make the page print in landscape or portrait mode
Xls.PrintLandscape := true;
end;
procedure TFGettingStarted.btnCreateFileClick(Sender: TObject);
begin
CreateFile;
end;
procedure TFGettingStarted.ShowOpenDialog(const Xls: TExcelFile);
begin
if not SaveDialog.Execute then exit;
Xls.Save(SaveDialog.FileName); //No need to delete the file first, since AllowOverWriteFiles is true in XlsAdapter.
{$if CompilerVersion >= 31} //Delphi 10.1 Berlin deprecated MessageDlg
if TDialogServiceSync.MessageDialog('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0) = mrYes then
begin
DocExport.ExportFile(nil, SaveDialog.FileName);
end;
{$else}
if MessageDlg('Do you want to open the generated file?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
begin
DocExport.ExportFile(nil, SaveDialog.FileName);
end;
{$endif}
end;
end.
'WORK' 카테고리의 다른 글
(2020-05-13) Custom previewing (FireMonkey Desktop) (0) | 2020.05.13 |
---|---|
(2020-05-13) Reading excel files (by FireMonkey on Desktop & Mobile) (0) | 2020.05.13 |
(2020-05-13) Reports (FireMonkey Mobile) (0) | 2020.05.13 |
(2020-05-12) FlexCel ReportsDesigners Guide (0) | 2020.05.12 |
(2020-05-12) FlexCel.Report 예제 (0) | 2020.05.12 |
- Total
- Today
- Yesterday
- solomonsystem
- READ_PRIVILEGED_PHONE_STATE
- Android 64
- FMX
- 키오스크
- 비에이블스터디카페
- WidevineID
- 앱관리자
- push server
- SOLO1ASP
- Grijjy
- 스터디카페
- Firemonkey
- 솔로원DB복제
- mysql db 복구
- 솔로몬시스템
- KSNetPOSLib.ocx
- DelphiZeroMQ
- 안드로이드관리자
- 식권발매
- delphi push message
- .dproj
- Delphi
- Could not convert variant of type (Null) into type (OleStr)
- RADStudio11
- KSNetPOSLib
- 비에이블
- TT쿼리
- Unable to load project
- 안드로이드_관리자
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |