-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.cpp
More file actions
103 lines (93 loc) · 2.67 KB
/
Copy pathUnit1.cpp
File metadata and controls
103 lines (93 loc) · 2.67 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxClasses"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxDBData"
#pragma link "cxEdit"
#pragma link "cxFilter"
#pragma link "cxGraphics"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridDBTableView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxNavigator"
#pragma link "cxProgressBar"
#pragma link "cxStyles"
#pragma link "dxDateRanges"
#pragma link "dxmdaset"
#pragma link "dxScrollbarAnnotations"
#pragma link "cxExport"
#pragma link "cxGridExportLink"
#pragma link "dxSpreadSheet"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExportToXLSXClick(TObject *Sender)
{
TExportHandler* AExportHandler = new TExportHandler(this);
try
{
AExportHandler->Visible = false;
AExportHandler->Parent = this;
AExportHandler->ProgressBar = cxProgressBar1;
ExportGridToXLSX("test.xlsx", cxGrid1, True, True, True,
"xlsx", AExportHandler);
}
__finally
{
delete AExportHandler;
}
}
//---------------------------------------------------------------------------
void __fastcall TExportHandler::OnBeforeSave(TdxSpreadSheet* Sender)
{
TdxSpreadSheetTableView* AView;
AView = Sender->ActiveSheetAsTable;
AView->InsertRows(0, 1);
AView->CreateCell(0, 0)->AsString = "Countries";
}
void __fastcall TExportHandler::OnProgress(System::TObject* Sender, int Percent)
{
if(FProgressBar != nullptr)
{
FProgressBar->Position = Percent;
Sleep(10);
Application->ProcessMessages();
}
}
HRESULT __stdcall TExportHandler::QueryInterface(const GUID& IID, void **Obj)
{
return GetInterface(IID, Obj) ? S_OK : E_NOINTERFACE;
}
ULONG __stdcall TExportHandler::AddRef(void)
{
InterlockedIncrement(&m_cRef);
return (ULONG)m_cRef;
};
ULONG __stdcall TExportHandler::Release(void)
{
ULONG ulRefCount = InterlockedDecrement(&m_cRef);
return ulRefCount;
};
inline __fastcall TExportHandler::TExportHandler(TComponent* AOwner): TdxSpreadSheet(AOwner)
{
}
//---------------------------------------------------------------------------