-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.pas
84 lines (75 loc) · 2.41 KB
/
Main.pas
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
unit Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, cxGraphics,
cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack,
dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom,
dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
dxSkinXmas2008Blue, cxSSheet;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
tsSpreadSheet: TTabSheet;
tsXml: TTabSheet;
mXML: TMemo;
cxSpread: TcxSpreadSheetBook;
procedure PageControl1Change(Sender: TObject);
private
{ Private declarations }
public
procedure GenerateXML();
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses msxml;
procedure TForm1.GenerateXML;
var
Doc: IXMLDOMDocument;
DataElement: IXMLDOMElement;
I, J: Integer;
Cell: TcxSSCellObject;
//R: TRect;
S, AttrName: string;
Row: IXMLDOMElement;
begin
Doc := CoDOMDocument.Create;
Doc.preserveWhiteSpace := True;
DataElement := Doc.createElement('data');
Doc.documentElement := DataElement;
for J := 0 to cxSpread.ActiveSheet.RowCount - 1 do
begin
Row := Doc.createElement('row');
DataElement.appendChild(Row);
for I := 0 to cxSpread.ActiveSheet.ColumnCount - 1 do
begin
Cell := cxSpread.ActiveSheet.GetCellObject(I, J);
S := Cell.DisplayText;
//R := Rect(I, J, I, J);
//S := cxSpread.CellsNameByRef(cxSpread.ActivePage, R);
if S <> '' then
begin
AttrName := 'c' + IntToStr(I);
Row.setAttribute(AttrName, S);
end;
end;
end;
Doc.save('d:\my.xml');
mXML.Text := Doc.xml;
end;
procedure TForm1.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePageIndex = 1 then
GenerateXML();
end;
end.