├── .gitattributes
├── .gitignore
├── README.md
├── demo
├── .build
│ ├── default.Manifest.xml
│ ├── default.init.aardio
│ └── default.main.aardio
├── Publish
│ ├── script
│ │ ├── autofilter_byvalue.aardio
│ │ ├── autofilter_strcustom.aardio
│ │ ├── autofilter_topN.aardio
│ │ ├── logo.png
│ │ ├── mergecells.aardio
│ │ ├── receipt.aardio
│ │ ├── usedrange.aardio
│ │ ├── writedatatime.aardio
│ │ └── writeformulas.aardio
│ ├── test.aardio
│ ├── txt2xlsx.aardio
│ └── 返点.aardio
├── default.aproj
├── lib
│ ├── config.aardio
│ └── libxl
│ │ ├── _.aardio
│ │ ├── autofilter.aardio
│ │ ├── book.aardio
│ │ ├── filtercolumn.aardio
│ │ ├── font.aardio
│ │ ├── format.aardio
│ │ └── sheet.aardio
├── main.aardio
└── script
│ ├── autofilter_byvalue.aardio
│ ├── autofilter_strcustom.aardio
│ ├── autofilter_topN.aardio
│ ├── logo.png
│ ├── mergecells.aardio
│ ├── receipt.aardio
│ ├── usedrange.aardio
│ ├── writedatatime.aardio
│ └── writeformulas.aardio
└── libxl
├── _.aardio
├── autofilter.aardio
├── book.aardio
├── filtercolumn.aardio
├── font.aardio
├── format.aardio
└── sheet.aardio
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows thumbnail cache files
2 | Thumbs.db
3 | ehthumbs.db
4 | ehthumbs_vista.db
5 |
6 | # Folder config file
7 | Desktop.ini
8 |
9 | # Recycle Bin used on file shares
10 | $RECYCLE.BIN/
11 |
12 | # Windows Installer files
13 | *.cab
14 | *.msi
15 | *.msm
16 | *.msp
17 |
18 | # Windows shortcuts
19 | *.lnk
20 |
21 | # =========================
22 | # Operating System Files
23 | # =========================
24 | demo/res/libxl.dll
25 | demo/export/receipt.xlsx
26 | demo/export/formula.xlsx
27 | demo/export/datetime.xlsx
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # libxl
2 | 本库基于 LibXL 3.8.0 版本,支持在未安装 Office 的电脑上读写 xls、xlsx 文件。
3 |
4 | 需要KEY的请QQ联系我
5 |
6 | 欢迎有能力的人重写本库。
7 |
8 | 感谢 libxl 编写的 dll,项目地址:http://www.libxl.com/
9 |
--------------------------------------------------------------------------------
/demo/.build/default.Manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 | libxl_examp
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
52 |
53 |
54 |
55 |
56 |
57 | True/PM
58 |
59 |
60 |
--------------------------------------------------------------------------------
/demo/.build/default.init.aardio:
--------------------------------------------------------------------------------
1 | //发布前触发
2 | import ide;
--------------------------------------------------------------------------------
/demo/.build/default.main.aardio:
--------------------------------------------------------------------------------
1 | //此触发器在生成EXE以后执行
2 | import ide;
3 | import fsys;
4 |
5 | //获取生成的EXE文件路径
6 | var publishFile = ide.getPublishPath();
--------------------------------------------------------------------------------
/demo/Publish/script/autofilter_byvalue.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var autofilter_byValue = function(){
5 | io.open()
6 |
7 | var start = time.tick()
8 |
9 | var file = "export/autofilter_byValue.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var xlSheet = xlExcel.addSheet("my");
13 |
14 | if xlSheet{
15 |
16 | xlSheet.Cell(3,2).value = "Country";
17 | xlSheet.Cell(3,3).value = "Road injures";
18 | xlSheet.Cell(3,4).value = "Smoking";
19 | xlSheet.Cell(3,5).value = "Suicide";
20 |
21 | xlSheet.Cell(4, 2).value ="USA"; xlSheet.Cell(5, 2).value ="UK";
22 | xlSheet.Cell(4, 3).value = 64; xlSheet.Cell(5, 3).value =94;
23 | xlSheet.Cell(4, 4).value = 69; xlSheet.Cell(5, 4).value =55;
24 | xlSheet.Cell(4, 5).value = 49; xlSheet.Cell(5, 5).value = 64;
25 |
26 | xlSheet.Cell(6, 2).value ="Germany"; xlSheet.Cell(7, 2).value ="Switzerland";
27 | xlSheet.Cell(6, 3).value =88; xlSheet.Cell(7, 3).value = 93;
28 | xlSheet.Cell(6, 4).value =46; xlSheet.Cell(7, 4).value = 54;
29 | xlSheet.Cell(6, 5).value =55; xlSheet.Cell(7, 5).value = 50;
30 |
31 | xlSheet.Cell(8, 2).value ="Spain"; xlSheet.Cell(9, 2).value ="Italy";
32 | xlSheet.Cell(8, 3).value = 86; xlSheet.Cell(9, 3).value = 75;
33 | xlSheet.Cell(8, 4).value = 47; xlSheet.Cell(9, 4).value = 52;
34 | xlSheet.Cell(8, 5).value = 69; xlSheet.Cell(9, 5).value = 71;
35 |
36 | xlSheet.Cell(10, 2).value ="Greece"; xlSheet.Cell(11, 2).value ="Japan";
37 | xlSheet.Cell(10, 3).value =67; xlSheet.Cell(11, 3).value =91;
38 | xlSheet.Cell(10, 4).value =23; xlSheet.Cell(11, 4).value =57;
39 | xlSheet.Cell(10, 5).value =87; xlSheet.Cell(11, 5).value =36;
40 |
41 | var xlAutoFilter = xlSheet.autoFilter();
42 | xlAutoFilter.setRef("B3E11");
43 |
44 | var xlFilterColumn = xlAutoFilter.getColumn(1);
45 | xlFilterColumn.filterText = "Japan"
46 | xlFilterColumn.filterText = "USA"
47 | xlFilterColumn.filterText = "Switzerland"
48 |
49 | xlSheet.applyFilter();
50 |
51 | io.print(xlExcel.Save(file))
52 | io.print(xlExcel.getErrMsg())
53 |
54 | xlExcel.Close()
55 |
56 | io.print("use " + (time.tick() - start + " ms"));
57 | }
58 |
59 | };
60 |
61 | autofilter_byValue()
62 |
63 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/autofilter_strcustom.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var autofilter_strcustom = function(){
5 | io.open()
6 |
7 | var start = time.tick()
8 |
9 | var file = "export/autofilter_strcustom.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var xlSheet = xlExcel.addSheet("my");
13 |
14 | if xlSheet{
15 |
16 | xlSheet.Cell(3,2).value = "Country";
17 | xlSheet.Cell(3,3).value = "Road injures";
18 | xlSheet.Cell(3,4).value = "Smoking";
19 | xlSheet.Cell(3,5).value = "Suicide";
20 |
21 | xlSheet.Cell(4, 2).value ="USA"; xlSheet.Cell(5, 2).value ="UK";
22 | xlSheet.Cell(4, 3).value = 64; xlSheet.Cell(5, 3).value =94;
23 | xlSheet.Cell(4, 4).value = 69; xlSheet.Cell(5, 4).value =55;
24 | xlSheet.Cell(4, 5).value = 49; xlSheet.Cell(5, 5).value = 64;
25 |
26 | xlSheet.Cell(6, 2).value ="Germany"; xlSheet.Cell(7, 2).value ="Switzerland";
27 | xlSheet.Cell(6, 3).value =88; xlSheet.Cell(7, 3).value = 93;
28 | xlSheet.Cell(6, 4).value =46; xlSheet.Cell(7, 4).value = 54;
29 | xlSheet.Cell(6, 5).value =55; xlSheet.Cell(7, 5).value = 50;
30 |
31 | xlSheet.Cell(8, 2).value ="Spain"; xlSheet.Cell(9, 2).value ="Italy";
32 | xlSheet.Cell(8, 3).value = 86; xlSheet.Cell(9, 3).value = 75;
33 | xlSheet.Cell(8, 4).value = 47; xlSheet.Cell(9, 4).value = 52;
34 | xlSheet.Cell(8, 5).value = 69; xlSheet.Cell(9, 5).value = 71;
35 |
36 | xlSheet.Cell(10, 2).value ="Greece"; xlSheet.Cell(11, 2).value ="Japan";
37 | xlSheet.Cell(10, 3).value =67; xlSheet.Cell(11, 3).value =91;
38 | xlSheet.Cell(10, 4).value =23; xlSheet.Cell(11, 4).value =57;
39 | xlSheet.Cell(10, 5).value =87; xlSheet.Cell(11, 5).value =36;
40 |
41 | var xlAutoFilter = xlSheet.autoFilter();
42 | xlAutoFilter.setRef("B3E11");
43 |
44 | var xlFilterColumn = xlAutoFilter.getColumn(1);
45 | xlFilterColumn.setCustomFilter(0/*_OPERATOR_EQUAL*/,"G*")
46 |
47 | xlSheet.applyFilter();
48 |
49 | io.print(xlExcel.Save(file))
50 | io.print(xlExcel.getErrMsg())
51 | xlExcel.Close()
52 |
53 | io.print("use " + (time.tick() - start + " ms"));
54 | }
55 |
56 | };
57 |
58 | autofilter_strcustom()
59 |
60 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/autofilter_topN.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var autofilter_topN = function(){
5 | io.open()
6 |
7 | var start = time.tick()
8 |
9 | var file = "export/autofilter_topN.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var xlSheet = xlExcel.addSheet("my");
13 |
14 | if xlSheet{
15 |
16 | xlSheet.Cell(3,2).value = "Country";
17 | xlSheet.Cell(3,3).value = "Road injures";
18 | xlSheet.Cell(3,4).value = "Smoking";
19 | xlSheet.Cell(3,5).value = "Suicide";
20 |
21 | xlSheet.Cell(4, 2).value ="USA"; xlSheet.Cell(5, 2).value ="UK";
22 | xlSheet.Cell(4, 3).value = 64; xlSheet.Cell(5, 3).value =94;
23 | xlSheet.Cell(4, 4).value = 69; xlSheet.Cell(5, 4).value =55;
24 | xlSheet.Cell(4, 5).value = 49; xlSheet.Cell(5, 5).value = 64;
25 |
26 | xlSheet.Cell(6, 2).value ="Germany"; xlSheet.Cell(7, 2).value ="Switzerland";
27 | xlSheet.Cell(6, 3).value =88; xlSheet.Cell(7, 3).value = 93;
28 | xlSheet.Cell(6, 4).value =46; xlSheet.Cell(7, 4).value = 54;
29 | xlSheet.Cell(6, 5).value =55; xlSheet.Cell(7, 5).value = 50;
30 |
31 | xlSheet.Cell(8, 2).value ="Spain"; xlSheet.Cell(9, 2).value ="Italy";
32 | xlSheet.Cell(8, 3).value = 86; xlSheet.Cell(9, 3).value = 75;
33 | xlSheet.Cell(8, 4).value = 47; xlSheet.Cell(9, 4).value = 52;
34 | xlSheet.Cell(8, 5).value = 69; xlSheet.Cell(9, 5).value = 71;
35 |
36 | xlSheet.Cell(10, 2).value ="Greece"; xlSheet.Cell(11, 2).value ="Japan";
37 | xlSheet.Cell(10, 3).value =67; xlSheet.Cell(11, 3).value =91;
38 | xlSheet.Cell(10, 4).value =23; xlSheet.Cell(11, 4).value =57;
39 | xlSheet.Cell(10, 5).value =87; xlSheet.Cell(11, 5).value =36;
40 |
41 | var xlAutoFilter = xlSheet.autoFilter();
42 | xlAutoFilter.setRef("B3E11");
43 |
44 | var xlFilterColumn = xlAutoFilter.getColumn(2);
45 | xlFilterColumn.setTop10(3);
46 |
47 | var format2 = xlSheet.Cells(1,1).format;
48 | xlSheet.applyFilter();
49 |
50 | io.print(xlExcel.Save(file))
51 | io.print(xlExcel.getErrMsg())
52 |
53 | xlExcel.Close()
54 |
55 | io.print("use " + (time.tick() - start + " ms"));
56 | }
57 |
58 | };
59 |
60 | autofilter_topN()
61 |
62 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zgmf-x-20a/libxl/681649161af7ec082c7648263a8965ab8474d80c/demo/Publish/script/logo.png
--------------------------------------------------------------------------------
/demo/Publish/script/mergecells.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var mergeCells = function(){
5 |
6 | io.open()
7 |
8 | var start = time.tick()
9 |
10 | var file = "export/merge.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | var format1 = xlExcel.addFormat();
14 | format1.alignH = 2/*ALIGNH_CENTER*/;
15 | format1.alignV = 1/*ALIGNV_CENTER*/
16 |
17 | var xlSheet = xlExcel.addSheet("Sheet1");
18 |
19 | if xlSheet{
20 |
21 | xlSheet.Cell(4,2).setValue("Hello World!",format1);
22 | xlSheet.setMerge(4, 6, 2, 6);
23 | xlSheet.Range("B8:C21,E8F21").merge();
24 |
25 | xlSheet.Cell(8,2).setValue(1,format1);
26 | xlSheet.Cell(8,5).setValue(2,format1);
27 |
28 | io.print(xlExcel.Save(file))
29 | io.print(xlExcel.getErrMsg())
30 |
31 | xlExcel.Close()
32 |
33 | io.print("use " + (time.tick() - start + " ms"));
34 | }
35 |
36 | };
37 |
38 | mergeCells()
39 |
40 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/receipt.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 | import preg;
4 | import console;
5 |
6 |
7 | var WriteData = function(){
8 | io.open()
9 |
10 | var file = "export/receipt.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | //var Lincense_Name,Lincense_Key = "Halil Kural","windows-2723210a07c4e90162b26966a8jcdboe";
14 |
15 | //xlExcel.setKey(Lincense_Name,Lincense_Key);//注册
16 |
17 |
18 | var logoId = xlExcel.addPicture("script/logo.png")
19 |
20 | var textFont = xlExcel.addFont();
21 | textFont.size = 8;
22 | textFont.name = "Century Gothic"
23 |
24 | var titleFont = xlExcel.addFont(textFont)
25 | titleFont.size = 38
26 | titleFont.color = 22/*_COLOR_GRAY25*/
27 |
28 | var font12 = xlExcel.addFont(textFont);
29 | font12.size = 12;
30 |
31 | var font10 = xlExcel.addFont(textFont);
32 | font10.size = 10;
33 |
34 | var textFormat = xlExcel.addFormat()
35 | textFormat.font = textFont
36 | textFormat.alignH = 1/*ALIGNH_LEFT*/
37 |
38 | var titleFormat = xlExcel.addFormat()
39 | titleFormat.font = titleFont;
40 | titleFormat.alignH = 3/*ALIGNH_RIGHT*/
41 |
42 | var companyFormat = xlExcel.addFormat()
43 | companyFormat.font = font12
44 |
45 | var dateFormat = xlExcel.addFormat(textFormat)
46 | dateFormat.numStyle = xlExcel.addNumFormat("[$-409]mmmm d, yyyy;@")
47 |
48 | var phoneFormat = xlExcel.addFormat(textFormat)
49 | phoneFormat.numStyle = xlExcel.addNumFormat("[<=9999999]###\-####;\(###\)\ ###\-####")
50 |
51 |
52 | var borderFormat = xlExcel.addFormat(textFormat)
53 | borderFormat.borderStyle = 1 /*BORDERSTYLE_THIN*/
54 | borderFormat.borderColor = 22/*_COLOR_GRAY25*/
55 | borderFormat.alignV = 1/*ALIGNV_CENTER*/
56 |
57 | var percentFormat = xlExcel.addFormat(borderFormat)
58 | percentFormat.numStyle = xlExcel.addNumFormat("#%_)")
59 | percentFormat.alignH = 3/*ALIGNH_RIGHT*/
60 |
61 | var textRightFormat = xlExcel.addFormat(textFormat)
62 | textRightFormat.alignV = 1/*ALIGNV_CENTER*/
63 | textRightFormat.alignH = 3/*ALIGNH_RIGHT*/
64 |
65 | var thankFormat = xlExcel.addFormat()
66 | thankFormat.font = font10;
67 | thankFormat.alignH = 2/*ALIGNH_CENTER*/;
68 |
69 | var dollarFormat = xlExcel.addFormat(borderFormat)
70 | dollarFormat.numStyle = xlExcel.addNumFormat("_($* # ##0.00_);_($* (# ##0.00);_($* -??_);_(@_)")
71 |
72 | xlSheet = xlExcel.addSheet("Sales Receipt")
73 | xlSheet.displayGridlines = false
74 |
75 | xlSheet.Column(1).width = 10
76 | xlSheet.Column(2).width = 36
77 | xlSheet.Column(3,4).width = 11
78 | xlSheet.Column(5).width = 13
79 | xlSheet.Row(3).height = 47.25
80 |
81 | xlSheet.Cells(3,2).value = "Sales Receipt"
82 | xlSheet.Cells(3,2).format = titleFormat
83 | xlSheet.setMerge(3,3,2,5)
84 | xlSheet.setPicture(3,2,logoId,0.8)
85 |
86 | xlSheet.Cells(5,1).value = "Apricot Ltd.";
87 | xlSheet.Cells(5,1).format = companyFormat;
88 | xlSheet.Cells(5,4).value = "Date:";
89 | xlSheet.Cells(5,4).format = textFormat;
90 | xlSheet.Cells(5,5).formula = "TODAY()";
91 | xlSheet.Cells(5,5).format = dateFormat;
92 |
93 | xlSheet.Cells(6,4).value = "Receipt #:"
94 | xlSheet.Cells(6,4).format = textFormat;
95 | xlSheet.Cells(6,5).value = 652;
96 | xlSheet.Cells(6,5).format = textFormat;
97 |
98 | xlSheet.Cells(9,1).value = "Sold to:"
99 | xlSheet.Cells(9,1).format = textFormat
100 | xlSheet.Cells(9,2).value = "John Smith"
101 | xlSheet.Cells(9,2 ).format = textFormat
102 | xlSheet.Cells(10,2).value = "Pineapple Ltd."
103 | xlSheet.Cells(10,2).format = textFormat
104 | xlSheet.Cells(11 ,2 ).value = "123 Dreamland Street"
105 | xlSheet.Cells(11 ,2 ).format =textFormat
106 | xlSheet.Cells(12 ,2 ).value = "Moema, 52674"
107 | xlSheet.Cells(12 ,2 ).format = textFormat
108 | xlSheet.Cells(13 ,2 ).value = 2659872055
109 | xlSheet.Cells(13 ,2 ).format = phoneFormat
110 |
111 | xlSheet.Cells(15,1).value = "Item #"
112 | xlSheet.Cells(15,1).format = textFormat
113 | xlSheet.Cells(15,2).value = "Description"
114 | xlSheet.Cells(15,2).format = textFormat
115 | xlSheet.Cells(15,3).value = "Qty"
116 | xlSheet.Cells(15,3).format = textFormat
117 | xlSheet.Cells(15,4).value = "Unit Price"
118 | xlSheet.Cells(15,4).format = textFormat
119 | xlSheet.Cells(15,5).value = "Line Total"
120 | xlSheet.Cells(15,5).format = textFormat
121 |
122 | for row=16;38;1{
123 | xlSheet.Row(row).height = 15
124 | for col=1;3;1{
125 | xlSheet.Cells(row,col).blank = borderFormat
126 | }
127 | xlSheet.Cells(row,4).blank = dollarFormat;
128 | var str = string.concat("IF(C",row,">0;ABS(C",row ,"*D",row,");)")
129 | xlSheet.Cells(row,5).formula = str;
130 | xlSheet.Cells(row,5).format = dollarFormat;
131 | }
132 |
133 | xlSheet.Cells(39,4).value = "Subtotal"
134 | xlSheet.Cells(39,4).format = textRightFormat
135 | xlSheet.Cells(40,4).value = "Sales"
136 | xlSheet.Cells(40,4).format = textRightFormat
137 | xlSheet.Cells(41,4).value = "Total "
138 | xlSheet.Cells(41,4).format = textRightFormat
139 | xlSheet.Cells(39,5).formula = "SUM(E16:E38)"
140 | xlSheet.Cells(39,5).format = dollarFormat
141 | xlSheet.Cells(40,5).value = 0.2
142 | xlSheet.Cells(40,5).format = percentFormat
143 | xlSheet.Cells(41,5).formula = "E39+E39*E40"
144 | xlSheet.Cells(41,5).format = dollarFormat
145 | xlSheet.Row(39).height = 15
146 | xlSheet.Row(40).height = 15
147 | xlSheet.Row(41).height = 15
148 |
149 | xlSheet.Cells(43,1).value = "Thank you for your business!"
150 | xlSheet.Cells(43,1).format = thankFormat;
151 | xlSheet.setMerge(43,43,1,5)
152 |
153 | xlSheet.Cells(16,1).value = 45;
154 | xlSheet.Cells(16,1).format = borderFormat;
155 | xlSheet.Cells(16,2).value = "Grapes";
156 | xlSheet.Cells(16,2).format = borderFormat;
157 | xlSheet.Cells(16,3).value = 250;
158 | xlSheet.Cells(16,3).format = borderFormat;
159 | xlSheet.Cells(16,4).value = 4.5;
160 | xlSheet.Cells(16,4).format = dollarFormat;
161 |
162 | xlSheet.Cells(17,1).value = 12;
163 | xlSheet.Cells(17,1).format = borderFormat;
164 | xlSheet.Cells(17,2).value = "Bananas";
165 | xlSheet.Cells(17,2).format = borderFormat;
166 | xlSheet.Cells(17,3).value = 480;
167 | xlSheet.Cells(17,3).format = borderFormat;
168 | xlSheet.Cells(17,4).value = 1.4;
169 | xlSheet.Cells(17,4).format = dollarFormat;
170 |
171 | xlSheet.Cells(18,1).value = 19;
172 | xlSheet.Cells(18,1).format = borderFormat;
173 | xlSheet.Cells(18,2).value = "Apples";
174 | xlSheet.Cells(18,2).format = borderFormat;
175 | xlSheet.Cells(18,3).value = 180;
176 | xlSheet.Cells(18,3).format = borderFormat;
177 | xlSheet.Cells(18,4).value = 2.8;
178 | xlSheet.Cells(18,4).format = dollarFormat;
179 |
180 | io.print(xlExcel.Save(file))
181 |
182 | io.print(xlExcel.getErrMsg())
183 |
184 | xlExcel.Close()
185 |
186 | io.print("Done")
187 |
188 |
189 | };
190 |
191 | WriteData()
192 |
193 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/usedrange.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var mergeCells = function(){
5 |
6 | io.open()
7 |
8 | var start = time.tick()
9 |
10 | var file = "export/usedrange.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | var format1 = xlExcel.addFormat();
14 | format1.alignH = 2/*ALIGNH_CENTER*/;
15 | format1.alignV = 1/*ALIGNV_CENTER*/
16 |
17 | var xlSheet = xlExcel.addSheet("Sheet1");
18 |
19 | if xlSheet{
20 |
21 | xlSheet.Cell(4,2).setValue("Hello World!",format1);
22 | xlSheet.setMerge(4, 6, 2, 6);
23 | xlSheet.Range("B8:C21,E8F21").merge();
24 |
25 | xlSheet.Cell(8,2).setValue(1,format1);
26 | xlSheet.Cell(8,5).setValue(2,format1);
27 |
28 |
29 | var usedRange = xlSheet.usedRange;
30 | console.log(usedRange.Rows.Count,usedRange.Columns.Count)
31 |
32 | io.print(xlExcel.Save(file))
33 | io.print(xlExcel.getErrMsg())
34 |
35 | xlExcel.Close()
36 |
37 | io.print("use " + (time.tick() - start + " ms"));
38 | }
39 |
40 | };
41 |
42 | mergeCells()
43 |
44 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/writedatatime.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 |
5 | var writeDataTime = function(){
6 | io.open()
7 | var start = time.tick()
8 |
9 | var file = "export/datetime.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var format1 = xlExcel.addFormat();
13 | format1.numStyle = 15/*_NUMFORMAT_DATE*/;
14 |
15 | var format2 = xlExcel.addFormat();
16 | format2.numStyle = 23/*_NUMFORMAT_CUSTOM_MDYYYY_HMM*/;
17 |
18 | var format3 = xlExcel.addFormat();
19 | format3.numStyle = xlExcel.addNumFormat("d mmmm yyyy");
20 |
21 | var format4 = xlExcel.addFormat();
22 | format4.numStyle = 19/*_NUMFORMAT_CUSTOM_HMM_AM*/;
23 |
24 | var xlSheet = xlExcel.addSheet("Sheet1");
25 |
26 | if xlSheet{
27 |
28 | xlSheet.Column(2).width = 15
29 |
30 | xlSheet.Cell(3,2).value = xlExcel.datePack(2010,3,11);
31 | xlSheet.Cell(3,2).format = format1;
32 |
33 | xlSheet.Cell(4,2).setValue(xlExcel.datePack(2010,3,11,10,25,55),format2);
34 | xlSheet.Cell(5,2).setValue(xlExcel.timeValue("2010-03-11 0:0:0"),format3);
35 | xlSheet.Cell(6,2).setValue(xlExcel.timeValue("2010-03-11 10:25:55"),format4);
36 |
37 | var date = xlExcel.time(xlSheet.Cell(3,2).value);
38 | console.log("date",date)
39 |
40 | var date = xlExcel.time(xlSheet.Cell(4,2).value);
41 | console.log("date",date)
42 |
43 | io.print(xlExcel.Save(file))
44 | io.print(xlExcel.getErrMsg())
45 |
46 | xlExcel.Close()
47 |
48 | io.print("use " + (time.tick() - start + " ms"));
49 | }
50 |
51 | };
52 |
53 | writeDataTime()
54 |
55 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/script/writeformulas.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 | import console;
4 |
5 |
6 | var WriteData = function(){
7 | io.open()
8 | var start = time.tick()
9 |
10 | var file = "export/formula.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | var alFormat = xlExcel.addFormat()
14 | alFormat.alignH = 1/*ALIGNH_LEFT*/
15 |
16 | var arFormat = xlExcel.addFormat()
17 | arFormat.alignH = 3/*ALIGNH_RIGHT*/
18 |
19 | var alignDateFormat = xlExcel.addFormat(alFormat)
20 | alignDateFormat.numStyle = 14/*NUMFORMAT_DATE*/
21 |
22 | var linkFont = xlExcel.addFont();
23 | linkFont.color = 12/*_COLOR_BLUE*/
24 | linkFont.underLine = 1/*_UNDERLINE_SINGLE*/
25 |
26 | var linkFormat = xlExcel.addFormat(alFormat);
27 | linkFormat.font = linkFont;
28 |
29 | var xlSheet = xlExcel.addSheet("Sheet1")
30 |
31 | if xlSheet{
32 |
33 | xlSheet.Cell("A12").value = 40
34 |
35 | xlSheet.Column(1).width = 27
36 | xlSheet.Column(2).width = 10
37 |
38 | xlSheet.Cell(3,2).value = 40
39 | xlSheet.Cell(3,2).format = alFormat
40 | xlSheet.Cell(4,2).value = 30
41 | xlSheet.Cell(4,2).format = alFormat
42 | xlSheet.Cell(5,2).value = 50
43 | xlSheet.Cell(5,2).format = alFormat
44 |
45 | xlSheet.Cell(7,1).setValue("SUM(B3:B5) = ",arFormat)
46 | xlSheet.Cell(7,2).setFormula ("SUM(B3:B5)",alFormat)
47 |
48 | xlSheet.Cell(8,1).value = "AVERAGE(B3:B5) = ";
49 | xlSheet.Cell(8,1).format = arFormat;
50 | xlSheet.Cell(8,2).formula = "AVERAGE(B3:B5)";
51 | xlSheet.Cell(8,2).format = alFormat;
52 |
53 | xlSheet.Cell(9,1).value = "MAX(B3:B5) =";
54 | xlSheet.Cell(9,1).format = arFormat;
55 | xlSheet.Cell(9,2).formula = "MAX(B3:B5)";
56 | xlSheet.Cell(9,2).format = alFormat;
57 |
58 | xlSheet.Cell(10,1).value = "MIN(B3:B5) =";
59 | xlSheet.Cell(10,1).format = arFormat;
60 | xlSheet.Cell(10,2).formula = "MIN(B3:B5)";
61 | xlSheet.Cell(10,2).format = alFormat;
62 |
63 | xlSheet.Cell(11,1).value = "COUNT(B3:B5) =";
64 | xlSheet.Cell(11,1).format = arFormat;
65 | xlSheet.Cell(11,2).formula = "COUNT(B3:B5)";
66 | xlSheet.Cell(11,2).format = alFormat;
67 |
68 | io.print(xlExcel.Save(file))
69 |
70 | io.print(xlExcel.getErrMsg())
71 |
72 | xlExcel.Close()
73 |
74 | io.print("Done")
75 |
76 | io.print("use" + (time.tick() - start + "ms"));
77 | }
78 |
79 | };
80 |
81 | WriteData()
82 |
83 | console.pause(true);
--------------------------------------------------------------------------------
/demo/Publish/test.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 |
4 | io.open();
5 |
6 | var xlExcel = libxl();
7 |
8 | var xlSheet = xlExcel.addSheet("Sheet1");
9 | var newFormat = xlExcel.addFormat();
10 | newFormat.font.bold = true;
11 |
12 | var format = xlSheet.Cell(1,1).format
13 | var format2 = xlSheet.Cell(1,1).format
14 | xlSheet.Cell(1,2).format = newFormat;
15 | var format3 = xlSheet.Cell(1,2).format
16 |
17 | console.log("format",format,format.hwnd)
18 | console.log("format2",format2,format2.hwnd)
19 | console.log("format3",format3,newFormat,format3.hwnd,format2.font,format3.font)
20 |
21 | xlExcel.Close();
22 |
23 | console.pause();
--------------------------------------------------------------------------------
/demo/Publish/txt2xlsx.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 | import fsys.file;
4 | import fsys.codepage;
5 |
6 | path = "F:\成本底稿\芯片数据底稿\前期数据\201402.XLS"
7 |
8 | xlsdata = class {
9 | ctor( path ){
10 | var loadFFFELine = function(path){
11 | if !..io.exist(path) return ;
12 | return ..fsys.codepage.load(path,"unicodeFFFE")
13 | };
14 | var spliteData = function(data,rule = '<\r\n>'){
15 | return ..string.split(data,rule);
16 | };
17 |
18 | this.data = spliteData(loadFFFELine(path));
19 | this.seek = 0;
20 | };
21 | readline = function(){
22 | this.seek ++;
23 | return this.data[this.seek];
24 | };
25 | writeFile = function(path){
26 | var file = ..io.open(path,"wb+");
27 | file.write(..string.join(this.data));
28 | file.close();
29 | }
30 | }
31 |
32 | file = xlsdata(path);
33 |
34 | var i=0;
35 | while(i<30){
36 | var line = file.readline()
37 | console.log(i,#line,line)
38 | i ++;
39 | }
40 |
41 | file.writeFile("F:\成本底稿\芯片数据底稿\前期数据\测试.txt")
42 |
43 |
44 | console.pause();
45 |
--------------------------------------------------------------------------------
/demo/Publish/返点.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 | import web.json;
4 |
5 | io.open();
6 |
7 | var file = "F:\抵减明细\201707\剩余返点.xlsx"
8 | var save = "F:\抵减明细\201707\剩余返点处理.xlsx"
9 | var nowPeriod = "201707";
10 |
11 | var xlExcel = libxl(file);
12 | var desExcel = libxl();
13 |
14 |
15 |
16 | io.print("Opened");
17 |
18 | var test = function(){
19 | var src = xlExcel.Sheet("预提");
20 | for row=1;70;1{
21 | console.log("row",row,src.Cells(row,1).value)
22 | }
23 | }
24 |
25 |
26 | var getDiscount = function(){
27 | var list = {
28 | }
29 |
30 | var src = xlExcel.Sheet("预提");
31 |
32 | for row = 2;src.lastRow;1{
33 | var cusCode,cusName,period = src.Cells(row,1).value,src.Cells(row,2).value,src.Cells(row,3).value;
34 | var product,discount = src.Cells(row,12).value?src.Cells(row,12).value:"0",src.Cells(row,19).value;
35 | if (!list[cusCode]) {
36 | list[cusCode] = {} ;
37 | list[cusCode].name = cusName
38 | console.log("addname",cusCode,cusName)
39 | };
40 | if (!list[cusCode][product]) list[cusCode][product] ={};
41 | if (!list[cusCode][product][period]) {
42 | list[cusCode][product][period] = {};
43 | list[cusCode][product][period].src = 0;
44 | list[cusCode][product][period].used = 0;
45 | list[cusCode][product][period].remaind = 0
46 | };
47 | list[cusCode][product][period].src += math.round(discount,2);
48 | list[cusCode][product][period].remaind += math.round(discount,2);
49 | }
50 |
51 | return list;
52 | }
53 |
54 | var setDiscount = function(destiname ="new",list){
55 | var des = desExcel.addSheet(destiname);
56 | var src = xlExcel.Sheet("实际");
57 | var line;
58 |
59 | var addline = 0;
60 |
61 | for row=1;src.lastRow;1{
62 | //if row != 139 and row != 221 continue ;
63 | line = {}
64 | for col=1;src.lastCol;1{
65 | line[col] = src.Cells(row,col).value;
66 | }
67 | //逻辑处理段
68 | var cusCode = line[1];
69 | var product = line[12];
70 | var period = line[3];
71 | var amount = line[19];
72 | var found = false;
73 |
74 | //console.varDump(line);
75 | //console.log("product",product,"amount",amount)
76 |
77 | if list[cusCode]{//客户存在记录
78 | if list[cusCode][product]{//物料存在记录
79 |
80 | if cusCode == "N2205"{ }//
81 |
82 | for k,j in list[cusCode][product]{
83 | if j.remaind == 0 continue ;//没有剩余的跳过
84 | if math.abs(j.remaind) < math.abs(j.remaind - amount) continue ;//反方向的跳过
85 | //console.log("remaind",math.abs(j.remaind),"amount",math.abs(amount),
86 | // "remaind= math.abs(amount)){
110 | //console.log("正常")
111 | found = true;
112 | line[3] = k;
113 | j.used += amount;
114 | j.remaind = j.src - j.used;
115 | break ;
116 | }
117 | }
118 | if !found line[3] = nowPeriod;
119 | }
120 | else {
121 | line[3] = nowPeriod;
122 | }
123 | }
124 | else {//不存在就是当期
125 | if row != 1 line[3] = nowPeriod;
126 | }
127 |
128 | //console.varDump(line)
129 | for k,j in line{
130 | if j des.Cells(row + addline,k).value = j;
131 | }
132 | }
133 | }
134 |
135 | writeRemaind = function(destiname="remaind",list){
136 | var des = desExcel.addSheet(destiname);
137 | var src = xlExcel.Sheet("实际");
138 | for row=1;1;1{;
139 | line = {}
140 | for col=1;src.lastCol;1{
141 | line[col] = src.Cells(row,col).value;
142 | }
143 | for k,j in line{
144 | if j des.Cells(row,k).value = j;
145 | }
146 | }
147 | var row = 1;
148 |
149 | for cusCode,value in list{
150 | for product,value2 in value{
151 | for period,value3 in value2{
152 | if math.round(value3.remaind,2) != 0{
153 | row += 1;
154 | des.Cells(row,1).value = cusCode;
155 | des.Cells(row,2).value = value.name;
156 | des.Cells(row,3).value = period;
157 | des.Cells(row,12).value = product;
158 | des.Cells(row,19).value = value3.remaind;
159 | }
160 | }
161 | }
162 | }
163 | }
164 |
165 | test()
166 | return console.pause();
167 | var list = getDiscount();
168 | setDiscount("测试",list);
169 | writeRemaind("剩余",list);
170 |
171 | console.log("Saving")
172 |
173 | desExcel.Save(save);
174 |
175 | desExcel.Close();
176 | xlExcel.Close();
177 |
178 | console.pause();
--------------------------------------------------------------------------------
/demo/default.aproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/demo/lib/config.aardio:
--------------------------------------------------------------------------------
1 | //config 配置文件
2 | import fsys.config;
3 | config = ..fsys.config("/config/");
4 |
5 | /**
6 | config = ..fsys.config(
7 | ..fsys.joinpath( ..fsys.getSpecial( 0x1c /*_CSIDL_LOCAL_APPDATA*/ ),"应用程序名" )
8 | );
9 | **/
10 |
11 | //不需要序列化的配置名字前请添加下划线
12 | namespace config {
13 | __appName = "应用程序名";
14 | __appVersion = "1.0.0.01";
15 | __appDescription = "这是一个测试程序";
16 | __website = "http://www.aardio.com/";
17 | }
18 |
19 | /**intellisense(config)
20 | __appName = 应用程序名
21 | __appVersion = 应用程序内部版本号
22 | __appDescription = 程序说明
23 | __website = 官方网站
24 |
25 | saveAll() = 写入所有配置到文件
26 | mainForm.load() = 从配置文件(文件名"default")载入\n加载成功返回对象,加载失败返回null空值\n!fsys_table.
27 | mainForm.save() = 存储到配置文件(文件名"default")
28 | mainForm.mixin = @.mixin(\n 键名 = 值__;\n 键名 = 值;\n);//该数会自动调用save函数保存配置到文件
29 | mainForm.控件名称 = 控件默认值\n调用save()函数同步控件当前值
30 | mainForm.属性名 = 自配置文件(文件名"default")读写属性\n属性值可以是支持序列化的普通变量,支持table对象.\n配置文件在首次使用时自动加载,退出程序时自动保存.
31 | ? = 配置文件名,\n读写配置并序列化为一个表对象,\n表的成员值可以是支持序列化的普通变量,支持table对象\n配置文件在首次使用时自动加载,退出程序时自动保存\n!fsys_table.
32 | end intellisense**/
33 |
--------------------------------------------------------------------------------
/demo/lib/libxl/_.aardio:
--------------------------------------------------------------------------------
1 | //libxl
2 | import raw;
3 | import time;
4 |
5 | class libxl{
6 | ctor( file = "xlsx" ){
7 | //默认为 EXCEL XLSX
8 | this.file = ..io.exist(file);
9 | this.open = false;
10 | this.Book = Book;
11 | this.raw = false;//是否字节流
12 | this.Sheet = {//存储表数据
13 | @{
14 | _get = function(k){ //通过表名获取时
15 | for i=1;#owner;1{;//搜寻表名,一致时返回
16 | if owner[i].name == k return owner[i];
17 | };
18 | return null//owner[[k]];
19 | }
20 | _call = function(k){ //通过表名获取时
21 | if type(k) == type.number{
22 | if (k <= #owner) && (k > 0) return owner[k];
23 | }
24 | if type(k) == type.string{
25 | for i=1;#owner;1{;//搜寻表名,一致时返回
26 | if owner[i].name == k return owner[i];
27 | };
28 | }
29 | return null;
30 | }
31 | }
32 | };
33 |
34 | createbook = function(ext){
35 | if ext == null error("请指定文件类型");
36 | ext = ..string.lower( ..string.replace(ext,"@.",""));
37 | if ext = "xlsx" {this.hwnd = CreateXMLBook();isXlsx = true};
38 | if ext = "xls" {this.hwnd = CreateBook() ;isXlsx = false};
39 | if !this.hwnd return null;
40 | if (Lincense_Name && Lincense_Key) Book.SetKey(this.hwnd,Lincense_Name,Lincense_Key);//注册libxl
41 | return true;
42 | };
43 | getFileType = function(file){
44 | if !..io.exist(file) error("文件不存在");
45 | var hFile = ..io.open(file,"rb");
46 | var header = hFile.read(6);
47 | hFile.close()
48 | header = ..raw.convert(header,fileHeader);
49 | header = ..string.hex(header.head,"");
50 | if header == xlsHead return "xls";
51 | if header == xlsxHead return "xlsx";
52 | return null;
53 | };
54 | getFileTypebyName = function(file){
55 | var filePath = ..io.splitpath(file);
56 | if filePath.ext != "" return ..string.replace(filePath.ext,"@.","");
57 | return null;
58 | };
59 | getSheets = function(){
60 | var count = Book.SheetCount(this.hwnd);
61 | for i=1;count;1{
62 | ..table.push(this.Sheet,Sheet(Book.GetSheet(this.hwnd,i-1),this.ShareFormat));//读取并添加对应的Sheet表
63 | };
64 | if count return true;
65 | };
66 |
67 | isXlsx = null;
68 | if !..io.exist(file) && file != null{ //文件不存在,且参数非空,根据扩展名创建;
69 | var ext = file
70 | if #file > 5 {
71 | if #file > 1024{
72 | ext = "xlsx"; //默认xlsx,其实应该增加字节判断
73 | this.raw = true;
74 | }
75 | else {
76 | if !..io.exist(file) error("文件不存在")
77 | }
78 | }
79 | if !createbook(ext) error ("错误的参数");
80 | };
81 | errMsgStatue = function(){
82 | if this.hwnd {
83 | var err = Book.ErrorMessage(this.hwnd);
84 | if (err = errMsg[1] || err = errMsg[2]) err = "错误的文件类型"
85 | return err;
86 | };
87 | return "句柄不存在";
88 | };
89 |
90 | load = function(file,ext){
91 | if !file return null,"文件不存在";
92 | if this.raw {
93 | if this.hwnd == null && ext == null error("请指定文件类型");
94 | if !createbook( ext:( isXlsx?"xlsx":"xls" )) error("错误的参数");
95 | if !Book.LoadRaw(this.hwnd,file,#file) return null,errMsgStatue();
96 | this.open = true;
97 | };
98 | else {
99 | if this.hwnd == null {
100 | ext = ext?ext:(getFileType(file)?getFileType(file):getFileTypebyName(file));
101 | if !createbook(ext) error("错误的文件类型");
102 | };
103 | if !Book.Load(this.hwnd,file) return null,errMsgStatue();
104 | this.file = file;
105 | this.open = true;
106 | };
107 | if getSheets() return true;
108 | };
109 | //---共享格式对象
110 | this.ShareFormat = {book = this};
111 | this.ShareFormat.Formats = { //同一个工作表的Format是共享的
112 | @{
113 | _call = function(k,p_shareformat){ //k是句柄
114 | if owner[tonumber(k)] return owner[tonumber(k)];
115 | owner[tonumber(k)] = ..libxl.Format(k,p_shareformat)
116 | return owner[tonumber(k)];
117 | }
118 | }
119 | }
120 | this.ShareFormat.Fonts = {//同一个工作表的Font是共享的
121 | @{
122 | _call = function(k){ //k是句柄
123 | if owner[tonumber(k)] return owner[tonumber(k)];
124 | owner[tonumber(k)] = ..libxl.Font(k)
125 | return owner[tonumber(k)];
126 | }
127 | }
128 | }
129 | if this.file or this.raw //字节类的也加载
130 | if !load(file) return null,"文件无法加载";
131 |
132 | };
133 | @_metaProperty;
134 | Load = load;
135 | Save = function(file){
136 | var path = this.file;
137 | if file path = file;
138 | if this.raw && !path return owner.saveStr();
139 | if !path return null,"未指定文件";
140 | if path return Book.Save(this.hwnd,path);
141 | return false;
142 | }
143 | loadStr = function(pString){
144 | if !Book.LoadRaw(this.hwnd,pString,#pString) return null,"文件无法从内存加载";
145 | getSheets()
146 | };
147 | saveStr = function(){
148 | var str = /*{byte buffer[%d]}*/
149 | var result,data,size = Book.SaveRaw(this.hwnd,,1);
150 | if !result return null,"文件无法保存至变量";
151 | data = ..raw.convert(data,eval(..string.format(str,size )))
152 | return data.buffer;
153 | };
154 | addSheet = function(sheetName,cpSheet){
155 | var iniSheetHwnd;
156 | if type(sheetName) != type.string sheetName = tostring(sheetName);//强制转换
157 | if (type(cpSheet) == type.number){
158 | if cpSheet > #this.Sheet return null,"工作表不存在";
159 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
160 | }
161 | elseif (type(cpSheet) == type.string){
162 | var sheet = this.Sheet[cpSheet]
163 | if !sheet return null,"工作表不存在";
164 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
165 | }
166 | elseif (type(cpSheet) == type.table) {
167 | if !cpSheet.hwnd return null,"工作表不存在";;
168 | iniSheetHwnd = cpSheet.hwnd
169 | }
170 | var np_Sheet = Book.AddSheet(this.hwnd,sheetName,iniSheetHwnd)
171 | if !np_Sheet return null,"工作表创建失败";
172 | ..table.push(this.Sheet,Sheet(np_Sheet,this.ShareFormat));//增加book对象
173 | return this.Sheet[#this.Sheet];
174 | };
175 | insertSheet = function(index,sheetName,cpSheet){
176 | var iniSheetHwnd;
177 | if type(cpSheet) == type.number{
178 | if cpSheet > #this.Sheet return null,"工作表不存在";
179 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
180 | };
181 | if type(cpSheet) == type.string{
182 | var sheet = this.Sheet[cpSheet]
183 | if !sheet return null,"工作表不存在";
184 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
185 | };
186 | var np_Sheet = Book.InsertSheet(this.hwnd,index - 1,sheetName,iniSheetHwnd)
187 | if !np_Sheet return null,"工作表创建失败";
188 | ..table.insert(this.Sheet,Sheet(np_Sheet,this.ShareFormat),index);//增加book对象
189 | return this.Sheet[index];
190 | };
191 | moveSheet = function(cpSheet,index){
192 | var srcSheetIndex;
193 | if !index return null,"请指定目的位置";
194 | srcSheetIndex = cpSheet;
195 | if type(cpSheet) == type.number if cpSheet > #this.Sheet return null,"工作表不存在";
196 | if type(cpSheet) == type.string{
197 | for i = 1;#this.Sheet{
198 | if this.Sheet[i].name == srcSheetIndex{
199 | srcSheetIndex = i;
200 | break ;
201 | }
202 | }
203 | if type(srcSheetIndex) != type.number return null,"工作表不存在";
204 | }
205 | Book.MoveSheet(this.hwnd,srcSheetIndex,index)
206 | };
207 | sheetType = function(cpSheet){
208 | var index;
209 | if type(cpSheet) == type.string{
210 | for i=1;#this.Sheet;1{;//搜寻表名,一致时返回
211 | if this.Sheet[i].name == cpSheet {
212 | index = i;
213 | break ;
214 | } ;
215 | };
216 | }
217 | if !index index = cpSheet;
218 | return Book.SheetType(this.hwnd,index -1);
219 | };
220 | delSheet = function(cpSheet){
221 | var index;
222 | if type(cpSheet) == type.string{
223 | for i=1;#this.Sheet;1{;//搜寻表名,一致时返回
224 | if this.Sheet[i].name == cpSheet {
225 | index = i;
226 | break ;
227 | } ;
228 | };
229 | }
230 | if !index index = cpSheet;
231 | var result = Book.DelSheet(this.hwnd,index -1);
232 | if !result return result;
233 | ..table.remove(this.Sheet,index)
234 | return true;
235 | };
236 | addFormat = function(hFormat){
237 | if type(hFormat) == type.table hFormat = hFormat.hwnd
238 | var hwnd = Book.AddFormat(this.hwnd,hFormat)
239 | return this.ShareFormat.Formats(hwnd,this.ShareFormat); //统一管理格式
240 | };
241 | addFont = function(hFont){
242 | if type(hFont) == type.table hFont = hFont.hwnd
243 | var hwnd = Book.AddFont(this.hwnd,hFont)
244 | return this.ShareFormat.Fonts(hwnd); //统一管理字体
245 | };
246 | addNumFormat = function(textNumFormat){
247 | return (Book.AddCustomNumFormat(this.hwnd,textNumFormat) + 1);
248 | };
249 | getFormat = function(index){
250 | return Book.Format(this.hwnd,index - 1);
251 | };
252 | getFont = function(index){
253 | return Book.Font(this.hwnd,index - 1);
254 | };
255 | getNumFormat = function(index){
256 | return Book.CustomNumFormat(this.hwnd,index - 1);
257 | };
258 | datePack = function(year, month, day, hour = 0, min = 0, sec = 0, msec = 0){
259 | return Book.DatePack(this.hwnd,year,month,day,hour,min, sec,msec);
260 | }
261 | dateUnpack = function(date){
262 | var result,year,month,day,hour,min,sec,msec = Book.DateUnpack(this.hwnd,date,0,0,0,0,0,0,0);
263 | if !result return null;
264 | var date = {year = year; month = month; day = day; hour = hour;min = min;sec = sec;msec =msec};
265 | return date;
266 | }
267 | timeValue = function(date){
268 | var datetime = date;
269 | if type(datetime) == type.string datetime = ..time(datetime);
270 | if type(datetime) != type.table return null;
271 | return Book.DatePack(this.hwnd,datetime.year,datetime.month,datetime.day,
272 | datetime.hour,datetime.minute, datetime.second,datetime.milliseconds);
273 | }
274 | time = function(date){
275 | var result,year,month,day,hour,min,sec,msec = Book.DateUnpack(this.hwnd,date,0,0,0,0,0,0,0);
276 | if !result return null;
277 | var datetime = ..time();
278 | datetime.year = year;
279 | datetime.month = month;
280 | datetime.day = day;
281 | datetime.hour = hour;
282 | datetime.minute = min;
283 | datetime.second = sec;
284 | datetime.milliseconds = msec;
285 | return datetime;
286 | };
287 | colorPack = function(red = 0,green = 0, blue = 0){
288 | return Book.ColorPack(this.hwnd,red,green,blue);
289 | };
290 | colorUnpack = function(rgbColor){
291 | var red,green,blue = Book.ColorUnpack(this.hwnd,rgbColor,0,0,0);
292 | if !red return null;
293 | var color = {red = red;green = green; blue = blue}
294 | return color;
295 | };
296 | getPicture = function(index){
297 | var str = /*{byte buffer[%d]}*/
298 | var picType,data,size = Book.GetPicture(this.hwnd,index - 1,,1);
299 | data = ..raw.convert(data,eval(..string.format(str,size )))
300 | return data.buffer,picType;
301 | };
302 | addPicture = function(file){
303 | var result = Book.AddPicture(this.hwnd,..io.exist(file));
304 | if result == -1 return null;
305 | result += 1;
306 | return result;
307 | };
308 | addPictureByStr = function(pString){
309 | var result = Book.AddPicture2(this.hwnd,pString,#pString);
310 | if result == -1 return null;
311 | result += 1;
312 | return result;
313 | };
314 | getDefaultFont = function(){
315 | var int = 1;
316 | var name,size = Book.DefaultFont(this.hwnd,int);
317 | if !name return null;
318 | return name,size;
319 | };
320 | setDefaultFont = function(fontName,fontSize){
321 | Book.SetDefaultFont(this.hwnd,fontName,fontSize);
322 | };
323 | setKey = function(name,key){
324 | Book.SetKey(this.hwnd,name,key);
325 | };
326 | setStrLocal = function(descrption){
327 | Book.SetLocale(this.hwnd,descrption);
328 | };
329 | getErrMsg = function(){
330 | return ..raw.str(Book.ErrorMessage(this.hwnd));
331 | };
332 | Close = function(save = false){
333 | if save Book.Save(this.hwnd,this.file);
334 | Release(this.hwnd);
335 | this.open = false;
336 | owner = null;//销毁对象
337 | collectgarbage("collect");
338 | return true;
339 | };
340 | };
341 |
342 | namespace libxl{
343 |
344 | LIBXL_VERSON = "3.8.0.0";
345 |
346 | _dll = ..raw.loadDll("/res/libxl.dll",,"cdecl,unicode");
347 |
348 | import libxl.Book;
349 | import libxl.Sheet;
350 | import libxl.Format;
351 | import libxl.Font;
352 | import libxl.AutoFilter;
353 | import libxl.FilterColumn;
354 |
355 | var libxl32 = _dll;
356 |
357 | //Lincense_Name,Lincense_Key = "","";
358 |
359 | CreateBook = libxl32.api("xlCreateBook","ptr()");
360 | CreateXMLBook = libxl32.api("xlCreateXMLBook","ptr()");
361 | Release = libxl32.api("xlBookRelease","void(ptr BookHandle)");
362 |
363 | cellComment = class {
364 | ctor( value,author,width = 100,height = 50 ){
365 | this.value = value;
366 | this.author = author;
367 | this.width = width;
368 | this.height = height;
369 | };
370 | }
371 | cellRange = class {
372 | ctor( iniRow = 1,lastRow = 1,iniCol = 1,lastCol = 1 ){
373 | this.iniCol = iniCol;
374 | this.lastCol = lastCol;
375 | this.iniRow = iniRow;
376 | this.lastRow = lastRow;
377 | };
378 | }
379 | nameRange = class {
380 | ctor( iniRow = 1,lastRow = 1,iniCol = 1,lastCol = 1,scopeID = 0,hidden = 0){
381 | this.iniCol = iniCol;
382 | this.lastCol = lastCol;
383 | this.iniRow = iniRow;
384 | this.lastRow = lastRow;
385 | this.scopeID = scopeID;
386 | this.hidden = hidden;
387 | this.name = name
388 | };
389 | }
390 |
391 | picturePos = class {
392 | ctor( top,left,bottom,right,width,height, offset_x,offset_y ){
393 | this.top = top;
394 | this.left = left;
395 | this.bottom = bottom;
396 | this.right = right;
397 | this.width = width;
398 | this.height = height;
399 | this.offset_x = offset_x;
400 | this.offset_y = offset_y;
401 | };
402 | };
403 |
404 | fileHeader = {
405 | byte head[6];
406 | };
407 | xlsHead = "D0CF11E0A1B1";
408 | xlsxHead = "504B03041400";
409 | errMsg = {
410 | "invalid file format";
411 | "The central directory was not found in the archive (or you were trying to open not the last volume of a segmented archive).";
412 | };
413 |
414 |
415 | _metaProperty = ..util.metaProperty(
416 | formatCount = {
417 | _get = function(){
418 | return Book.FormatSize(owner.hwnd);
419 | }
420 | };
421 | fontCount = {
422 | _get = function(){
423 | return Book.FontSize(owner.hwnd);
424 | };
425 | };
426 | activeSheetInex = {
427 | _get = function(){
428 | return (Book.ActiveSheet(owner.hwnd) + 1);
429 | };
430 | _set = function(v){
431 | owner.activeSheet(v);
432 | };
433 | };
434 | activeSheet = {
435 | _get = function(){
436 | return owner.Sheet((Book.ActiveSheet(owner.hwnd) + 1));
437 | };
438 | _set = function(v){
439 | var index;
440 | if type(v) == type.string{
441 | for i=1;#owner.Sheet;1{;//搜寻表名
442 | if owner.Sheet[i].name == v {
443 | index = i;
444 | break ;
445 | } ;
446 | };
447 | }
448 | if !index index = v;
449 | Book.SetActiveSheet(owner.hwnd,index - 1);
450 | };
451 | };
452 | pictureCount = {
453 | _get = function(){
454 | return Book.PictureSize(owner.hwnd);
455 | };
456 | };
457 | RGB = {
458 | _get = function(){
459 | return Book.RgbMode(owner.hwnd);
460 | };
461 | _set = function(v){
462 | return Book.SetRgbMode(owner.hwnd,v);
463 | };
464 | };
465 | R1C1 = {
466 | _get = function(){
467 | return Book.RefR1C1(owner.hwnd);
468 | };
469 | _set = function(v){
470 | return Book.SetRefR1C1(owner.hwnd,v);
471 | };
472 | };
473 | biffVersion = {
474 | _get = function(){
475 | return Book.BiffVersion(owner.hwnd);
476 | };
477 | }
478 | Date1904 = {
479 | _get = function(){
480 | return Book.IsDate1904(owner.hwnd);
481 | };
482 | _set = function(v){
483 | return Book.SetDate1904(owner.hwnd,v);
484 | };
485 | };
486 | template = {
487 | _get = function(){
488 | return Book.IsTemplate(owner.hwnd);
489 | };
490 | _set = function(v){
491 | return Book.SetTemplate(owner.hwnd,v);
492 | };
493 | };
494 | )
495 |
496 | };
497 |
498 | /**intellisense()
499 | libxl() = !libxl.
500 | !libxl.addSheet() = !xlSheet.
501 | !libxl.insertSheet() = !xlSheet.
502 | !libxl.activeSheet = !xlSheet.
503 | !libxl.Load(.(文件路径|文件流) = 加载指定Excel文件或文件流,失败返回null
504 | !libxl.Save(.() = 保存当前 Excel 文件
505 | !libxl.Sheet(.(工作表[名称|位置]) = 获取工作表对象
506 | !libxl.addSheet(.(工作表名称,[源工作表名|位置]) = 新增工作表,可复制源工作表,失败返回null
507 | !libxl.insertSheet(.(插入位置,工作表名称,[源工作表名|位置]) = 在指定位置插入工作表,可复制源工作表,失败返回null
508 | !libxl.delSheet(.(工作表名称|位置) = 删除指定名称或位置的工作表,失败返回false
509 | !libxl.sheetType(.(工作表名称|位置) = 获取指定名称或位置的工作表类型,失败返回false
510 | !libxl.addFormat(.([Format句柄]) = 新增格式句柄,可复制源格式。\n成功返回句柄,失败返回null
511 | !libxl.addFont(.([Font句柄]) = 新增字体句柄,可复制源格式。\n成功返回句柄,失败返回null
512 | !libxl.getFormat(.(工作簿内的Format索引) = 获得指定 Index 对应的 Format 句柄,失败返回null
513 | !libxl.getFont(.(工作簿内的Font索引) = 获得指定 Index 对应的 Font 句柄,失败返回null
514 | !libxl.getPicture(.(工作簿内的Picture索引) = 获得指定 Index 对应的 Picture 数据(二进制)及图片格式,失败返回null
515 | !libxl.saveStr(.() = 返回当前工作薄的数据(二进制),失败返回null
516 | !libxl.addPicture(.(文件路径) = 添加指定路径的图片并返回 图片 Index,失败返回null
517 | !libxl.addPictureByStr(.(文件流) = 加载文件流中的图片并返回 图片 Index,失败返回null
518 | !libxl.getDefaultFont(.() = 返回工作薄默认的字体名字及字号,失败返回null
519 | !libxl.setDefaultFont(.(字体名,字号) = 设置工作薄默认的字体
520 | !libxl.setKey(.(name,key) = 设置自定义 license key
521 | !libxl.addNumFormat(.("样式") = 添加自定义的数字格式
522 | !libxl.getErrMsg(.() = 获取错误信息
523 | !libxl.datePack(.(year,month,day,[hour],[min],[sec],[msec]) = 返回Excel日期数值
524 | !libxl.dateUnpack(.(date) = 将Excel日期数值转为date对象
525 | !libxl.timeValue(.(time()或时间文本) = 返回Excel日期数值
526 | !libxl.time(.(timeNumbers) = 将Excel日期数值转为time对象
527 | !libxl.colorPack(.(red,green,blue) = 打包颜色样式
528 | !libxl.colorUnpack(.(RGBColor) = 还原三原色,返回color对象
529 | !libxl.Close(.() = 关闭并销毁对象
530 | !libxl.formatCount = 工作薄内的 Format 数
531 | !libxl.fontCount = 工作薄内的 Font 数
532 | !libxl.activeSheet = 激活的工作簿
533 | !libxl.activeSheet = !xlSheet.
534 | !libxl.activeSheetInex = 激活工作簿的位置
535 | !libxl.pictureCount = 工作薄内的 Picture 数
536 | !libxl.RGB = RGB模式
537 | !libxl.R1C1 = R1C1模式
538 | !libxl.biffVersion = biffVersion,仅xls有效
539 | !libxl.Date1904 = 是否启用1904年作为日期基准
540 | !libxl.template = 是否是模板
541 | libxl.cellComment(.(value,author,[width],[height]) = 批注类,仅xls有效
542 | libxl.cellRange(.([iniRow],[lastRow],[iniCol],[lastCol]) = 区域类
543 | libxl.nameRange(.([iniCol],[lastCol],[]iniRow,lastRow],[scopeID],[hidden]) = 命名区域类
544 | libxl.picturePos(.(top,left,bottom,right,width,height, offset_x,offset_y) = 图片位置类
545 | end intellisense**/
--------------------------------------------------------------------------------
/demo/lib/libxl/autofilter.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class AutoFilter{
8 | ctor( hwnd,ow_hwnd){
9 | if !hwnd return null,"请指定自动筛选句柄";
10 | this.hwnd = hwnd;
11 | this.owner = ow_hwnd;
12 | };
13 | @_metaProperty;
14 | }
15 |
16 | namespace AutoFilter{
17 |
18 | _metaProperty = ..util.metaProperty(
19 | ref = {
20 | _get = function(){
21 | return owner.getRef();
22 | }
23 | _set = function(v){
24 | owner.setRef(v);
25 | }
26 | }
27 | columnNum = {
28 | _get = function(){
29 | return owner.columnSize();
30 | }
31 | }
32 | sortRange = {
33 | _get = function(){
34 | return getSortRange();
35 | }
36 | }
37 | columnSize = function(){
38 | return ColumnSize(owner.hwnd);
39 | }
40 | getColumn = function(index,isIndex){
41 | var func = Column;
42 | if isIndex func = ColumnByIndex;
43 | index -= 1;
44 | var hwnd = func(owner.hwnd,index);
45 | if !hwnd return null;
46 | return ..libxl.FilterColumn(hwnd);
47 | }
48 | setRef = function(v){
49 | var cellRange = v;
50 | if type(cellRange) = type.string{
51 | cellRange = ..libxl.Sheet.Range.reCalcuCellRange(owner.owner,cellRange);
52 | }
53 | SetRef(owner.hwnd,cellRange.iniRow - 1,cellRange.lastRow - 1,cellRange.iniCol - 1,cellRange.lastCol - 1);
54 | }
55 | getRef = function(addr){
56 | var result,rowFirst,rowLast,colFirst,colLast = GetRef(owner.hwnd,0,0,0,0);
57 | if !result return null;
58 | if addr{
59 | var addrStart = ..libxl.Sheet.rowColToAddr(rowFirst + 1,colFirst + 1)
60 | var addrEnd = ..libxl.Sheet.rowColToAddr(rowLast + 1,colLast + 1)
61 | return ..string.concat(addrStart,":",addrEnd);
62 | }
63 | return ..libxl.cellRange(rowFirst + 1, rowLast + 1, colFirst + 1,colLast + 1);
64 | }
65 | getSortRange = function(addr){
66 | var result,rowFirst,rowLast,colFirst,colLast = GetSortRange(owner.hwnd,0,0,0,0);
67 | if !result return null;
68 | if addr{
69 | var addrStart = ..libxl.Sheet.rowColToAddr(rowFirst,colFirst)
70 | var addrEnd = ..libxl.Sheet.rowColToAddr(rowLast,colLast)
71 | return ..string.concat(addrStart,":",addrEnd);
72 | }
73 | return ..libxl.cellRange(rowFirst, rowLast, colFirst,colLast);
74 | }
75 | getSort = function(){
76 | var result,columnIndex,descending = GetSort(owner.hwnd,0,0);
77 | if !result return null;
78 | return columnIndex,descending;
79 | }
80 | setSort = function(columnIndex,descending){
81 | return SetSort(owner.hwnd,columnIndex,descending);
82 | }
83 |
84 | column = getColumn;
85 | )
86 |
87 | GetRef = libxl32.api("xlAutoFilterGetRef","int(ptr AutoFilterHandle, int& rowFirst, int& rowLast, int& colFirst, int& colLast)");
88 | SetRef = libxl32.api("xlAutoFilterSetRef","void(ptr AutoFilterHandle, int rowFirst, int rowLast, int colFirst, int colLast)");
89 |
90 | ColumnSize = libxl32.api("xlAutoFilterColumnSize","int(ptr AutoFilterHandle)");
91 |
92 | Column = libxl32.api("xlAutoFilterColumn","ptr(ptr AutoFilterHandle, int colId)");//FilterColumnHandle
93 | ColumnByIndex = libxl32.api("xlAutoFilterColumnByIndex","ptr(ptr AutoFilterHandle, int index)");//FilterColumnHandle
94 |
95 | GetSortRange = libxl32.api("xlAutoFilterGetSortRange","int(ptr AutoFilterHandle, int& rowFirst, int& rowLast, int& colFirst, int& colLast)");
96 | GetSort = libxl32.api("xlAutoFilterGetSort","int(ptr AutoFilterHandle, int& columnIndex, int& descending)");
97 | SetSort = libxl32.api("xlAutoFilterSetSort","int(ptr AutoFilterHandle, int columnIndex, int descending)");
98 |
99 | }
100 |
101 |
102 | /**intellisense()
103 | !xlSheet.autoFilter() = !xlAutoFilter.
104 | !xlAutoFilter.ref = 设置或返回筛选区域
105 | !xlAutoFilter.columnNum = 筛选区域列数
106 | !xlAutoFilter.sortRange = 获取排序区域
107 | !xlAutoFilter.getColumn(.(列数,[是否相对位置]) = 返回筛选列对象
108 | end intellisense**/
--------------------------------------------------------------------------------
/demo/lib/libxl/book.aardio:
--------------------------------------------------------------------------------
1 | namespace libxl;
2 |
3 | var libxl32 = _dll;
4 |
5 | namespace Book{
6 |
7 | Load = libxl32.api("xlBookLoad","bool(ptr BookHandle, ustring filename)")
8 | Save = libxl32.api("xlBookSave","bool(ptr BookHandle, ustring filename)")
9 |
10 | LoadRaw = libxl32.api("xlBookLoadRaw","bool(ptr BookHandle, string data, INT size)")
11 | SaveRaw = libxl32.api("xlBookSaveRaw","bool(ptr BookHandle, pointer& data, INT& size)")
12 |
13 | AddSheet = libxl32.api("xlBookAddSheet","ptr(ptr BookHandle, ustring name, ptr initSheet)") //SheetHandle
14 | InsertSheet = libxl32.api("xlBookInsertSheet","ptr(ptr BookHandle, int index, ustring name, ptr initSheet)") //SheetHandle
15 | GetSheet = libxl32.api("xlBookGetSheet","ptr(ptr BookHandle, int index)") //SheetHandle
16 | SheetType = libxl32.api("xlBookSheetType","int(ptr BookHandle, int index)")
17 | DelSheet = libxl32.api("xlBookDelSheet","int(ptr BookHandle, int index)")
18 | SheetCount = libxl32.api("xlBookSheetCount","int(ptr BookHandle)")
19 |
20 | AddFormat = libxl32.api("xlBookAddFormat","ptr(ptr BookHandle, ptr initFormat)") //FormatHandle,initFormat为ptr
21 | AddFont = libxl32.api("xlBookAddFont","ptr(ptr BookHandle, ptr initFont)") //FontHandle,initFont为ptr
22 |
23 | Format = libxl32.api("xlBookFormat","ptr(ptr BookHandle, int index)")//FormatHandle,
24 | FormatSize = libxl32.api("xlBookFormatSize","int(ptr BookHandle)")
25 | Font = libxl32.api("xlBookFont","ptr(ptr BookHandle, int index)")//FontHandle,
26 | FontSize = libxl32.api("xlBookFontSize","int(ptr BookHandle)")
27 |
28 | ActiveSheet = libxl32.api("xlBookActiveSheet","int(ptr BookHandle)")
29 | SetActiveSheet = libxl32.api("xlBookSetActiveSheet","void(ptr BookHandle, int index)")
30 | PictureSize = libxl32.api("xlBookPictureSize","int(ptr BookHandle)")
31 | GetPicture = libxl32.api("xlBookGetPicture","int(ptr BookHandle, int index, pointer& data, INT& size)")
32 | AddPicture = libxl32.api("xlBookAddPicture","int(ptr BookHandle, ustring filename)")
33 | AddPicture2 = libxl32.api("xlBookAddPicture2","int(ptr BookHandle, ustring data, INT size)")
34 |
35 | DefaultFont = libxl32.api("xlBookDefaultFont","ustring(ptr BookHandle, INT& fontSize)")
36 | SetDefaultFont = libxl32.api("xlBookSetDefaultFont","void(ptr BookHandle, ustring fontName, INT fontSize)")
37 |
38 | RgbMode = libxl32.api("xlBookRgbMode","int(ptr BookHandle)")
39 | SetRgbMode = libxl32.api("xlBookSetRgbMode","void(ptr BookHandle, BYTE rgbMode)")
40 | RefR1C1 = libxl32.api("xlBookRefR1C1","int(ptr BookHandle)")
41 | SetRefR1C1 = libxl32.api("xlBookSetRefR1C1","void(ptr BookHandle, BYTE refR1C1)")
42 | BiffVersion = libxl32.api("xlBookBiffVersion","int(ptr BookHandle)")
43 | IsDate1904 = libxl32.api("xlBookIsDate1904","int(ptr BookHandle)")
44 | SetDate1904 = libxl32.api("xlBookSetDate1904","void(ptr BookHandle, BYTE date1904)")
45 | IsTemplate = libxl32.api("xlBookIsTemplate","int(ptr BookHandle)")
46 | SetTemplate = libxl32.api("xlBookSetTemplate","void(ptr BookHandle, int tmpl)")
47 | SetKey = libxl32.api("xlBookSetKey","void(ptr BookHandle, ustring name, ustring key)")
48 | SetLocale = libxl32.api("xlBookSetLocale","int(ptr BookHandle, string locale)")
49 | ErrorMessage = libxl32.api("xlBookErrorMessage","ptr(ptr BookHandle)")
50 |
51 | AddCustomNumFormat = libxl32.api("xlBookAddCustomNumFormat","int(ptr BookHandle, ustring customNumFormat)")
52 | CustomNumFormat = libxl32.api("xlBookCustomNumFormat", "ustring(ptr BookHandle,int fmt)")
53 | DatePack = libxl32.api("xlBookDatePack","double(ptr BookHandle,int year, int month, int day,int hour, int min, int sec, int msec)")
54 | DateUnpack = libxl32.api("xlBookDateUnpack","bool(ptr BookHandle, double value,int& year, int& month, int& day,int& hour, int& min, int& sec, int& msec)")
55 | ColorPack = libxl32.api("xlBookColorPack","int(ptr BookHandle, int red, int green, int blue)")
56 | ColorUnpack = libxl32.api("xlBookColorUnpack","void(ptr BookHandle, int color, int& red, int& green, int& blue)")
57 |
58 | MoveSheet = libxl32.api("xlBookMoveSheet","int(ptr BookHandle, int srcIndex, int dstIndex)");
59 | AddPictureAsLink = libxl32.api("xlBookAddPictureAsLink","int(ptr BookHandle, ustring& filename, int insert)");
60 | LoadUsingTempFile = libxl32.api("xlBookLoadUsingTempFile","int(ptr BookHandle, ustring& filename, ustring& tempFile)");
61 | SaveUsingTempFile = libxl32.api("xlBookSaveUsingTempFile","int(ptr BookHandle, ustring& filename, int useTempFile)");
62 | LoadPartially = libxl32.api("xlBookLoadPartially","int(ptr BookHandle, ustring& filename, int sheetIndex, int firstRow, int lastRow)");
63 | LoadPartiallyUsingTempFile = libxl32.api("xlBookLoadPartiallyUsingTempFile","int(ptr BookHandle, ustring& filename, int sheetIndex, int firstRow, int lastRow, ustring& tempFile)");
64 | }
65 |
66 | /**intellisense()
67 | _SHEETTYPE_SHEET=@0/*_SHEETTYPE_SHEET*/
68 | _SHEETTYPE_CHART=@1/*_SHEETTYPE_CHART*/
69 | _SHEETTYPE_UNKNOW=@2/*_SHEETTYPE_UNKNOW*/
70 | !libxl().Book = !xlBook.
71 | !xlBook.Load(.(ptr,filename,tempfile) = 插入行
72 | end intellisense**/
--------------------------------------------------------------------------------
/demo/lib/libxl/filtercolumn.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class FilterColumn{
8 | ctor( hwnd ){
9 | if !hwnd return null,"请指定自动筛选句柄";
10 | this.hwnd = hwnd;
11 | };
12 | @_metaProperty;
13 | }
14 |
15 |
16 | namespace FilterColumn{
17 | _metaProperty = ..util.metaProperty(
18 | index = {
19 | _get = function(){
20 | return Index(owner.hwnd) + 1;
21 | }
22 | }
23 | filterType = {
24 | _get = function(){
25 | return FilterType(owner.hwnd);
26 | }
27 | }
28 | filterSize = {
29 | _get = function(){
30 | return FilterSize(owner.hwnd);
31 | }
32 | }
33 | filterText = {
34 | _set = function(v){
35 | owner.setFilter(v);
36 | }
37 | }
38 | value = function(index){//按作者的习惯,不应该只有str类型的
39 | return Filter(owner.hwnd,index -1);
40 | }
41 | setFilter = function(v){
42 | //if type(v) != type.string v = tostring(v);
43 | AddFilter(owner.hwnd,v);
44 | }
45 | getTop10 = function(){
46 | var result,value,top,percent = GetTop10(owner.hwnd,0,false,false);
47 | if !result return null;
48 | return value,top,percent; //不知道是什么鬼,不处理了
49 | }
50 | setTop10 = function(value,top = true,percent = false){
51 | SetTop10(owner.hwnd,value,top,percent);
52 | }
53 | getCustomFilter = function(){
54 | var str = /*{ustring text[1024]}*/
55 | var result,v1_type,v1_ptr,v2_type,v2_ptr,option = GetCustomFilter(owner.hwnd,0,,0,,false)
56 | if !result return null;
57 | var v1,v2 = ..raw.convert(v1_ptr,str),..raw.convert(v2_ptr,str);
58 | return v1_type,v1,v2_type,v2,option;
59 | }
60 | setCustomFilter = function(v1_type,v1,v2_type,v2,option = false){ //默认为‘或’
61 | if v2 == null{
62 | return SetCustomFilter(owner.hwnd,v1_type,v1);
63 | }
64 | SetCustomFilterEx(owner.hwnd,v1_type,v1,v2_type,v2,option);
65 | }
66 | clear = function(){
67 | Clear(owner.hwnd);
68 | }
69 |
70 | //增加关键字
71 | Type = filterType;//由于是关键字,只能大写了
72 | count = filterSize;
73 | filter = filterText;
74 | )
75 |
76 |
77 | Index = libxl32.api("xlFilterColumnIndex","int(ptr FilterColumnHandle)");
78 |
79 | FilterType = libxl32.api("xlFilterColumnFilterType","int(ptr FilterColumnHandle)");
80 |
81 | FilterSize = libxl32.api("xlFilterColumnFilterSize","int(ptr FilterColumnHandle)");
82 | Filter = libxl32.api("xlFilterColumnFilter","ustring(ptr FilterColumnHandle, int index)");
83 |
84 | AddFilter = libxl32.api("xlFilterColumnAddFilter","void(ptr FilterColumnHandle,ustring value)");
85 |
86 | GetTop10 = libxl32.api("xlFilterColumnGetTop10","int(ptr FilterColumnHandle, double& value, bool& top, bool& percent)");
87 | SetTop10 = libxl32.api("xlFilterColumnSetTop10","void(ptr FilterColumnHandle, double value, bool top, bool percent)");
88 |
89 | GetCustomFilter = libxl32.api("xlFilterColumnGetCustomFilter","int(ptr FilterColumnHandle, int& op1, ptr& v1, int& op2, ptr& v2, bool& andOp)");
90 | SetCustomFilter = libxl32.api("xlFilterColumnSetCustomFilter","void(ptr FilterColumnHandle, int op, ustring val)");
91 | SetCustomFilterEx = libxl32.api("xlFilterColumnSetCustomFilterEx","void(ptr FilterColumnHandle, int op1, ustring v1, int op2, ustring v2, bool andOp)");
92 |
93 | Clear = libxl32.api("xlFilterColumnClear","void(ptr FilterColumnHandle)");
94 | }
95 |
96 | /**intellisense()
97 | libxl.FilterColumn() = !xlFilterColumn.
98 | !xlAutoFilter.getColumn() = !xlFilterColumn.
99 | !xlFilterColumn.index = 返回当前筛选所在列
100 | !xlFilterColumn.filterType = 返回当前筛选类型
101 | !xlFilterColumn.filterSize = 返回当前筛选行数
102 | !xlFilterColumn.filterText = 设置筛选值(文本)
103 | !xlFilterColumn.value(.(行数N) = 筛选中第N行的值
104 | !xlFilterColumn.setFilter(.(文本) = 设置筛选值
105 | !xlFilterColumn.GetTop10(.() = 前十值,有三个参数返回
106 | !xlFilterColumn.getCustomFilter(.() = 返回自定义筛选值,分别为 条件1类型,条件1,条件2类型,条件2,与或关系
107 | !xlFilterColumn.setCustomFilter(.(条件1类型,条件1,[条件2类型],[条件2],[与或关系]) = 设置自定义筛选
108 | !xlFilterColumn.clear() = 清除筛选
109 | _FILTER_VALUE=@0/*_FILTER_VALUE*/
110 | _FILTER_TOP10=@1/*_FILTER_TOP10*/
111 | _FILTER_CUSTOM=@2/*_FILTER_CUSTOM*/
112 | _FILTER_DYNAMIC=@3/*_FILTER_DYNAMIC*/
113 | _FILTER_COLOR=@4/*_FILTER_COLOR*/
114 | _FILTER_ICON=@5/*_FILTER_ICON*/
115 | _FILTER_EXT=@6/*_FILTER_EXT*/
116 | _FILTER_NOT_SET=@7/*_FILTER_NOT_SET*/
117 | _OPERATOR_EQUAL=@0/*_OPERATOR_EQUAL*/
118 | _OPERATOR_GREATER_THAN=@1/*_OPERATOR_GREATER_THAN*/
119 | _OPERATOR_GREATER_THAN_OR_EQUAL=@2/*_OPERATOR_GREATER_THAN_OR_EQUAL*/
120 | _OPERATOR_LESS_THAN=@3/*_OPERATOR_LESS_THAN*/
121 | _OPERATOR_LESS_THAN_OR_EQUAL=@4/*_OPERATOR_LESS_THAN_OR_EQUAL*/
122 | _OPERATOR_NOT_EQUAL=@5/*_OPERATOR_NOT_EQUAL*/
123 | end intellisense**/
--------------------------------------------------------------------------------
/demo/lib/libxl/font.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class Font{
8 | ctor( hwnd ){
9 | if !hwnd return null,"请指定字体句柄";
10 | this.hwnd = hwnd;
11 | };
12 | @_metaProperty;
13 | }
14 |
15 | namespace Font{
16 | _metaProperty = ..util.metaProperty(
17 | size = {
18 | _get = function(){
19 | return Size(owner.hwnd);
20 | };
21 | _set = function( v ){
22 | SetSize(owner.hwnd,v);
23 | };
24 | };
25 | italic = {
26 | _get = function(){
27 | return Italic(owner.hwnd);
28 | };
29 | _set = function( v ){
30 | SetItalic(owner.hwnd,v);
31 | };
32 | };
33 | strikeOut = {
34 | _get = function(){
35 | return StrikeOut(owner.hwnd);
36 | };
37 | _set = function( v ){
38 | SetStrikeOut(owner.hwnd,v);
39 | };
40 | };
41 | color = {
42 | _get = function(){
43 | return Color(owner.hwnd);
44 | };
45 | _set = function( v ){
46 | SetColor(owner.hwnd,v);
47 | };
48 | };
49 | bold = {
50 | _get = function(){
51 | return Bold(owner.hwnd);
52 | };
53 | _set = function( v ){
54 | SetBold(owner.hwnd,tonumber(v));
55 | };
56 | };
57 | script = {
58 | _get = function(){
59 | return Script(owner.hwnd);
60 | };
61 | _set = function( v ){
62 | SetScript(owner.hwnd,v);
63 | };
64 | };
65 | underLine = {
66 | _get = function(){
67 | return Underline(owner.hwnd);
68 | };
69 | _set = function( v ){
70 | SetUnderline(owner.hwnd,v);
71 | };
72 | };
73 | name = {
74 | _get = function(){
75 | return Name(owner.hwnd);
76 | };
77 | _set = function( v ){
78 | SetName(owner.hwnd,v);
79 | };
80 | };
81 | )
82 |
83 | Size = libxl32.api("xlFontSize","int(ptr FontHandle)")
84 | SetSize = libxl32.api("xlFontSetSize","void(ptr FontHandle, int size)")
85 |
86 | Italic = libxl32.api("xlFontItalic","int(ptr FontHandle)")
87 | SetItalic = libxl32.api("xlFontSetItalic","void(ptr FontHandle, int italic)")
88 |
89 | StrikeOut = libxl32.api("xlFontStrikeOut","int(ptr FontHandle)")
90 | SetStrikeOut = libxl32.api("xlFontSetStrikeOut","void(ptr FontHandle, int strikeOut)")
91 |
92 | Color = libxl32.api("xlFontColor","int(ptr FontHandle)")
93 | SetColor = libxl32.api("xlFontSetColor","void(ptr FontHandle, int color)")
94 |
95 | Bold = libxl32.api("xlFontBold","int(ptr FontHandle)")
96 | SetBold = libxl32.api("xlFontSetBold","void(ptr FontHandle, int bold)")
97 |
98 | Script = libxl32.api("xlFontScript","int(ptr FontHandle)")
99 | SetScript = libxl32.api("xlFontSetScript","void(ptr FontHandle, int script)")
100 |
101 | Underline = libxl32.api("xlFontUnderline","int(ptr FontHandle)")
102 | SetUnderline = libxl32.api("xlFontSetUnderline","void(ptr FontHandle, int underline)")
103 |
104 | Name = libxl32.api("xlFontName","ustring(ptr FontHandle)")
105 | SetName = libxl32.api("xlFontSetName","int(ptr FontHandle, ustring name)")
106 |
107 | }
108 |
109 | /**intellisense()
110 | libxl.Format() = !xlFont.
111 | !libxl.Format() = !xlFont.
112 | !libxl.addFont() = !xlFont.
113 | !xlFont.size = 字号
114 | !xlFont.italic = 斜体
115 | !xlFont.strikeOut = 删除线
116 | !xlFont.color = 颜色,_COLOR_
117 | !xlFont.bold = 粗体
118 | !xlFont.script = 小字符样式,_SCRIPT_
119 | !xlFont.underLine = 下划线,_UNDERLINE_
120 | !xlFont.name = 字体
121 | _COLOR_BLACK=@8/*_COLOR_BLACK*/
122 | _COLOR_WHITE=@9/*_COLOR_WHITE*/
123 | _COLOR_RED=@10/*_COLOR_RED*/
124 | _COLOR_BRIGHTGREEN=@11/*_COLOR_BRIGHTGREEN*/
125 | _COLOR_BLUE=@12/*_COLOR_BLUE*/
126 | _COLOR_YELLOW=@13/*_COLOR_YELLOW*/
127 | _COLOR_PINK=@14/*_COLOR_PINK*/
128 | _COLOR_TURQUOISE=@15/*_COLOR_TURQUOISE*/
129 | _COLOR_DARKRED=@16/*_COLOR_DARKRED*/
130 | _COLOR_GREEN=@17/*_COLOR_GREEN*/
131 | _COLOR_DARKBLUE=@18/*_COLOR_DARKBLUE*/
132 | _COLOR_DARKYELLOW=@19/*_COLOR_DARKYELLOW*/
133 | _COLOR_VIOLET=@20/*_COLOR_VIOLET*/
134 | _COLOR_TEAL=@21/*_COLOR_TEAL*/
135 | _COLOR_GRAY25=@22/*_COLOR_GRAY25*/
136 | _COLOR_GRAY50=@23/*_COLOR_GRAY50*/
137 | _COLOR_PERIWINKLE_CF=@24/*_COLOR_PERIWINKLE_CF*/
138 | _COLOR_PLUM_CF=@25/*_COLOR_PLUM_CF*/
139 | _COLOR_IVORY_CF=@26/*_COLOR_IVORY_CF*/
140 | _COLOR_LIGHTTURQUOISE_CF=@27/*_COLOR_LIGHTTURQUOISE_CF*/
141 | _COLOR_DARKPURPLE_CF=@28/*_COLOR_DARKPURPLE_CF*/
142 | _COLOR_CORAL_CF=@29/*_COLOR_CORAL_CF*/
143 | _COLOR_OCEANBLUE_CF=@30/*_COLOR_OCEANBLUE_CF*/
144 | _COLOR_ICEBLUE_CF=@31/*_COLOR_ICEBLUE_CF*/
145 | _COLOR_DARKBLUE_CL=@32/*_COLOR_DARKBLUE_CL*/
146 | _COLOR_PINK_CL=@33/*_COLOR_PINK_CL*/
147 | _COLOR_YELLOW_CL=@34/*_COLOR_YELLOW_CL*/
148 | _COLOR_TURQUOISE_CL=@35/*_COLOR_TURQUOISE_CL*/
149 | _COLOR_VIOLET_CL=@36/*_COLOR_VIOLET_CL*/
150 | _COLOR_DARKRED_CL=@37/*_COLOR_DARKRED_CL*/
151 | _COLOR_TEAL_CL=@38/*_COLOR_TEAL_CL*/
152 | _COLOR_BLUE_CL=@39/*_COLOR_BLUE_CL*/
153 | _COLOR_SKYBLUE=@40/*_COLOR_SKYBLUE*/
154 | _COLOR_LIGHTTURQUOISE=@41/*_COLOR_LIGHTTURQUOISE*/
155 | _COLOR_LIGHTGREEN=@42/*_COLOR_LIGHTGREEN*/
156 | _COLOR_LIGHTYELLOW=@43/*_COLOR_LIGHTYELLOW*/
157 | _COLOR_PALEBLUE=@44/*_COLOR_PALEBLUE*/
158 | _COLOR_ROSE=@45/*_COLOR_ROSE*/
159 | _COLOR_LAVENDER=@46/*_COLOR_LAVENDER*/
160 | _COLOR_TAN=@47/*_COLOR_TAN*/
161 | _COLOR_LIGHTBLUE=@48/*_COLOR_LIGHTBLUE*/
162 | _COLOR_AQUA=@49/*_COLOR_AQUA*/
163 | _COLOR_LIME=@50/*_COLOR_LIME*/
164 | _COLOR_GOLD=@51/*_COLOR_GOLD*/
165 | _COLOR_LIGHTORANGE=@52/*_COLOR_LIGHTORANGE*/
166 | _COLOR_ORANGE=@53/*_COLOR_ORANGE*/
167 | _COLOR_BLUEGRAY=@54/*_COLOR_BLUEGRAY*/
168 | _COLOR_GRAY40=@55/*_COLOR_GRAY40*/
169 | _COLOR_DARKTEAL=@56/*_COLOR_DARKTEAL*/
170 | _COLOR_SEAGREEN=@57/*_COLOR_SEAGREEN*/
171 | _COLOR_DARKGREEN=@58/*_COLOR_DARKGREEN*/
172 | _COLOR_OLIVEGREEN=@59/*_COLOR_OLIVEGREEN*/
173 | _COLOR_BROWN=@60/*_COLOR_BROWN*/
174 | _COLOR_PLUM=@61/*_COLOR_PLUM*/
175 | _COLOR_INDIGO=@62/*_COLOR_INDIGO*/
176 | _COLOR_GRAY80=@63/*_COLOR_GRAY80*/
177 | _COLOR_DEFAULT_FOREGROUND=@64/*_COLOR_DEFAULT_FOREGROUND*/
178 | _COLOR_DEFAULT_BACKGROUND=@65/*_COLOR_DEFAULT_BACKGROUND*/
179 | _UNDERLINE_NONE=@0/*_UNDERLINE_NONE*/
180 | _UNDERLINE_SINGLE=@1/*_UNDERLINE_SINGLE*/
181 | _UNDERLINE_DOUBLE=@2/*_UNDERLINE_DOUBLE*/
182 | _UNDERLINE_SINGLEACC=@3/*_UNDERLINE_SINGLEACC*/
183 | _UNDERLINE_DOUBLEACC=@4/*_UNDERLINE_DOUBLEACC*/
184 | _SCRIPT_NORMAL=@0/*_SCRIPT_NORMAL*/
185 | _SCRIPT_SUPER=@1/*_SCRIPT_SUPER*/
186 | _SCRIPT_SUB=@2/*_SCRIPT_SUB*/
187 | end intellisense**/
--------------------------------------------------------------------------------
/demo/lib/libxl/format.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class Format{
8 | ctor( hwnd,p_shformat ){
9 | if !hwnd return null,"请指定格式句柄";
10 | this.hwnd = hwnd;
11 | this.p_shformat = p_shformat;
12 | };
13 | @_metaProperty;
14 | }
15 |
16 | namespace Format{
17 | _metaProperty = ..util.metaProperty(
18 | font = {
19 | _get = function(){
20 | var hwnd = Font(owner.hwnd)
21 | if !hwnd return hwnd;
22 | var s_font = owner.p_shformat.Fonts(hwnd);
23 | return s_font;
24 | };
25 | _set = function( fonts ){
26 | var hFont = fonts;
27 | if type(fonts) == type.table hFont = fonts.hwnd
28 | if !owner.p_shformat.Fonts[tonumber(hFont)]{
29 | hFont = owner.p_shformat.book.addFont(hFont).hwnd
30 | }
31 | return SetFont(owner.hwnd,hFont);
32 | };
33 | };
34 | numStyle = {
35 | _get = function(){
36 | return (NumFormat(owner.hwnd)+1);
37 | };
38 | _set = function( v ){
39 | SetNumFormat(owner.hwnd,v - 1);
40 | };
41 | };
42 | alignH = {
43 | _get = function(){
44 | return AlignH(owner.hwnd);
45 | };
46 | _set = function( v ){
47 | SetAlignH(owner.hwnd,v);
48 | };
49 | };
50 | alignV = {
51 | _get = function(){
52 | return AlignV(owner.hwnd);
53 | };
54 | _set = function( v ){
55 | SetAlignV(owner.hwnd,v);
56 | };
57 | };
58 | wrap = {
59 | _get = function(){
60 | return Wrap(owner.hwnd);
61 | };
62 | _set = function( v ){
63 | SetWrap(owner.hwnd,tonumber(v));
64 | };
65 | };
66 | rotation = {
67 | _get = function(){
68 | return Rotation(owner.hwnd);
69 | };
70 | _set = function( v ){
71 | return SetRotation(owner.hwnd,v);
72 | };
73 | };
74 | indent = {
75 | _get = function(){
76 | return Indent(owner.hwnd);
77 | };
78 | _set = function( v ){
79 | return SetIndent(owner.hwnd,v);
80 | };
81 | };
82 | fit = {
83 | _get = function(){
84 | return ShrinkToFit(owner.hwnd);
85 | };
86 | _set = function( v ){
87 | return SetShrinkToFit(owner.hwnd,tonumber(v));
88 | };
89 | };
90 | shrinkToFit = {
91 | _get = function(){
92 | return ShrinkToFit(owner.hwnd);
93 | };
94 | _set = function( v ){
95 | return SetShrinkToFit(owner.hwnd,tonumber(v));
96 | };
97 | };
98 | borderStyle = {
99 | _get = function(){
100 | return null;
101 | };
102 | _set = function(v){
103 | SetBorder(owner.hwnd,v);
104 | };
105 | };
106 | borderColor = {
107 | _get = function(){
108 | return null;
109 | };
110 | _set = function( v ){
111 | SetBorderColor(owner.hwnd,v);
112 | };
113 | };
114 | borderLeft = {
115 | _get = function(){
116 | return BorderLeft(owner.hwnd);
117 | };
118 | _set = function( v ){
119 | SetBorderLeft(owner.hwnd,v);
120 | };
121 | };
122 | borderRight = {
123 | _get = function(){
124 | return BorderRight(owner.hwnd);
125 | };
126 | _set = function( v ){
127 | SetBorderRight(owner.hwnd,v);
128 | };
129 | };
130 | borderTop = {
131 | _get = function(){
132 | return BorderTop(owner.hwnd);
133 | };
134 | _set = function( v ){
135 | SetBorderTop(owner.hwnd,v);
136 | };
137 | };
138 | borderBottom = {
139 | _get = function(){
140 | return BorderBottom(owner.hwnd);
141 | };
142 | _set = function( v ){
143 | SetBorderBottom(owner.hwnd,v);
144 | };
145 | };
146 | borderLeftColor = {
147 | _get = function(){
148 | return BorderLeftColor(owner.hwnd);
149 | };
150 | _set = function( v ){
151 | SetBorderLeftColor(owner.hwnd,v);
152 | };
153 | };
154 | borderRightColor = {
155 | _get = function(){
156 | return BorderRightColor(owner.hwnd);
157 | };
158 | _set = function( v ){
159 | SetBorderRightColor(owner.hwnd,v);
160 | };
161 | };
162 | borderTopColor = {
163 | _get = function(){
164 | return BorderTopColor(owner.hwnd);
165 | };
166 | _set = function( v ){
167 | SetBorderTopColor(owner.hwnd,v);
168 | };
169 | };
170 | borderBottomColor = {
171 | _get = function(){
172 | return BorderBottomColor(owner.hwnd);
173 | };
174 | _set = function( v ){
175 | SetBorderBottomColor(owner.hwnd,v);
176 | };
177 | };
178 | borderDiagonal = {
179 | _get = function(){
180 | return BorderDiagonal(owner.hwnd);
181 | };
182 | _set = function( v ){
183 | SetBorderDiagonal(owner.hwnd,v);
184 | };
185 | };
186 | borderDiagonalStyle = {
187 | _get = function(){
188 | return BorderDiagonalStyle(owner.hwnd);
189 | };
190 | _set = function( v ){
191 | SetBorderDiagonalStyle(owner.hwnd,v);
192 | };
193 | };
194 | borderDiagonalColor = {
195 | _get = function(){
196 | return BorderDiagonalColor(owner.hwnd);
197 | };
198 | _set = function( v ){
199 | SetBorderDiagonalColor(owner.hwnd,v);
200 | };
201 | };
202 | pattern = {
203 | _get = function(){
204 | return FillPattern(owner.hwnd);
205 | };
206 | _set = function( v ){
207 | SetFillPattern(owner.hwnd,v);
208 | };
209 | };
210 | patternForeColor = {
211 | _get = function(){
212 | return PatternForegroundColor(owner.hwnd);
213 | };
214 | _set = function( v ){
215 | SetPatternForegroundColor(owner.hwnd,v);
216 | };
217 | };
218 | patternBackColor = {
219 | _get = function(){
220 | return PatternBackgroundColor(owner.hwnd);
221 | };
222 | _set = function( v ){
223 | SetPatternBackgroundColor(owner.hwnd,v);
224 | };
225 | };
226 | lock = {
227 | _get = function(){
228 | return Locked(owner.hwnd);
229 | };
230 | _set = function( v ){
231 | SetLocked(owner.hwnd,tonumber(v));
232 | };
233 | };
234 | hidden = {
235 | _get = function(){
236 | return Hidden(owner.hwnd);
237 | };
238 | _set = function( v ){
239 | SetHidden(owner.hwnd,tonumber(v));
240 | };
241 | };
242 | )
243 |
244 |
245 | Font = libxl32.api("xlFormatFont","ptr(ptr FormatHandle)")//FontHandle
246 | SetFont = libxl32.api("xlFormatSetFont","int(ptr FormatHandle, ptr ))")
247 |
248 | NumFormat = libxl32.api("xlFormatNumFormat","int(ptr FormatHandle)")
249 | SetNumFormat = libxl32.api("xlFormatSetNumFormat","void(ptr FormatHandle, int numFormat)")
250 |
251 | AlignH = libxl32.api("xlFormatAlignH","int(ptr FormatHandle)")
252 | SetAlignH = libxl32.api("xlFormatSetAlignH","void(ptr FormatHandle, int align)")
253 | AlignV = libxl32.api("xlFormatAlignV","int(ptr FormatHandle)")
254 | SetAlignV = libxl32.api("xlFormatSetAlignV","void(ptr FormatHandle, int align)")
255 |
256 | Wrap = libxl32.api("xlFormatWrap","int(ptr FormatHandle)")
257 | SetWrap = libxl32.api("xlFormatSetWrap","void(ptr FormatHandle, int wrap)")
258 |
259 | Rotation = libxl32.api("xlFormatRotation","int(ptr FormatHandle)")
260 | SetRotation = libxl32.api("xlFormatSetRotation","int(ptr FormatHandle, int rotation)")
261 |
262 | Indent = libxl32.api("xlFormatIndent","int(ptr FormatHandle)")
263 | SetIndent = libxl32.api("xlFormatSetIndent","void(ptr FormatHandle, int indent)")
264 |
265 | ShrinkToFit = libxl32.api("xlFormatShrinkToFit","int(ptr FormatHandle)")
266 | SetShrinkToFit = libxl32.api("xlFormatSetShrinkToFit","void(ptr FormatHandle, int shrinkToFit)")
267 |
268 | SetBorder = libxl32.api("xlFormatSetBorder","void(ptr FormatHandle, int style)")
269 | SetBorderColor = libxl32.api("xlFormatSetBorderColor","void(ptr FormatHandle, int color)")
270 | BorderLeft = libxl32.api("xlFormatBorderLeft","int(ptr FormatHandle)")
271 | SetBorderLeft = libxl32.api("xlFormatSetBorderLeft","void(ptr FormatHandle, int style)")
272 | BorderRight = libxl32.api("xlFormatBorderRight","int(ptr FormatHandle)")
273 | SetBorderRight = libxl32.api("xlFormatSetBorderRight","void(ptr FormatHandle, int style)")
274 | BorderTop = libxl32.api("xlFormatBorderTop","int(ptr FormatHandle)")
275 | SetBorderTop = libxl32.api("xlFormatSetBorderTop","void(ptr FormatHandle, int style)")
276 | BorderBottom = libxl32.api("xlFormatBorderBottom","int(ptr FormatHandle)")
277 | SetBorderBottom = libxl32.api("xlFormatSetBorderBottom","void(ptr FormatHandle, int style)")
278 |
279 | BorderLeftColor = libxl32.api("xlFormatBorderLeftColor","int(ptr FormatHandle)")
280 | SetBorderLeftColor = libxl32.api("xlFormatSetBorderLeftColor","void(ptr FormatHandle, int color)")
281 | BorderRightColor = libxl32.api("xlFormatBorderRightColor","int(ptr FormatHandle)")
282 | SetBorderRightColor = libxl32.api("xlFormatSetBorderRightColor","void(ptr FormatHandle, int color)")
283 | BorderTopColor = libxl32.api("xlFormatBorderTopColor","int(ptr FormatHandle)")
284 | SetBorderTopColor = libxl32.api("xlFormatSetBorderTopColor","void(ptr FormatHandle, int color)")
285 | BorderBottomColor = libxl32.api("xlFormatBorderBottomColor","int(ptr FormatHandle)")
286 | SetBorderBottomColor = libxl32.api("xlFormatSetBorderBottomColor","void(ptr FormatHandle, int color)")
287 |
288 | BorderDiagonal = libxl32.api("xlFormatBorderDiagonal","int(ptr FormatHandle)")
289 | SetBorderDiagonal = libxl32.api("xlFormatSetBorderDiagonal","void(ptr FormatHandle, int border)")
290 | BorderDiagonalStyle = libxl32.api("xlFormatBorderDiagonalStyle","int(ptr FormatHandle)")
291 | SetBorderDiagonalStyle = libxl32.api("xlFormatSetBorderDiagonalStyle","void(ptr FormatHandle, int style)")
292 | BorderDiagonalColor = libxl32.api("xlFormatBorderDiagonalColor","int(ptr FormatHandle)")
293 | SetBorderDiagonalColor = libxl32.api("xlFormatSetBorderDiagonalColor","void(ptr FormatHandle, int color)")
294 |
295 | FillPattern = libxl32.api("xlFormatFillPattern","int(ptr FormatHandle)")
296 | SetFillPattern = libxl32.api("xlFormatSetFillPattern","void(ptr FormatHandle, int pattern)")
297 | PatternForegroundColor = libxl32.api("xlFormatPatternForegroundColor","int(ptr FormatHandle)")
298 | SetPatternForegroundColor = libxl32.api("xlFormatSetPatternForegroundColor","void(ptr FormatHandle, int color)")
299 | PatternBackgroundColor = libxl32.api("xlFormatPatternBackgroundColor","int(ptr FormatHandle)")
300 | SetPatternBackgroundColor = libxl32.api("xlFormatSetPatternBackgroundColor","void(ptr FormatHandle, int color)")
301 |
302 | Locked = libxl32.api("xlFormatLocked","int(ptr FormatHandle)")
303 | SetLocked = libxl32.api("xlFormatSetLocked","void(ptr FormatHandle, int locked)")
304 |
305 | Hidden = libxl32.api("xlFormatHidden","int(ptr FormatHandle)")
306 | SetHidden = libxl32.api("xlFormatSetHidden","void(ptr FormatHandle, int hidden)")
307 |
308 | }
309 |
310 | /**intellisense()
311 | libxl.Format() = !xlFormat.
312 | !libxl.Format() = !xlFormat.
313 | !libxl.addFormat() = !xlFormat.
314 | !xlFormat.font = 字体
315 | !xlFormat.font = !xlFont.
316 | !xlFormat.numStyle = 数字格式,_NUMFORMAT_
317 | !xlFormat.alignH = 水平对齐样式,_ALIGNH_
318 | !xlFormat.alignV = 垂直对齐样式,_ALIGNV
319 | !xlFormat.wrap = 环绕
320 | !xlFormat.rotation = 旋转角度,默认255
321 | !xlFormat.indent = 凹陷程度,小于等于15
322 | !xlFormat.fit = 自适应宽度
323 | !xlFormat.shrinkToFit = 自适应宽度
324 | !xlFormat.borderStyle = 边框样式,_BORDERSTYLE_
325 | !xlFormat.borderColor = 边框颜色
326 | !xlFormat.borderLeft = 左边框样式
327 | !xlFormat.borderRight = 右边框样式
328 | !xlFormat.borderTop = 上边框样式
329 | !xlFormat.borderBottom = 下边框样式
330 | !xlFormat.borderLeftColor = 左边框颜色
331 | !xlFormat.borderRightColor = 右边框颜色
332 | !xlFormat.borderTopColor = 上边框颜色
333 | !xlFormat.borderBottomColor = 下边框颜色
334 | !xlFormat.borderDiagonal = 对角线边框,_BORDERDIAGONAL_
335 | !xlFormat.borderDiagonalStyle = 对角线边框样式
336 | !xlFormat.borderDiagonalColor = 对角线边框颜色
337 | !xlFormat.pattern = 填充样式,_FILLPATTERN_
338 | !xlFormat.patternForeColor = 样式前景色
339 | !xlFormat.patternBackColor = 样式背景色
340 | !xlFormat.lock = 锁定单元格
341 | !xlFormat.hidden = 隐藏单元格
342 | _NUMFORMAT_GENERAL=@1/*_NUMFORMAT_GENERAL*/
343 | _NUMFORMAT_NUMBER=@2/*_NUMFORMAT_NUMBER*/
344 | _NUMFORMAT_NUMBER_D2=@3/*_NUMFORMAT_NUMBER_D2*/
345 | _NUMFORMAT_NUMBER_SEP=@4/*_NUMFORMAT_NUMBER_SEP*/
346 | _NUMFORMAT_NUMBER_SEP_D2=@5/*_NUMFORMAT_NUMBER_SEP_D2*/
347 | _NUMFORMAT_CURRENCY_NEGBRA=@6/*_NUMFORMAT_CURRENCY_NEGBRA*/
348 | _NUMFORMAT_CURRENCY_NEGBRARED=@7/*_NUMFORMAT_CURRENCY_NEGBRARED*/
349 | _NUMFORMAT_CURRENCY_D2_NEGBRA=@8/*_NUMFORMAT_CURRENCY_D2_NEGBRA*/
350 | _NUMFORMAT_CURRENCY_D2_NEGBRARED=@9/*_NUMFORMAT_CURRENCY_D2_NEGBRARED*/
351 | _NUMFORMAT_PERCENT=@10/*_NUMFORMAT_PERCENT*/
352 | _NUMFORMAT_PERCENT_D2=@11/*_NUMFORMAT_PERCENT_D2*/
353 | _NUMFORMAT_SCIENTIFIC_D2=@12/*_NUMFORMAT_SCIENTIFIC_D2*/
354 | _NUMFORMAT_FRACTION_ONEDIG=@13/*_NUMFORMAT_FRACTION_ONEDIG*/
355 | _NUMFORMAT_FRACTION_TWODIG=@14/*_NUMFORMAT_FRACTION_TWODIG*/
356 | _NUMFORMAT_DATE=@15/*_NUMFORMAT_DATE*/
357 | _NUMFORMAT_CUSTOM_D_MON_YY=@16/*_NUMFORMAT_CUSTOM_D_MON_YY*/
358 | _NUMFORMAT_CUSTOM_D_MON=@17/*_NUMFORMAT_CUSTOM_D_MON*/
359 | _NUMFORMAT_CUSTOM_MON_YY=@18/*_NUMFORMAT_CUSTOM_MON_YY*/
360 | _NUMFORMAT_CUSTOM_HMM_AM=@19/*_NUMFORMAT_CUSTOM_HMM_AM*/
361 | _NUMFORMAT_CUSTOM_HMMSS_AM=@20/*_NUMFORMAT_CUSTOM_HMMSS_AM*/
362 | _NUMFORMAT_CUSTOM_HMM=@21/*_NUMFORMAT_CUSTOM_HMM*/
363 | _NUMFORMAT_CUSTOM_HMMSS=@22/*_NUMFORMAT_CUSTOM_HMMSS*/
364 | _NUMFORMAT_CUSTOM_MDYYYY_HMM=@23/*_NUMFORMAT_CUSTOM_MDYYYY_HMM*/
365 | _NUMFORMAT_NUMBER_SEP_NEGBRA=@24/*_NUMFORMAT_NUMBER_SEP_NEGBRA*/
366 | _NUMFORMAT_NUMBER_SEP_NEGBRARED=@25/*_NUMFORMAT_NUMBER_SEP_NEGBRARED*/
367 | _NUMFORMAT_NUMBER_D2_SEP_NEGBRA=@26/*_NUMFORMAT_NUMBER_D2_SEP_NEGBRA*/
368 | _NUMFORMAT_NUMBER_D2_SEP_NEGBRARED=@27/*_NUMFORMAT_NUMBER_D2_SEP_NEGBRARED*/
369 | _NUMFORMAT_ACCOUNT=@28/*_NUMFORMAT_ACCOUNT*/
370 | _NUMFORMAT_ACCOUNTCUR=@29/*_NUMFORMAT_ACCOUNTCUR*/
371 | _NUMFORMAT_ACCOUNT_D2=@30/*_NUMFORMAT_ACCOUNT_D2*/
372 | _NUMFORMAT_ACCOUNT_D2_CUR=@31/*_NUMFORMAT_ACCOUNT_D2_CUR*/
373 | _NUMFORMAT_CUSTOM_MMSS=@32/*_NUMFORMAT_CUSTOM_MMSS*/
374 | _NUMFORMAT_CUSTOM_H0MMSS=@33/*_NUMFORMAT_CUSTOM_H0MMSS*/
375 | _NUMFORMAT_CUSTOM_MMSS0=@34/*_NUMFORMAT_CUSTOM_MMSS0*/
376 | _NUMFORMAT_CUSTOM_000P0E_PLUS0=@35/*_NUMFORMAT_CUSTOM_000P0E_PLUS0*/
377 | _NUMFORMAT_TEXT=@36/*_NUMFORMAT_TEXT*/
378 | _ALIGNH_GENERAL=@0/*ALIGNH_GENERAL*/
379 | _ALIGNH_LEFT=@1/*ALIGNH_LEFT*/
380 | _ALIGNH_CENTER=@2/*ALIGNH_CENTER*/
381 | _ALIGNH_RIGHT=@3/*ALIGNH_RIGHT*/
382 | _ALIGNH_FILL=@4/*ALIGNH_FILL*/
383 | _ALIGNH_JUSTIFY=@5/*ALIGNH_JUSTIFY*/
384 | _ALIGNH_MERGE=@6/*ALIGNH_MERGE*/
385 | _ALIGNH_DISTRIBUTED=@7/*ALIGNH_DISTRIBUTED*/
386 | _ALIGNV_TOP=@0/*ALIGNV_TOP*/
387 | _ALIGNV_CENTER=@1/*ALIGNV_CENTER*/
388 | _ALIGNV_BOTTOM=@2/*ALIGNV_BOTTOM*/
389 | _ALIGNV_JUSTIFY=@3/*ALIGNV_JUSTIFY*/
390 | _ALIGNV_DISTRIBUTED=@4/*ALIGNV_DISTRIBUTED*/
391 | _BORDERSTYLE_NONE=@0/*BORDERSTYLE_NONE*/
392 | _BORDERSTYLE_THIN=@1/*BORDERSTYLE_THIN*/
393 | _BORDERSTYLE_MEDIUM=@2/*BORDERSTYLE_MEDIUM*/
394 | _BORDERSTYLE_DASHED=@3/*BORDERSTYLE_DASHED*/
395 | _BORDERSTYLE_DOTTED=@4/*BORDERSTYLE_DOTTED*/
396 | _BORDERSTYLE_THICK=@5/*BORDERSTYLE_THICK*/
397 | _BORDERSTYLE_DOUBLE=@6/*BORDERSTYLE_DOUBLE*/
398 | _BORDERSTYLE_HAIR=@7/*BORDERSTYLE_HAIR*/
399 | _BORDERSTYLE_MEDIUMDASHED=@8/*BORDERSTYLE_MEDIUMDASHED*/
400 | _BORDERSTYLE_DASHDOT=@9/*BORDERSTYLE_DASHDOT*/
401 | _BORDERSTYLE_MEDIUMDASHDOT=@10/*BORDERSTYLE_MEDIUMDASHDOT*/
402 | _BORDERSTYLE_DASHDOTDOT=@11/*BORDERSTYLE_DASHDOTDOT*/
403 | _BORDERSTYLE_MEDIUMDASHDOTDOT=@12/*BORDERSTYLE_MEDIUMDASHDOTDOT*/
404 | _BORDERSTYLE_SLANTDASHDOT=@13/*BORDERSTYLE_SLANTDASHDOT*/
405 | _BORDERDIAGONAL_NONE=@0/*BORDERDIAGONAL_NONE*/
406 | _BORDERDIAGONAL_DOWN=@1/*BORDERDIAGONAL_DOWN*/
407 | _BORDERDIAGONAL_UP=@2/*BORDERDIAGONAL_UP*/
408 | _BORDERDIAGONAL_BOTH=@3/*BORDERDIAGONAL_BOTH*/
409 | _FILLPATTERN_NONE=@0/*FILLPATTERN_NONE*/
410 | _FILLPATTERN_SOLID=@1/*FILLPATTERN_SOLID*/
411 | _FILLPATTERN_GRAY50=@2/*FILLPATTERN_GRAY50*/
412 | _FILLPATTERN_GRAY75=@3/*FILLPATTERN_GRAY75*/
413 | _FILLPATTERN_GRAY25=@4/*FILLPATTERN_GRAY25*/
414 | _FILLPATTERN_HORSTRIPE=@5/*FILLPATTERN_HORSTRIPE*/
415 | _FILLPATTERN_VERSTRIPE=@6/*FILLPATTERN_VERSTRIPE*/
416 | _FILLPATTERN_REVDIAGSTRIPE=@7/*FILLPATTERN_REVDIAGSTRIPE*/
417 | _FILLPATTERN_DIAGSTRIPE=@8/*FILLPATTERN_DIAGSTRIPE*/
418 | _FILLPATTERN_DIAGCROSSHATCH=@9/*FILLPATTERN_DIAGCROSSHATCH*/
419 | _FILLPATTERN_THICKDIAGCROSSHATCH=@10/*FILLPATTERN_THICKDIAGCROSSHATCH*/
420 | _FILLPATTERN_THINHORSTRIPE=@11/*FILLPATTERN_THINHORSTRIPE*/
421 | _FILLPATTERN_THINVERSTRIPE=@12/*FILLPATTERN_THINVERSTRIPE*/
422 | _FILLPATTERN_THINREVDIAGSTRIPE=@13/*FILLPATTERN_THINREVDIAGSTRIPE*/
423 | _FILLPATTERN_THINDIAGSTRIPE=@14/*FILLPATTERN_THINDIAGSTRIPE*/
424 | _FILLPATTERN_THINHORCROSSHATCH=@15/*FILLPATTERN_THINHORCROSSHATCH*/
425 | _FILLPATTERN_THINDIAGCROSSHATCH=@16/*FILLPATTERN_THINDIAGCROSSHATCH*/
426 | _FILLPATTERN_GRAY12P5=@17/*FILLPATTERN_GRAY12P5*/
427 | _FILLPATTERN_GRAY6P25=@18/*FILLPATTERN_GRAY6P25*/
428 | end intellisense**/
--------------------------------------------------------------------------------
/demo/main.aardio:
--------------------------------------------------------------------------------
1 | import win.ui;
2 | /*DSG{{*/
3 | mainForm = win.form(text="libxl-3.8";right=598;bottom=151)
4 | mainForm.add(
5 | static={cls="static";text="请执行Script下的示例";left=131;top=65;right=499;bottom=116;font=LOGFONT(h=-35);notify=1;transparent=1;z=1};
6 | static2={cls="static";text="执行前,请先从libxl官网下载dll,并放置到res目录下";left=74;top=32;right=574;bottom=61;font=LOGFONT(h=-21);transparent=1;z=2}
7 | )
8 | /*}}*/
9 |
10 | _dll = ..raw.loadDll(..string.load("/res/libxl.dll"),,"cdecl");
11 | var libxl32 = _dll;
12 |
13 | CreateBook = libxl32.api("xlCreateBook","ptr()");
14 | CreateXMLBook = libxl32.api("xlCreateXMLBook","ptr()");
15 | Release = libxl32.api("xlBookRelease","void(ptr BookHandle)");
16 | Load = libxl32.api("xlBookLoad","int(ptr BookHandle, ustring filename)")
17 | Save = libxl32.api("xlBookSave","bool(ptr BookHandle, ustring filename)")
18 |
19 | var book = CreateXMLBook();
20 |
21 | mainForm.show();
22 | return win.loopMessage();
--------------------------------------------------------------------------------
/demo/script/autofilter_byvalue.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var autofilter_byValue = function(){
5 | io.open()
6 |
7 | var start = time.tick()
8 |
9 | var file = "export/autofilter_byValue.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var xlSheet = xlExcel.addSheet("my");
13 |
14 | if xlSheet{
15 |
16 | xlSheet.Cell(3,2).value = "Country";
17 | xlSheet.Cell(3,3).value = "Road injures";
18 | xlSheet.Cell(3,4).value = "Smoking";
19 | xlSheet.Cell(3,5).value = "Suicide";
20 |
21 | xlSheet.Cell(4, 2).value ="USA"; xlSheet.Cell(5, 2).value ="UK";
22 | xlSheet.Cell(4, 3).value = 64; xlSheet.Cell(5, 3).value =94;
23 | xlSheet.Cell(4, 4).value = 69; xlSheet.Cell(5, 4).value =55;
24 | xlSheet.Cell(4, 5).value = 49; xlSheet.Cell(5, 5).value = 64;
25 |
26 | xlSheet.Cell(6, 2).value ="Germany"; xlSheet.Cell(7, 2).value ="Switzerland";
27 | xlSheet.Cell(6, 3).value =88; xlSheet.Cell(7, 3).value = 93;
28 | xlSheet.Cell(6, 4).value =46; xlSheet.Cell(7, 4).value = 54;
29 | xlSheet.Cell(6, 5).value =55; xlSheet.Cell(7, 5).value = 50;
30 |
31 | xlSheet.Cell(8, 2).value ="Spain"; xlSheet.Cell(9, 2).value ="Italy";
32 | xlSheet.Cell(8, 3).value = 86; xlSheet.Cell(9, 3).value = 75;
33 | xlSheet.Cell(8, 4).value = 47; xlSheet.Cell(9, 4).value = 52;
34 | xlSheet.Cell(8, 5).value = 69; xlSheet.Cell(9, 5).value = 71;
35 |
36 | xlSheet.Cell(10, 2).value ="Greece"; xlSheet.Cell(11, 2).value ="Japan";
37 | xlSheet.Cell(10, 3).value =67; xlSheet.Cell(11, 3).value =91;
38 | xlSheet.Cell(10, 4).value =23; xlSheet.Cell(11, 4).value =57;
39 | xlSheet.Cell(10, 5).value =87; xlSheet.Cell(11, 5).value =36;
40 |
41 | var xlAutoFilter = xlSheet.autoFilter();
42 | xlAutoFilter.setRef("B3E11");
43 |
44 | var xlFilterColumn = xlAutoFilter.getColumn(1);
45 | xlFilterColumn.filterText = "Japan"
46 | xlFilterColumn.filterText = "USA"
47 | xlFilterColumn.filterText = "Switzerland"
48 |
49 | xlSheet.applyFilter();
50 |
51 | io.print(xlExcel.Save(file))
52 | io.print(xlExcel.getErrMsg())
53 |
54 | xlExcel.Close()
55 |
56 | io.print("use " + (time.tick() - start + " ms"));
57 | }
58 |
59 | };
60 |
61 | autofilter_byValue()
62 |
63 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/autofilter_strcustom.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var autofilter_strcustom = function(){
5 | io.open()
6 |
7 | var start = time.tick()
8 |
9 | var file = "export/autofilter_strcustom.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var xlSheet = xlExcel.addSheet("my");
13 |
14 | if xlSheet{
15 |
16 | xlSheet.Cell(3,2).value = "Country";
17 | xlSheet.Cell(3,3).value = "Road injures";
18 | xlSheet.Cell(3,4).value = "Smoking";
19 | xlSheet.Cell(3,5).value = "Suicide";
20 |
21 | xlSheet.Cell(4, 2).value ="USA"; xlSheet.Cell(5, 2).value ="UK";
22 | xlSheet.Cell(4, 3).value = 64; xlSheet.Cell(5, 3).value =94;
23 | xlSheet.Cell(4, 4).value = 69; xlSheet.Cell(5, 4).value =55;
24 | xlSheet.Cell(4, 5).value = 49; xlSheet.Cell(5, 5).value = 64;
25 |
26 | xlSheet.Cell(6, 2).value ="Germany"; xlSheet.Cell(7, 2).value ="Switzerland";
27 | xlSheet.Cell(6, 3).value =88; xlSheet.Cell(7, 3).value = 93;
28 | xlSheet.Cell(6, 4).value =46; xlSheet.Cell(7, 4).value = 54;
29 | xlSheet.Cell(6, 5).value =55; xlSheet.Cell(7, 5).value = 50;
30 |
31 | xlSheet.Cell(8, 2).value ="Spain"; xlSheet.Cell(9, 2).value ="Italy";
32 | xlSheet.Cell(8, 3).value = 86; xlSheet.Cell(9, 3).value = 75;
33 | xlSheet.Cell(8, 4).value = 47; xlSheet.Cell(9, 4).value = 52;
34 | xlSheet.Cell(8, 5).value = 69; xlSheet.Cell(9, 5).value = 71;
35 |
36 | xlSheet.Cell(10, 2).value ="Greece"; xlSheet.Cell(11, 2).value ="Japan";
37 | xlSheet.Cell(10, 3).value =67; xlSheet.Cell(11, 3).value =91;
38 | xlSheet.Cell(10, 4).value =23; xlSheet.Cell(11, 4).value =57;
39 | xlSheet.Cell(10, 5).value =87; xlSheet.Cell(11, 5).value =36;
40 |
41 | var xlAutoFilter = xlSheet.autoFilter();
42 | xlAutoFilter.setRef("B3E11");
43 |
44 | var xlFilterColumn = xlAutoFilter.getColumn(1);
45 | xlFilterColumn.setCustomFilter(0/*_OPERATOR_EQUAL*/,"G*")
46 |
47 | xlSheet.applyFilter();
48 |
49 | io.print(xlExcel.Save(file))
50 | io.print(xlExcel.getErrMsg())
51 | xlExcel.Close()
52 |
53 | io.print("use " + (time.tick() - start + " ms"));
54 | }
55 |
56 | };
57 |
58 | autofilter_strcustom()
59 |
60 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/autofilter_topN.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var autofilter_topN = function(){
5 | io.open()
6 |
7 | var start = time.tick()
8 |
9 | var file = "export/autofilter_topN.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var xlSheet = xlExcel.addSheet("my");
13 |
14 | if xlSheet{
15 |
16 | xlSheet.Cell(3,2).value = "Country";
17 | xlSheet.Cell(3,3).value = "Road injures";
18 | xlSheet.Cell(3,4).value = "Smoking";
19 | xlSheet.Cell(3,5).value = "Suicide";
20 |
21 | xlSheet.Cell(4, 2).value ="USA"; xlSheet.Cell(5, 2).value ="UK";
22 | xlSheet.Cell(4, 3).value = 64; xlSheet.Cell(5, 3).value =94;
23 | xlSheet.Cell(4, 4).value = 69; xlSheet.Cell(5, 4).value =55;
24 | xlSheet.Cell(4, 5).value = 49; xlSheet.Cell(5, 5).value = 64;
25 |
26 | xlSheet.Cell(6, 2).value ="Germany"; xlSheet.Cell(7, 2).value ="Switzerland";
27 | xlSheet.Cell(6, 3).value =88; xlSheet.Cell(7, 3).value = 93;
28 | xlSheet.Cell(6, 4).value =46; xlSheet.Cell(7, 4).value = 54;
29 | xlSheet.Cell(6, 5).value =55; xlSheet.Cell(7, 5).value = 50;
30 |
31 | xlSheet.Cell(8, 2).value ="Spain"; xlSheet.Cell(9, 2).value ="Italy";
32 | xlSheet.Cell(8, 3).value = 86; xlSheet.Cell(9, 3).value = 75;
33 | xlSheet.Cell(8, 4).value = 47; xlSheet.Cell(9, 4).value = 52;
34 | xlSheet.Cell(8, 5).value = 69; xlSheet.Cell(9, 5).value = 71;
35 |
36 | xlSheet.Cell(10, 2).value ="Greece"; xlSheet.Cell(11, 2).value ="Japan";
37 | xlSheet.Cell(10, 3).value =67; xlSheet.Cell(11, 3).value =91;
38 | xlSheet.Cell(10, 4).value =23; xlSheet.Cell(11, 4).value =57;
39 | xlSheet.Cell(10, 5).value =87; xlSheet.Cell(11, 5).value =36;
40 |
41 | var xlAutoFilter = xlSheet.autoFilter();
42 | xlAutoFilter.setRef("B3E11");
43 |
44 | var xlFilterColumn = xlAutoFilter.getColumn(2);
45 | xlFilterColumn.setTop10(3);
46 |
47 | var format2 = xlSheet.Cells(1,1).format;
48 | xlSheet.applyFilter();
49 |
50 | io.print(xlExcel.Save(file))
51 | io.print(xlExcel.getErrMsg())
52 |
53 | xlExcel.Close()
54 |
55 | io.print("use " + (time.tick() - start + " ms"));
56 | }
57 |
58 | };
59 |
60 | autofilter_topN()
61 |
62 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zgmf-x-20a/libxl/681649161af7ec082c7648263a8965ab8474d80c/demo/script/logo.png
--------------------------------------------------------------------------------
/demo/script/mergecells.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var mergeCells = function(){
5 |
6 | io.open()
7 |
8 | var start = time.tick()
9 |
10 | var file = "export/merge.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | var format1 = xlExcel.addFormat();
14 | format1.alignH = 2/*ALIGNH_CENTER*/;
15 | format1.alignV = 1/*ALIGNV_CENTER*/
16 |
17 | var xlSheet = xlExcel.addSheet("Sheet1");
18 |
19 | if xlSheet{
20 |
21 | xlSheet.Cell(4,2).setValue("Hello World!",format1);
22 | xlSheet.setMerge(4, 6, 2, 6);
23 | xlSheet.Range("B8:C21,E8F21").merge();
24 |
25 | xlSheet.Cell(8,2).setValue(1,format1);
26 | xlSheet.Cell(8,5).setValue(2,format1);
27 |
28 | io.print(xlExcel.Save(file))
29 | io.print(xlExcel.getErrMsg())
30 |
31 | xlExcel.Close()
32 |
33 | io.print("use " + (time.tick() - start + " ms"));
34 | }
35 |
36 | };
37 |
38 | mergeCells()
39 |
40 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/receipt.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 | import preg;
4 | import console;
5 |
6 |
7 | var WriteData = function(){
8 | io.open()
9 |
10 | var file = "export/receipt.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | //var Lincense_Name,Lincense_Key = "Halil Kural","windows-2723210a07c4e90162b26966a8jcdboe";
14 |
15 | //xlExcel.setKey(Lincense_Name,Lincense_Key);//注册
16 |
17 |
18 | var logoId = xlExcel.addPicture("script/logo.png")
19 |
20 | var textFont = xlExcel.addFont();
21 | textFont.size = 8;
22 | textFont.name = "Century Gothic"
23 |
24 | var titleFont = xlExcel.addFont(textFont)
25 | titleFont.size = 38
26 | titleFont.color = 22/*_COLOR_GRAY25*/
27 |
28 | var font12 = xlExcel.addFont(textFont);
29 | font12.size = 12;
30 |
31 | var font10 = xlExcel.addFont(textFont);
32 | font10.size = 10;
33 |
34 | var textFormat = xlExcel.addFormat()
35 | textFormat.font = textFont
36 | textFormat.alignH = 1/*ALIGNH_LEFT*/
37 |
38 | var titleFormat = xlExcel.addFormat()
39 | titleFormat.font = titleFont;
40 | titleFormat.alignH = 3/*ALIGNH_RIGHT*/
41 |
42 | var companyFormat = xlExcel.addFormat()
43 | companyFormat.font = font12
44 |
45 | var dateFormat = xlExcel.addFormat(textFormat)
46 | dateFormat.numStyle = xlExcel.addNumFormat("[$-409]mmmm d, yyyy;@")
47 |
48 | var phoneFormat = xlExcel.addFormat(textFormat)
49 | phoneFormat.numStyle = xlExcel.addNumFormat("[<=9999999]###\-####;\(###\)\ ###\-####")
50 |
51 |
52 | var borderFormat = xlExcel.addFormat(textFormat)
53 | borderFormat.borderStyle = 1 /*BORDERSTYLE_THIN*/
54 | borderFormat.borderColor = 22/*_COLOR_GRAY25*/
55 | borderFormat.alignV = 1/*ALIGNV_CENTER*/
56 |
57 | var percentFormat = xlExcel.addFormat(borderFormat)
58 | percentFormat.numStyle = xlExcel.addNumFormat("#%_)")
59 | percentFormat.alignH = 3/*ALIGNH_RIGHT*/
60 |
61 | var textRightFormat = xlExcel.addFormat(textFormat)
62 | textRightFormat.alignV = 1/*ALIGNV_CENTER*/
63 | textRightFormat.alignH = 3/*ALIGNH_RIGHT*/
64 |
65 | var thankFormat = xlExcel.addFormat()
66 | thankFormat.font = font10;
67 | thankFormat.alignH = 2/*ALIGNH_CENTER*/;
68 |
69 | var dollarFormat = xlExcel.addFormat(borderFormat)
70 | dollarFormat.numStyle = xlExcel.addNumFormat("_($* # ##0.00_);_($* (# ##0.00);_($* -??_);_(@_)")
71 |
72 | xlSheet = xlExcel.addSheet("Sales Receipt")
73 | xlSheet.displayGridlines = false
74 |
75 | xlSheet.Column(1).width = 10
76 | xlSheet.Column(2).width = 36
77 | xlSheet.Column(3,4).width = 11
78 | xlSheet.Column(5).width = 13
79 | xlSheet.Row(3).height = 47.25
80 |
81 | xlSheet.Cells(3,2).value = "Sales Receipt"
82 | xlSheet.Cells(3,2).format = titleFormat
83 | xlSheet.setMerge(3,3,2,5)
84 | xlSheet.setPicture(3,2,logoId,0.8)
85 |
86 | xlSheet.Cells(5,1).value = "Apricot Ltd.";
87 | xlSheet.Cells(5,1).format = companyFormat;
88 | xlSheet.Cells(5,4).value = "Date:";
89 | xlSheet.Cells(5,4).format = textFormat;
90 | xlSheet.Cells(5,5).formula = "TODAY()";
91 | xlSheet.Cells(5,5).format = dateFormat;
92 |
93 | xlSheet.Cells(6,4).value = "Receipt #:"
94 | xlSheet.Cells(6,4).format = textFormat;
95 | xlSheet.Cells(6,5).value = 652;
96 | xlSheet.Cells(6,5).format = textFormat;
97 |
98 | xlSheet.Cells(9,1).value = "Sold to:"
99 | xlSheet.Cells(9,1).format = textFormat
100 | xlSheet.Cells(9,2).value = "John Smith"
101 | xlSheet.Cells(9,2 ).format = textFormat
102 | xlSheet.Cells(10,2).value = "Pineapple Ltd."
103 | xlSheet.Cells(10,2).format = textFormat
104 | xlSheet.Cells(11 ,2 ).value = "123 Dreamland Street"
105 | xlSheet.Cells(11 ,2 ).format =textFormat
106 | xlSheet.Cells(12 ,2 ).value = "Moema, 52674"
107 | xlSheet.Cells(12 ,2 ).format = textFormat
108 | xlSheet.Cells(13 ,2 ).value = 2659872055
109 | xlSheet.Cells(13 ,2 ).format = phoneFormat
110 |
111 | xlSheet.Cells(15,1).value = "Item #"
112 | xlSheet.Cells(15,1).format = textFormat
113 | xlSheet.Cells(15,2).value = "Description"
114 | xlSheet.Cells(15,2).format = textFormat
115 | xlSheet.Cells(15,3).value = "Qty"
116 | xlSheet.Cells(15,3).format = textFormat
117 | xlSheet.Cells(15,4).value = "Unit Price"
118 | xlSheet.Cells(15,4).format = textFormat
119 | xlSheet.Cells(15,5).value = "Line Total"
120 | xlSheet.Cells(15,5).format = textFormat
121 |
122 | for row=16;38;1{
123 | xlSheet.Row(row).height = 15
124 | for col=1;3;1{
125 | xlSheet.Cells(row,col).blank = borderFormat
126 | }
127 | xlSheet.Cells(row,4).blank = dollarFormat;
128 | var str = string.concat("IF(C",row,">0;ABS(C",row ,"*D",row,");)")
129 | xlSheet.Cells(row,5).formula = str;
130 | xlSheet.Cells(row,5).format = dollarFormat;
131 | }
132 |
133 | xlSheet.Cells(39,4).value = "Subtotal"
134 | xlSheet.Cells(39,4).format = textRightFormat
135 | xlSheet.Cells(40,4).value = "Sales"
136 | xlSheet.Cells(40,4).format = textRightFormat
137 | xlSheet.Cells(41,4).value = "Total "
138 | xlSheet.Cells(41,4).format = textRightFormat
139 | xlSheet.Cells(39,5).formula = "SUM(E16:E38)"
140 | xlSheet.Cells(39,5).format = dollarFormat
141 | xlSheet.Cells(40,5).value = 0.2
142 | xlSheet.Cells(40,5).format = percentFormat
143 | xlSheet.Cells(41,5).formula = "E39+E39*E40"
144 | xlSheet.Cells(41,5).format = dollarFormat
145 | xlSheet.Row(39).height = 15
146 | xlSheet.Row(40).height = 15
147 | xlSheet.Row(41).height = 15
148 |
149 | xlSheet.Cells(43,1).value = "Thank you for your business!"
150 | xlSheet.Cells(43,1).format = thankFormat;
151 | xlSheet.setMerge(43,43,1,5)
152 |
153 | xlSheet.Cells(16,1).value = 45;
154 | xlSheet.Cells(16,1).format = borderFormat;
155 | xlSheet.Cells(16,2).value = "Grapes";
156 | xlSheet.Cells(16,2).format = borderFormat;
157 | xlSheet.Cells(16,3).value = 250;
158 | xlSheet.Cells(16,3).format = borderFormat;
159 | xlSheet.Cells(16,4).value = 4.5;
160 | xlSheet.Cells(16,4).format = dollarFormat;
161 |
162 | xlSheet.Cells(17,1).value = 12;
163 | xlSheet.Cells(17,1).format = borderFormat;
164 | xlSheet.Cells(17,2).value = "Bananas";
165 | xlSheet.Cells(17,2).format = borderFormat;
166 | xlSheet.Cells(17,3).value = 480;
167 | xlSheet.Cells(17,3).format = borderFormat;
168 | xlSheet.Cells(17,4).value = 1.4;
169 | xlSheet.Cells(17,4).format = dollarFormat;
170 |
171 | xlSheet.Cells(18,1).value = 19;
172 | xlSheet.Cells(18,1).format = borderFormat;
173 | xlSheet.Cells(18,2).value = "Apples";
174 | xlSheet.Cells(18,2).format = borderFormat;
175 | xlSheet.Cells(18,3).value = 180;
176 | xlSheet.Cells(18,3).format = borderFormat;
177 | xlSheet.Cells(18,4).value = 2.8;
178 | xlSheet.Cells(18,4).format = dollarFormat;
179 |
180 | io.print(xlExcel.Save(file))
181 |
182 | io.print(xlExcel.getErrMsg())
183 |
184 | xlExcel.Close()
185 |
186 | io.print("Done")
187 |
188 |
189 | };
190 |
191 | WriteData()
192 |
193 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/usedrange.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 | var mergeCells = function(){
5 |
6 | io.open()
7 |
8 | var start = time.tick()
9 |
10 | var file = "export/usedrange.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | var format1 = xlExcel.addFormat();
14 | format1.alignH = 2/*ALIGNH_CENTER*/;
15 | format1.alignV = 1/*ALIGNV_CENTER*/
16 |
17 | var xlSheet = xlExcel.addSheet("Sheet1");
18 |
19 | if xlSheet{
20 |
21 | xlSheet.Cell(4,2).setValue("Hello World!",format1);
22 | xlSheet.setMerge(4, 6, 2, 6);
23 | xlSheet.Range("B8:C21,E8F21").merge();
24 |
25 | xlSheet.Cell(8,2).setValue(1,format1);
26 | xlSheet.Cell(8,5).setValue(2,format1);
27 |
28 |
29 | var usedRange = xlSheet.usedRange;
30 | console.log(usedRange.Rows.Count,usedRange.Columns.Count)
31 |
32 | io.print(xlExcel.Save(file))
33 | io.print(xlExcel.getErrMsg())
34 |
35 | xlExcel.Close()
36 |
37 | io.print("use " + (time.tick() - start + " ms"));
38 | }
39 |
40 | };
41 |
42 | mergeCells()
43 |
44 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/writedatatime.aardio:
--------------------------------------------------------------------------------
1 | import libxl;
2 | import console;
3 |
4 |
5 | var writeDataTime = function(){
6 | io.open()
7 | var start = time.tick()
8 |
9 | var file = "export/datetime.xlsx"
10 | var xlExcel,err = libxl()
11 |
12 | var format1 = xlExcel.addFormat();
13 | format1.numStyle = 15/*_NUMFORMAT_DATE*/;
14 |
15 | var format2 = xlExcel.addFormat();
16 | format2.numStyle = 23/*_NUMFORMAT_CUSTOM_MDYYYY_HMM*/;
17 |
18 | var format3 = xlExcel.addFormat();
19 | format3.numStyle = xlExcel.addNumFormat("d mmmm yyyy");
20 |
21 | var format4 = xlExcel.addFormat();
22 | format4.numStyle = 19/*_NUMFORMAT_CUSTOM_HMM_AM*/;
23 |
24 | var xlSheet = xlExcel.addSheet("Sheet1");
25 |
26 | if xlSheet{
27 |
28 | xlSheet.Column(2).width = 15
29 |
30 | xlSheet.Cell(3,2).value = xlExcel.datePack(2010,3,11);
31 | xlSheet.Cell(3,2).format = format1;
32 |
33 | xlSheet.Cell(4,2).setValue(xlExcel.datePack(2010,3,11,10,25,55),format2);
34 | xlSheet.Cell(5,2).setValue(xlExcel.timeValue("2010-03-11 0:0:0"),format3);
35 | xlSheet.Cell(6,2).setValue(xlExcel.timeValue("2010-03-11 10:25:55"),format4);
36 |
37 | var date = xlExcel.time(xlSheet.Cell(3,2).value);
38 | console.log("date",date)
39 |
40 | var date = xlExcel.time(xlSheet.Cell(4,2).value);
41 | console.log("date",date)
42 |
43 | io.print(xlExcel.Save(file))
44 | io.print(xlExcel.getErrMsg())
45 |
46 | xlExcel.Close()
47 |
48 | io.print("use " + (time.tick() - start + " ms"));
49 | }
50 |
51 | };
52 |
53 | writeDataTime()
54 |
55 | console.pause(true);
--------------------------------------------------------------------------------
/demo/script/writeformulas.aardio:
--------------------------------------------------------------------------------
1 | import console;
2 | import libxl;
3 | import console;
4 |
5 |
6 | var WriteData = function(){
7 | io.open()
8 | var start = time.tick()
9 |
10 | var file = "export/formula.xlsx"
11 | var xlExcel,err = libxl()
12 |
13 | var alFormat = xlExcel.addFormat()
14 | alFormat.alignH = 1/*ALIGNH_LEFT*/
15 |
16 | var arFormat = xlExcel.addFormat()
17 | arFormat.alignH = 3/*ALIGNH_RIGHT*/
18 |
19 | var alignDateFormat = xlExcel.addFormat(alFormat)
20 | alignDateFormat.numStyle = 14/*NUMFORMAT_DATE*/
21 |
22 | var linkFont = xlExcel.addFont();
23 | linkFont.color = 12/*_COLOR_BLUE*/
24 | linkFont.underLine = 1/*_UNDERLINE_SINGLE*/
25 |
26 | var linkFormat = xlExcel.addFormat(alFormat);
27 | linkFormat.font = linkFont;
28 |
29 | var xlSheet = xlExcel.addSheet("Sheet1")
30 |
31 | if xlSheet{
32 |
33 | xlSheet.Cell("A12").value = 40
34 |
35 | xlSheet.Column(1).width = 27
36 | xlSheet.Column(2).width = 10
37 |
38 | xlSheet.Cell(3,2).value = 40
39 | xlSheet.Cell(3,2).format = alFormat
40 | xlSheet.Cell(4,2).value = 30
41 | xlSheet.Cell(4,2).format = alFormat
42 | xlSheet.Cell(5,2).value = 50
43 | xlSheet.Cell(5,2).format = alFormat
44 |
45 | xlSheet.Cell(7,1).setValue("SUM(B3:B5) = ",arFormat)
46 | xlSheet.Cell(7,2).setFormula ("SUM(B3:B5)",alFormat)
47 |
48 | xlSheet.Cell(8,1).value = "AVERAGE(B3:B5) = ";
49 | xlSheet.Cell(8,1).format = arFormat;
50 | xlSheet.Cell(8,2).formula = "AVERAGE(B3:B5)";
51 | xlSheet.Cell(8,2).format = alFormat;
52 |
53 | xlSheet.Cell(9,1).value = "MAX(B3:B5) =";
54 | xlSheet.Cell(9,1).format = arFormat;
55 | xlSheet.Cell(9,2).formula = "MAX(B3:B5)";
56 | xlSheet.Cell(9,2).format = alFormat;
57 |
58 | xlSheet.Cell(10,1).value = "MIN(B3:B5) =";
59 | xlSheet.Cell(10,1).format = arFormat;
60 | xlSheet.Cell(10,2).formula = "MIN(B3:B5)";
61 | xlSheet.Cell(10,2).format = alFormat;
62 |
63 | xlSheet.Cell(11,1).value = "COUNT(B3:B5) =";
64 | xlSheet.Cell(11,1).format = arFormat;
65 | xlSheet.Cell(11,2).formula = "COUNT(B3:B5)";
66 | xlSheet.Cell(11,2).format = alFormat;
67 |
68 | io.print(xlExcel.Save(file))
69 |
70 | io.print(xlExcel.getErrMsg())
71 |
72 | xlExcel.Close()
73 |
74 | io.print("Done")
75 |
76 | io.print("use" + (time.tick() - start + "ms"));
77 | }
78 |
79 | };
80 |
81 | WriteData()
82 |
83 | console.pause(true);
--------------------------------------------------------------------------------
/libxl/_.aardio:
--------------------------------------------------------------------------------
1 | //libxl
2 | import raw;
3 | import time;
4 |
5 | class libxl{
6 | ctor( file = "xlsx" ){
7 | //默认为 EXCEL XLSX
8 | this.file = ..io.exist(file);
9 | this.open = false;
10 | this.Book = Book;
11 | this.raw = false;//是否字节流
12 | this.Sheet = {//存储表数据
13 | @{
14 | _get = function(k){ //通过表名获取时
15 | for i=1;#owner;1{;//搜寻表名,一致时返回
16 | if owner[i].name == k return owner[i];
17 | };
18 | return null//owner[[k]];
19 | }
20 | _call = function(k){ //通过表名获取时
21 | if type(k) == type.number{
22 | if (k <= #owner) && (k > 0) return owner[k];
23 | }
24 | if type(k) == type.string{
25 | for i=1;#owner;1{;//搜寻表名,一致时返回
26 | if owner[i].name == k return owner[i];
27 | };
28 | }
29 | return null;
30 | }
31 | }
32 | };
33 |
34 | createbook = function(ext){
35 | if ext == null error("请指定文件类型");
36 | ext = ..string.lower( ..string.replace(ext,"@.",""));
37 | if ext = "xlsx" {this.hwnd = CreateXMLBook();isXlsx = true};
38 | if ext = "xls" {this.hwnd = CreateBook() ;isXlsx = false};
39 | if !this.hwnd return null;
40 | if (Lincense_Name && Lincense_Key) Book.SetKey(this.hwnd,Lincense_Name,Lincense_Key);//注册libxl
41 | return true;
42 | };
43 | getFileType = function(file){
44 | if !..io.exist(file) error("文件不存在");
45 | var hFile = ..io.open(file,"rb");
46 | var header = hFile.read(6);
47 | hFile.close()
48 | header = ..raw.convert(header,fileHeader);
49 | header = ..string.hex(header.head,"");
50 | if header == xlsHead return "xls";
51 | if header == xlsxHead return "xlsx";
52 | return null;
53 | };
54 | getFileTypebyName = function(file){
55 | var filePath = ..io.splitpath(file);
56 | if filePath.ext != "" return ..string.replace(filePath.ext,"@.","");
57 | return null;
58 | };
59 | getSheets = function(){
60 | var count = Book.SheetCount(this.hwnd);
61 | for i=1;count;1{
62 | ..table.push(this.Sheet,Sheet(Book.GetSheet(this.hwnd,i-1),this.ShareFormat));//读取并添加对应的Sheet表
63 | };
64 | if count return true;
65 | };
66 |
67 | isXlsx = null;
68 | if !..io.exist(file) && file != null{ //文件不存在,且参数非空,根据扩展名创建;
69 | var ext = file
70 | if #file > 5 {
71 | if #file > 1024{
72 | ext = "xlsx"; //默认xlsx,其实应该增加字节判断
73 | this.raw = true;
74 | }
75 | else {
76 | if !..io.exist(file) error("文件不存在")
77 | }
78 | }
79 | if !createbook(ext) error ("错误的参数");
80 | };
81 | errMsgStatue = function(){
82 | if this.hwnd {
83 | var err = Book.ErrorMessage(this.hwnd);
84 | if (err = errMsg[1] || err = errMsg[2]) err = "错误的文件类型"
85 | return err;
86 | };
87 | return "句柄不存在";
88 | };
89 |
90 | load = function(file,ext){
91 | if !file return null,"文件不存在";
92 | if this.raw {
93 | if this.hwnd == null && ext == null error("请指定文件类型");
94 | if !createbook( ext:( isXlsx?"xlsx":"xls" )) error("错误的参数");
95 | if !Book.LoadRaw(this.hwnd,file,#file) return null,errMsgStatue();
96 | this.open = true;
97 | };
98 | else {
99 | if this.hwnd == null {
100 | ext = ext?ext:(getFileType(file)?getFileType(file):getFileTypebyName(file));
101 | if !createbook(ext) error("错误的文件类型");
102 | };
103 | if !Book.Load(this.hwnd,file) return null,errMsgStatue();
104 | this.file = file;
105 | this.open = true;
106 | };
107 | if getSheets() return true;
108 | };
109 | //---共享格式对象
110 | this.ShareFormat = {book = this};
111 | this.ShareFormat.Formats = { //同一个工作表的Format是共享的
112 | @{
113 | _call = function(k,p_shareformat){ //k是句柄
114 | if owner[tonumber(k)] return owner[tonumber(k)];
115 | owner[tonumber(k)] = ..libxl.Format(k,p_shareformat)
116 | return owner[tonumber(k)];
117 | }
118 | }
119 | }
120 | this.ShareFormat.Fonts = {//同一个工作表的Font是共享的
121 | @{
122 | _call = function(k){ //k是句柄
123 | if owner[tonumber(k)] return owner[tonumber(k)];
124 | owner[tonumber(k)] = ..libxl.Font(k)
125 | return owner[tonumber(k)];
126 | }
127 | }
128 | }
129 | if this.file or this.raw //字节类的也加载
130 | if !load(file) return null,"文件无法加载";
131 |
132 | };
133 | @_metaProperty;
134 | Load = load;
135 | Save = function(file){
136 | var path = this.file;
137 | if file path = file;
138 | if this.raw && !path return owner.saveStr();
139 | if !path return null,"未指定文件";
140 | if path return Book.Save(this.hwnd,path);
141 | return false;
142 | }
143 | loadStr = function(pString){
144 | if !Book.LoadRaw(this.hwnd,pString,#pString) return null,"文件无法从内存加载";
145 | getSheets()
146 | };
147 | saveStr = function(){
148 | var str = /*{byte buffer[%d]}*/
149 | var result,data,size = Book.SaveRaw(this.hwnd,,1);
150 | if !result return null,"文件无法保存至变量";
151 | data = ..raw.convert(data,eval(..string.format(str,size )))
152 | return data.buffer;
153 | };
154 | addSheet = function(sheetName,cpSheet){
155 | var iniSheetHwnd;
156 | if type(sheetName) != type.string sheetName = tostring(sheetName);//强制转换
157 | if (type(cpSheet) == type.number){
158 | if cpSheet > #this.Sheet return null,"工作表不存在";
159 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
160 | }
161 | elseif (type(cpSheet) == type.string){
162 | var sheet = this.Sheet[cpSheet]
163 | if !sheet return null,"工作表不存在";
164 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
165 | }
166 | elseif (type(cpSheet) == type.table) {
167 | if !cpSheet.hwnd return null,"工作表不存在";;
168 | iniSheetHwnd = cpSheet.hwnd
169 | }
170 | var np_Sheet = Book.AddSheet(this.hwnd,sheetName,iniSheetHwnd)
171 | if !np_Sheet return null,"工作表创建失败";
172 | ..table.push(this.Sheet,Sheet(np_Sheet,this.ShareFormat));//增加book对象
173 | return this.Sheet[#this.Sheet];
174 | };
175 | insertSheet = function(index,sheetName,cpSheet){
176 | var iniSheetHwnd;
177 | if type(cpSheet) == type.number{
178 | if cpSheet > #this.Sheet return null,"工作表不存在";
179 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
180 | };
181 | if type(cpSheet) == type.string{
182 | var sheet = this.Sheet[cpSheet]
183 | if !sheet return null,"工作表不存在";
184 | iniSheetHwnd = this.Sheet[cpSheet].hwnd
185 | };
186 | var np_Sheet = Book.InsertSheet(this.hwnd,index - 1,sheetName,iniSheetHwnd)
187 | if !np_Sheet return null,"工作表创建失败";
188 | ..table.insert(this.Sheet,Sheet(np_Sheet,this.ShareFormat),index);//增加book对象
189 | return this.Sheet[index];
190 | };
191 | moveSheet = function(cpSheet,index){
192 | var srcSheetIndex;
193 | if !index return null,"请指定目的位置";
194 | srcSheetIndex = cpSheet;
195 | if type(cpSheet) == type.number if cpSheet > #this.Sheet return null,"工作表不存在";
196 | if type(cpSheet) == type.string{
197 | for i = 1;#this.Sheet{
198 | if this.Sheet[i].name == srcSheetIndex{
199 | srcSheetIndex = i;
200 | break ;
201 | }
202 | }
203 | if type(srcSheetIndex) != type.number return null,"工作表不存在";
204 | }
205 | Book.MoveSheet(this.hwnd,srcSheetIndex,index)
206 | };
207 | sheetType = function(cpSheet){
208 | var index;
209 | if type(cpSheet) == type.string{
210 | for i=1;#this.Sheet;1{;//搜寻表名,一致时返回
211 | if this.Sheet[i].name == cpSheet {
212 | index = i;
213 | break ;
214 | } ;
215 | };
216 | }
217 | if !index index = cpSheet;
218 | return Book.SheetType(this.hwnd,index -1);
219 | };
220 | delSheet = function(cpSheet){
221 | var index;
222 | if type(cpSheet) == type.string{
223 | for i=1;#this.Sheet;1{;//搜寻表名,一致时返回
224 | if this.Sheet[i].name == cpSheet {
225 | index = i;
226 | break ;
227 | } ;
228 | };
229 | }
230 | if !index index = cpSheet;
231 | var result = Book.DelSheet(this.hwnd,index -1);
232 | if !result return result;
233 | ..table.remove(this.Sheet,index)
234 | return true;
235 | };
236 | addFormat = function(hFormat){
237 | if type(hFormat) == type.table hFormat = hFormat.hwnd
238 | var hwnd = Book.AddFormat(this.hwnd,hFormat)
239 | return this.ShareFormat.Formats(hwnd,this.ShareFormat); //统一管理格式
240 | };
241 | addFont = function(hFont){
242 | if type(hFont) == type.table hFont = hFont.hwnd
243 | var hwnd = Book.AddFont(this.hwnd,hFont)
244 | return this.ShareFormat.Fonts(hwnd); //统一管理字体
245 | };
246 | addNumFormat = function(textNumFormat){
247 | return (Book.AddCustomNumFormat(this.hwnd,textNumFormat) + 1);
248 | };
249 | getFormat = function(index){
250 | return Book.Format(this.hwnd,index - 1);
251 | };
252 | getFont = function(index){
253 | return Book.Font(this.hwnd,index - 1);
254 | };
255 | getNumFormat = function(index){
256 | return Book.CustomNumFormat(this.hwnd,index - 1);
257 | };
258 | datePack = function(year, month, day, hour = 0, min = 0, sec = 0, msec = 0){
259 | return Book.DatePack(this.hwnd,year,month,day,hour,min, sec,msec);
260 | }
261 | dateUnpack = function(date){
262 | var result,year,month,day,hour,min,sec,msec = Book.DateUnpack(this.hwnd,date,0,0,0,0,0,0,0);
263 | if !result return null;
264 | var date = {year = year; month = month; day = day; hour = hour;min = min;sec = sec;msec =msec};
265 | return date;
266 | }
267 | timeValue = function(date){
268 | var datetime = date;
269 | if type(datetime) == type.string datetime = ..time(datetime);
270 | if type(datetime) != type.table return null;
271 | return Book.DatePack(this.hwnd,datetime.year,datetime.month,datetime.day,
272 | datetime.hour,datetime.minute, datetime.second,datetime.milliseconds);
273 | }
274 | time = function(date){
275 | var result,year,month,day,hour,min,sec,msec = Book.DateUnpack(this.hwnd,date,0,0,0,0,0,0,0);
276 | if !result return null;
277 | var datetime = ..time();
278 | datetime.year = year;
279 | datetime.month = month;
280 | datetime.day = day;
281 | datetime.hour = hour;
282 | datetime.minute = min;
283 | datetime.second = sec;
284 | datetime.milliseconds = msec;
285 | return datetime;
286 | };
287 | colorPack = function(red = 0,green = 0, blue = 0){
288 | return Book.ColorPack(this.hwnd,red,green,blue);
289 | };
290 | colorUnpack = function(rgbColor){
291 | var red,green,blue = Book.ColorUnpack(this.hwnd,rgbColor,0,0,0);
292 | if !red return null;
293 | var color = {red = red;green = green; blue = blue}
294 | return color;
295 | };
296 | getPicture = function(index){
297 | var str = /*{byte buffer[%d]}*/
298 | var picType,data,size = Book.GetPicture(this.hwnd,index - 1,,1);
299 | data = ..raw.convert(data,eval(..string.format(str,size )))
300 | return data.buffer,picType;
301 | };
302 | addPicture = function(file){
303 | var result = Book.AddPicture(this.hwnd,..io.exist(file));
304 | if result == -1 return null;
305 | result += 1;
306 | return result;
307 | };
308 | addPictureByStr = function(pString){
309 | var result = Book.AddPicture2(this.hwnd,pString,#pString);
310 | if result == -1 return null;
311 | result += 1;
312 | return result;
313 | };
314 | getDefaultFont = function(){
315 | var int = 1;
316 | var name,size = Book.DefaultFont(this.hwnd,int);
317 | if !name return null;
318 | return name,size;
319 | };
320 | setDefaultFont = function(fontName,fontSize){
321 | Book.SetDefaultFont(this.hwnd,fontName,fontSize);
322 | };
323 | setKey = function(name,key){
324 | Book.SetKey(this.hwnd,name,key);
325 | };
326 | setStrLocal = function(descrption){
327 | Book.SetLocale(this.hwnd,descrption);
328 | };
329 | getErrMsg = function(){
330 | return ..raw.str(Book.ErrorMessage(this.hwnd));
331 | };
332 | Close = function(save = false){
333 | if save Book.Save(this.hwnd,this.file);
334 | Release(this.hwnd);
335 | this.open = false;
336 | owner = null;//销毁对象
337 | collectgarbage("collect");
338 | return true;
339 | };
340 | };
341 |
342 | namespace libxl{
343 |
344 | LIBXL_VERSON = "3.8.0.0";
345 |
346 | _dll = ..raw.loadDll("/res/libxl.dll",,"cdecl,unicode");
347 |
348 | import libxl.Book;
349 | import libxl.Sheet;
350 | import libxl.Format;
351 | import libxl.Font;
352 | import libxl.AutoFilter;
353 | import libxl.FilterColumn;
354 |
355 | var libxl32 = _dll;
356 |
357 | //Lincense_Name,Lincense_Key = "","";
358 |
359 | CreateBook = libxl32.api("xlCreateBook","ptr()");
360 | CreateXMLBook = libxl32.api("xlCreateXMLBook","ptr()");
361 | Release = libxl32.api("xlBookRelease","void(ptr BookHandle)");
362 |
363 | cellComment = class {
364 | ctor( value,author,width = 100,height = 50 ){
365 | this.value = value;
366 | this.author = author;
367 | this.width = width;
368 | this.height = height;
369 | };
370 | }
371 | cellRange = class {
372 | ctor( iniRow = 1,lastRow = 1,iniCol = 1,lastCol = 1 ){
373 | this.iniCol = iniCol;
374 | this.lastCol = lastCol;
375 | this.iniRow = iniRow;
376 | this.lastRow = lastRow;
377 | };
378 | }
379 | nameRange = class {
380 | ctor( iniRow = 1,lastRow = 1,iniCol = 1,lastCol = 1,scopeID = 0,hidden = 0){
381 | this.iniCol = iniCol;
382 | this.lastCol = lastCol;
383 | this.iniRow = iniRow;
384 | this.lastRow = lastRow;
385 | this.scopeID = scopeID;
386 | this.hidden = hidden;
387 | this.name = name
388 | };
389 | }
390 |
391 | picturePos = class {
392 | ctor( top,left,bottom,right,width,height, offset_x,offset_y ){
393 | this.top = top;
394 | this.left = left;
395 | this.bottom = bottom;
396 | this.right = right;
397 | this.width = width;
398 | this.height = height;
399 | this.offset_x = offset_x;
400 | this.offset_y = offset_y;
401 | };
402 | };
403 |
404 | fileHeader = {
405 | byte head[6];
406 | };
407 | xlsHead = "D0CF11E0A1B1";
408 | xlsxHead = "504B03041400";
409 | errMsg = {
410 | "invalid file format";
411 | "The central directory was not found in the archive (or you were trying to open not the last volume of a segmented archive).";
412 | };
413 |
414 |
415 | _metaProperty = ..util.metaProperty(
416 | formatCount = {
417 | _get = function(){
418 | return Book.FormatSize(owner.hwnd);
419 | }
420 | };
421 | fontCount = {
422 | _get = function(){
423 | return Book.FontSize(owner.hwnd);
424 | };
425 | };
426 | activeSheetInex = {
427 | _get = function(){
428 | return (Book.ActiveSheet(owner.hwnd) + 1);
429 | };
430 | _set = function(v){
431 | owner.activeSheet(v);
432 | };
433 | };
434 | activeSheet = {
435 | _get = function(){
436 | return owner.Sheet((Book.ActiveSheet(owner.hwnd) + 1));
437 | };
438 | _set = function(v){
439 | var index;
440 | if type(v) == type.string{
441 | for i=1;#owner.Sheet;1{;//搜寻表名
442 | if owner.Sheet[i].name == v {
443 | index = i;
444 | break ;
445 | } ;
446 | };
447 | }
448 | if !index index = v;
449 | Book.SetActiveSheet(owner.hwnd,index - 1);
450 | };
451 | };
452 | pictureCount = {
453 | _get = function(){
454 | return Book.PictureSize(owner.hwnd);
455 | };
456 | };
457 | RGB = {
458 | _get = function(){
459 | return Book.RgbMode(owner.hwnd);
460 | };
461 | _set = function(v){
462 | return Book.SetRgbMode(owner.hwnd,v);
463 | };
464 | };
465 | R1C1 = {
466 | _get = function(){
467 | return Book.RefR1C1(owner.hwnd);
468 | };
469 | _set = function(v){
470 | return Book.SetRefR1C1(owner.hwnd,v);
471 | };
472 | };
473 | biffVersion = {
474 | _get = function(){
475 | return Book.BiffVersion(owner.hwnd);
476 | };
477 | }
478 | Date1904 = {
479 | _get = function(){
480 | return Book.IsDate1904(owner.hwnd);
481 | };
482 | _set = function(v){
483 | return Book.SetDate1904(owner.hwnd,v);
484 | };
485 | };
486 | template = {
487 | _get = function(){
488 | return Book.IsTemplate(owner.hwnd);
489 | };
490 | _set = function(v){
491 | return Book.SetTemplate(owner.hwnd,v);
492 | };
493 | };
494 | )
495 |
496 | };
497 |
498 | /**intellisense()
499 | libxl() = !libxl.
500 | !libxl.addSheet() = !xlSheet.
501 | !libxl.insertSheet() = !xlSheet.
502 | !libxl.activeSheet = !xlSheet.
503 | !libxl.Load(.(文件路径|文件流) = 加载指定Excel文件或文件流,失败返回null
504 | !libxl.Save(.() = 保存当前 Excel 文件
505 | !libxl.Sheet(.(工作表[名称|位置]) = 获取工作表对象
506 | !libxl.addSheet(.(工作表名称,[源工作表名|位置]) = 新增工作表,可复制源工作表,失败返回null
507 | !libxl.insertSheet(.(插入位置,工作表名称,[源工作表名|位置]) = 在指定位置插入工作表,可复制源工作表,失败返回null
508 | !libxl.delSheet(.(工作表名称|位置) = 删除指定名称或位置的工作表,失败返回false
509 | !libxl.sheetType(.(工作表名称|位置) = 获取指定名称或位置的工作表类型,失败返回false
510 | !libxl.addFormat(.([Format句柄]) = 新增格式句柄,可复制源格式。\n成功返回句柄,失败返回null
511 | !libxl.addFont(.([Font句柄]) = 新增字体句柄,可复制源格式。\n成功返回句柄,失败返回null
512 | !libxl.getFormat(.(工作簿内的Format索引) = 获得指定 Index 对应的 Format 句柄,失败返回null
513 | !libxl.getFont(.(工作簿内的Font索引) = 获得指定 Index 对应的 Font 句柄,失败返回null
514 | !libxl.getPicture(.(工作簿内的Picture索引) = 获得指定 Index 对应的 Picture 数据(二进制)及图片格式,失败返回null
515 | !libxl.saveStr(.() = 返回当前工作薄的数据(二进制),失败返回null
516 | !libxl.addPicture(.(文件路径) = 添加指定路径的图片并返回 图片 Index,失败返回null
517 | !libxl.addPictureByStr(.(文件流) = 加载文件流中的图片并返回 图片 Index,失败返回null
518 | !libxl.getDefaultFont(.() = 返回工作薄默认的字体名字及字号,失败返回null
519 | !libxl.setDefaultFont(.(字体名,字号) = 设置工作薄默认的字体
520 | !libxl.setKey(.(name,key) = 设置自定义 license key
521 | !libxl.addNumFormat(.("样式") = 添加自定义的数字格式
522 | !libxl.getErrMsg(.() = 获取错误信息
523 | !libxl.datePack(.(year,month,day,[hour],[min],[sec],[msec]) = 返回Excel日期数值
524 | !libxl.dateUnpack(.(date) = 将Excel日期数值转为date对象
525 | !libxl.timeValue(.(time()或时间文本) = 返回Excel日期数值
526 | !libxl.time(.(timeNumbers) = 将Excel日期数值转为time对象
527 | !libxl.colorPack(.(red,green,blue) = 打包颜色样式
528 | !libxl.colorUnpack(.(RGBColor) = 还原三原色,返回color对象
529 | !libxl.Close(.() = 关闭并销毁对象
530 | !libxl.formatCount = 工作薄内的 Format 数
531 | !libxl.fontCount = 工作薄内的 Font 数
532 | !libxl.activeSheet = 激活的工作簿
533 | !libxl.activeSheet = !xlSheet.
534 | !libxl.activeSheetInex = 激活工作簿的位置
535 | !libxl.pictureCount = 工作薄内的 Picture 数
536 | !libxl.RGB = RGB模式
537 | !libxl.R1C1 = R1C1模式
538 | !libxl.biffVersion = biffVersion,仅xls有效
539 | !libxl.Date1904 = 是否启用1904年作为日期基准
540 | !libxl.template = 是否是模板
541 | libxl.cellComment(.(value,author,[width],[height]) = 批注类,仅xls有效
542 | libxl.cellRange(.([iniRow],[lastRow],[iniCol],[lastCol]) = 区域类
543 | libxl.nameRange(.([iniCol],[lastCol],[]iniRow,lastRow],[scopeID],[hidden]) = 命名区域类
544 | libxl.picturePos(.(top,left,bottom,right,width,height, offset_x,offset_y) = 图片位置类
545 | end intellisense**/
--------------------------------------------------------------------------------
/libxl/autofilter.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class AutoFilter{
8 | ctor( hwnd,ow_hwnd){
9 | if !hwnd return null,"请指定自动筛选句柄";
10 | this.hwnd = hwnd;
11 | this.owner = ow_hwnd;
12 | };
13 | @_metaProperty;
14 | }
15 |
16 | namespace AutoFilter{
17 |
18 | _metaProperty = ..util.metaProperty(
19 | ref = {
20 | _get = function(){
21 | return owner.getRef();
22 | }
23 | _set = function(v){
24 | owner.setRef(v);
25 | }
26 | }
27 | columnNum = {
28 | _get = function(){
29 | return owner.columnSize();
30 | }
31 | }
32 | sortRange = {
33 | _get = function(){
34 | return getSortRange();
35 | }
36 | }
37 | columnSize = function(){
38 | return ColumnSize(owner.hwnd);
39 | }
40 | getColumn = function(index,isIndex){
41 | var func = Column;
42 | if isIndex func = ColumnByIndex;
43 | index -= 1;
44 | var hwnd = func(owner.hwnd,index);
45 | if !hwnd return null;
46 | return ..libxl.FilterColumn(hwnd);
47 | }
48 | setRef = function(v){
49 | var cellRange = v;
50 | if type(cellRange) = type.string{
51 | cellRange = ..libxl.Sheet.Range.reCalcuCellRange(owner.owner,cellRange);
52 | }
53 | SetRef(owner.hwnd,cellRange.iniRow - 1,cellRange.lastRow - 1,cellRange.iniCol - 1,cellRange.lastCol - 1);
54 | }
55 | getRef = function(addr){
56 | var result,rowFirst,rowLast,colFirst,colLast = GetRef(owner.hwnd,0,0,0,0);
57 | if !result return null;
58 | if addr{
59 | var addrStart = ..libxl.Sheet.rowColToAddr(rowFirst + 1,colFirst + 1)
60 | var addrEnd = ..libxl.Sheet.rowColToAddr(rowLast + 1,colLast + 1)
61 | return ..string.concat(addrStart,":",addrEnd);
62 | }
63 | return ..libxl.cellRange(rowFirst + 1, rowLast + 1, colFirst + 1,colLast + 1);
64 | }
65 | getSortRange = function(addr){
66 | var result,rowFirst,rowLast,colFirst,colLast = GetSortRange(owner.hwnd,0,0,0,0);
67 | if !result return null;
68 | if addr{
69 | var addrStart = ..libxl.Sheet.rowColToAddr(rowFirst,colFirst)
70 | var addrEnd = ..libxl.Sheet.rowColToAddr(rowLast,colLast)
71 | return ..string.concat(addrStart,":",addrEnd);
72 | }
73 | return ..libxl.cellRange(rowFirst, rowLast, colFirst,colLast);
74 | }
75 | getSort = function(){
76 | var result,columnIndex,descending = GetSort(owner.hwnd,0,0);
77 | if !result return null;
78 | return columnIndex,descending;
79 | }
80 | setSort = function(columnIndex,descending){
81 | return SetSort(owner.hwnd,columnIndex,descending);
82 | }
83 |
84 | column = getColumn;
85 | )
86 |
87 | GetRef = libxl32.api("xlAutoFilterGetRef","int(ptr AutoFilterHandle, int& rowFirst, int& rowLast, int& colFirst, int& colLast)");
88 | SetRef = libxl32.api("xlAutoFilterSetRef","void(ptr AutoFilterHandle, int rowFirst, int rowLast, int colFirst, int colLast)");
89 |
90 | ColumnSize = libxl32.api("xlAutoFilterColumnSize","int(ptr AutoFilterHandle)");
91 |
92 | Column = libxl32.api("xlAutoFilterColumn","ptr(ptr AutoFilterHandle, int colId)");//FilterColumnHandle
93 | ColumnByIndex = libxl32.api("xlAutoFilterColumnByIndex","ptr(ptr AutoFilterHandle, int index)");//FilterColumnHandle
94 |
95 | GetSortRange = libxl32.api("xlAutoFilterGetSortRange","int(ptr AutoFilterHandle, int& rowFirst, int& rowLast, int& colFirst, int& colLast)");
96 | GetSort = libxl32.api("xlAutoFilterGetSort","int(ptr AutoFilterHandle, int& columnIndex, int& descending)");
97 | SetSort = libxl32.api("xlAutoFilterSetSort","int(ptr AutoFilterHandle, int columnIndex, int descending)");
98 |
99 | }
100 |
101 |
102 | /**intellisense()
103 | !xlSheet.autoFilter() = !xlAutoFilter.
104 | !xlAutoFilter.ref = 设置或返回筛选区域
105 | !xlAutoFilter.columnNum = 筛选区域列数
106 | !xlAutoFilter.sortRange = 获取排序区域
107 | !xlAutoFilter.getColumn(.(列数,[是否相对位置]) = 返回筛选列对象
108 | end intellisense**/
--------------------------------------------------------------------------------
/libxl/book.aardio:
--------------------------------------------------------------------------------
1 | namespace libxl;
2 |
3 | var libxl32 = _dll;
4 |
5 | namespace Book{
6 |
7 | Load = libxl32.api("xlBookLoad","bool(ptr BookHandle, ustring filename)")
8 | Save = libxl32.api("xlBookSave","bool(ptr BookHandle, ustring filename)")
9 |
10 | LoadRaw = libxl32.api("xlBookLoadRaw","bool(ptr BookHandle, string data, INT size)")
11 | SaveRaw = libxl32.api("xlBookSaveRaw","bool(ptr BookHandle, pointer& data, INT& size)")
12 |
13 | AddSheet = libxl32.api("xlBookAddSheet","ptr(ptr BookHandle, ustring name, ptr initSheet)") //SheetHandle
14 | InsertSheet = libxl32.api("xlBookInsertSheet","ptr(ptr BookHandle, int index, ustring name, ptr initSheet)") //SheetHandle
15 | GetSheet = libxl32.api("xlBookGetSheet","ptr(ptr BookHandle, int index)") //SheetHandle
16 | SheetType = libxl32.api("xlBookSheetType","int(ptr BookHandle, int index)")
17 | DelSheet = libxl32.api("xlBookDelSheet","int(ptr BookHandle, int index)")
18 | SheetCount = libxl32.api("xlBookSheetCount","int(ptr BookHandle)")
19 |
20 | AddFormat = libxl32.api("xlBookAddFormat","ptr(ptr BookHandle, ptr initFormat)") //FormatHandle,initFormat为ptr
21 | AddFont = libxl32.api("xlBookAddFont","ptr(ptr BookHandle, ptr initFont)") //FontHandle,initFont为ptr
22 |
23 | Format = libxl32.api("xlBookFormat","ptr(ptr BookHandle, int index)")//FormatHandle,
24 | FormatSize = libxl32.api("xlBookFormatSize","int(ptr BookHandle)")
25 | Font = libxl32.api("xlBookFont","ptr(ptr BookHandle, int index)")//FontHandle,
26 | FontSize = libxl32.api("xlBookFontSize","int(ptr BookHandle)")
27 |
28 | ActiveSheet = libxl32.api("xlBookActiveSheet","int(ptr BookHandle)")
29 | SetActiveSheet = libxl32.api("xlBookSetActiveSheet","void(ptr BookHandle, int index)")
30 | PictureSize = libxl32.api("xlBookPictureSize","int(ptr BookHandle)")
31 | GetPicture = libxl32.api("xlBookGetPicture","int(ptr BookHandle, int index, pointer& data, INT& size)")
32 | AddPicture = libxl32.api("xlBookAddPicture","int(ptr BookHandle, ustring filename)")
33 | AddPicture2 = libxl32.api("xlBookAddPicture2","int(ptr BookHandle, ustring data, INT size)")
34 |
35 | DefaultFont = libxl32.api("xlBookDefaultFont","ustring(ptr BookHandle, INT& fontSize)")
36 | SetDefaultFont = libxl32.api("xlBookSetDefaultFont","void(ptr BookHandle, ustring fontName, INT fontSize)")
37 |
38 | RgbMode = libxl32.api("xlBookRgbMode","int(ptr BookHandle)")
39 | SetRgbMode = libxl32.api("xlBookSetRgbMode","void(ptr BookHandle, BYTE rgbMode)")
40 | RefR1C1 = libxl32.api("xlBookRefR1C1","int(ptr BookHandle)")
41 | SetRefR1C1 = libxl32.api("xlBookSetRefR1C1","void(ptr BookHandle, BYTE refR1C1)")
42 | BiffVersion = libxl32.api("xlBookBiffVersion","int(ptr BookHandle)")
43 | IsDate1904 = libxl32.api("xlBookIsDate1904","int(ptr BookHandle)")
44 | SetDate1904 = libxl32.api("xlBookSetDate1904","void(ptr BookHandle, BYTE date1904)")
45 | IsTemplate = libxl32.api("xlBookIsTemplate","int(ptr BookHandle)")
46 | SetTemplate = libxl32.api("xlBookSetTemplate","void(ptr BookHandle, int tmpl)")
47 | SetKey = libxl32.api("xlBookSetKey","void(ptr BookHandle, ustring name, ustring key)")
48 | SetLocale = libxl32.api("xlBookSetLocale","int(ptr BookHandle, string locale)")
49 | ErrorMessage = libxl32.api("xlBookErrorMessage","ptr(ptr BookHandle)")
50 |
51 | AddCustomNumFormat = libxl32.api("xlBookAddCustomNumFormat","int(ptr BookHandle, ustring customNumFormat)")
52 | CustomNumFormat = libxl32.api("xlBookCustomNumFormat", "ustring(ptr BookHandle,int fmt)")
53 | DatePack = libxl32.api("xlBookDatePack","double(ptr BookHandle,int year, int month, int day,int hour, int min, int sec, int msec)")
54 | DateUnpack = libxl32.api("xlBookDateUnpack","bool(ptr BookHandle, double value,int& year, int& month, int& day,int& hour, int& min, int& sec, int& msec)")
55 | ColorPack = libxl32.api("xlBookColorPack","int(ptr BookHandle, int red, int green, int blue)")
56 | ColorUnpack = libxl32.api("xlBookColorUnpack","void(ptr BookHandle, int color, int& red, int& green, int& blue)")
57 |
58 | MoveSheet = libxl32.api("xlBookMoveSheet","int(ptr BookHandle, int srcIndex, int dstIndex)");
59 | AddPictureAsLink = libxl32.api("xlBookAddPictureAsLink","int(ptr BookHandle, ustring& filename, int insert)");
60 | LoadUsingTempFile = libxl32.api("xlBookLoadUsingTempFile","int(ptr BookHandle, ustring& filename, ustring& tempFile)");
61 | SaveUsingTempFile = libxl32.api("xlBookSaveUsingTempFile","int(ptr BookHandle, ustring& filename, int useTempFile)");
62 | LoadPartially = libxl32.api("xlBookLoadPartially","int(ptr BookHandle, ustring& filename, int sheetIndex, int firstRow, int lastRow)");
63 | LoadPartiallyUsingTempFile = libxl32.api("xlBookLoadPartiallyUsingTempFile","int(ptr BookHandle, ustring& filename, int sheetIndex, int firstRow, int lastRow, ustring& tempFile)");
64 | }
65 |
66 | /**intellisense()
67 | _SHEETTYPE_SHEET=@0/*_SHEETTYPE_SHEET*/
68 | _SHEETTYPE_CHART=@1/*_SHEETTYPE_CHART*/
69 | _SHEETTYPE_UNKNOW=@2/*_SHEETTYPE_UNKNOW*/
70 | !libxl().Book = !xlBook.
71 | !xlBook.Load(.(ptr,filename,tempfile) = 插入行
72 | end intellisense**/
--------------------------------------------------------------------------------
/libxl/filtercolumn.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class FilterColumn{
8 | ctor( hwnd ){
9 | if !hwnd return null,"请指定自动筛选句柄";
10 | this.hwnd = hwnd;
11 | };
12 | @_metaProperty;
13 | }
14 |
15 |
16 | namespace FilterColumn{
17 | _metaProperty = ..util.metaProperty(
18 | index = {
19 | _get = function(){
20 | return Index(owner.hwnd) + 1;
21 | }
22 | }
23 | filterType = {
24 | _get = function(){
25 | return FilterType(owner.hwnd);
26 | }
27 | }
28 | filterSize = {
29 | _get = function(){
30 | return FilterSize(owner.hwnd);
31 | }
32 | }
33 | filterText = {
34 | _set = function(v){
35 | owner.setFilter(v);
36 | }
37 | }
38 | value = function(index){//按作者的习惯,不应该只有str类型的
39 | return Filter(owner.hwnd,index -1);
40 | }
41 | setFilter = function(v){
42 | //if type(v) != type.string v = tostring(v);
43 | AddFilter(owner.hwnd,v);
44 | }
45 | getTop10 = function(){
46 | var result,value,top,percent = GetTop10(owner.hwnd,0,false,false);
47 | if !result return null;
48 | return value,top,percent; //不知道是什么鬼,不处理了
49 | }
50 | setTop10 = function(value,top = true,percent = false){
51 | SetTop10(owner.hwnd,value,top,percent);
52 | }
53 | getCustomFilter = function(){
54 | var str = /*{ustring text[1024]}*/
55 | var result,v1_type,v1_ptr,v2_type,v2_ptr,option = GetCustomFilter(owner.hwnd,0,,0,,false)
56 | if !result return null;
57 | var v1,v2 = ..raw.convert(v1_ptr,str),..raw.convert(v2_ptr,str);
58 | return v1_type,v1,v2_type,v2,option;
59 | }
60 | setCustomFilter = function(v1_type,v1,v2_type,v2,option = false){ //默认为‘或’
61 | if v2 == null{
62 | return SetCustomFilter(owner.hwnd,v1_type,v1);
63 | }
64 | SetCustomFilterEx(owner.hwnd,v1_type,v1,v2_type,v2,option);
65 | }
66 | clear = function(){
67 | Clear(owner.hwnd);
68 | }
69 |
70 | //增加关键字
71 | Type = filterType;//由于是关键字,只能大写了
72 | count = filterSize;
73 | filter = filterText;
74 | )
75 |
76 |
77 | Index = libxl32.api("xlFilterColumnIndex","int(ptr FilterColumnHandle)");
78 |
79 | FilterType = libxl32.api("xlFilterColumnFilterType","int(ptr FilterColumnHandle)");
80 |
81 | FilterSize = libxl32.api("xlFilterColumnFilterSize","int(ptr FilterColumnHandle)");
82 | Filter = libxl32.api("xlFilterColumnFilter","ustring(ptr FilterColumnHandle, int index)");
83 |
84 | AddFilter = libxl32.api("xlFilterColumnAddFilter","void(ptr FilterColumnHandle,ustring value)");
85 |
86 | GetTop10 = libxl32.api("xlFilterColumnGetTop10","int(ptr FilterColumnHandle, double& value, bool& top, bool& percent)");
87 | SetTop10 = libxl32.api("xlFilterColumnSetTop10","void(ptr FilterColumnHandle, double value, bool top, bool percent)");
88 |
89 | GetCustomFilter = libxl32.api("xlFilterColumnGetCustomFilter","int(ptr FilterColumnHandle, int& op1, ptr& v1, int& op2, ptr& v2, bool& andOp)");
90 | SetCustomFilter = libxl32.api("xlFilterColumnSetCustomFilter","void(ptr FilterColumnHandle, int op, ustring val)");
91 | SetCustomFilterEx = libxl32.api("xlFilterColumnSetCustomFilterEx","void(ptr FilterColumnHandle, int op1, ustring v1, int op2, ustring v2, bool andOp)");
92 |
93 | Clear = libxl32.api("xlFilterColumnClear","void(ptr FilterColumnHandle)");
94 | }
95 |
96 | /**intellisense()
97 | libxl.FilterColumn() = !xlFilterColumn.
98 | !xlAutoFilter.getColumn() = !xlFilterColumn.
99 | !xlFilterColumn.index = 返回当前筛选所在列
100 | !xlFilterColumn.filterType = 返回当前筛选类型
101 | !xlFilterColumn.filterSize = 返回当前筛选行数
102 | !xlFilterColumn.filterText = 设置筛选值(文本)
103 | !xlFilterColumn.value(.(行数N) = 筛选中第N行的值
104 | !xlFilterColumn.setFilter(.(文本) = 设置筛选值
105 | !xlFilterColumn.GetTop10(.() = 前十值,有三个参数返回
106 | !xlFilterColumn.getCustomFilter(.() = 返回自定义筛选值,分别为 条件1类型,条件1,条件2类型,条件2,与或关系
107 | !xlFilterColumn.setCustomFilter(.(条件1类型,条件1,[条件2类型],[条件2],[与或关系]) = 设置自定义筛选
108 | !xlFilterColumn.clear() = 清除筛选
109 | _FILTER_VALUE=@0/*_FILTER_VALUE*/
110 | _FILTER_TOP10=@1/*_FILTER_TOP10*/
111 | _FILTER_CUSTOM=@2/*_FILTER_CUSTOM*/
112 | _FILTER_DYNAMIC=@3/*_FILTER_DYNAMIC*/
113 | _FILTER_COLOR=@4/*_FILTER_COLOR*/
114 | _FILTER_ICON=@5/*_FILTER_ICON*/
115 | _FILTER_EXT=@6/*_FILTER_EXT*/
116 | _FILTER_NOT_SET=@7/*_FILTER_NOT_SET*/
117 | _OPERATOR_EQUAL=@0/*_OPERATOR_EQUAL*/
118 | _OPERATOR_GREATER_THAN=@1/*_OPERATOR_GREATER_THAN*/
119 | _OPERATOR_GREATER_THAN_OR_EQUAL=@2/*_OPERATOR_GREATER_THAN_OR_EQUAL*/
120 | _OPERATOR_LESS_THAN=@3/*_OPERATOR_LESS_THAN*/
121 | _OPERATOR_LESS_THAN_OR_EQUAL=@4/*_OPERATOR_LESS_THAN_OR_EQUAL*/
122 | _OPERATOR_NOT_EQUAL=@5/*_OPERATOR_NOT_EQUAL*/
123 | end intellisense**/
--------------------------------------------------------------------------------
/libxl/font.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class Font{
8 | ctor( hwnd ){
9 | if !hwnd return null,"请指定字体句柄";
10 | this.hwnd = hwnd;
11 | };
12 | @_metaProperty;
13 | }
14 |
15 | namespace Font{
16 | _metaProperty = ..util.metaProperty(
17 | size = {
18 | _get = function(){
19 | return Size(owner.hwnd);
20 | };
21 | _set = function( v ){
22 | SetSize(owner.hwnd,v);
23 | };
24 | };
25 | italic = {
26 | _get = function(){
27 | return Italic(owner.hwnd);
28 | };
29 | _set = function( v ){
30 | SetItalic(owner.hwnd,v);
31 | };
32 | };
33 | strikeOut = {
34 | _get = function(){
35 | return StrikeOut(owner.hwnd);
36 | };
37 | _set = function( v ){
38 | SetStrikeOut(owner.hwnd,v);
39 | };
40 | };
41 | color = {
42 | _get = function(){
43 | return Color(owner.hwnd);
44 | };
45 | _set = function( v ){
46 | SetColor(owner.hwnd,v);
47 | };
48 | };
49 | bold = {
50 | _get = function(){
51 | return Bold(owner.hwnd);
52 | };
53 | _set = function( v ){
54 | SetBold(owner.hwnd,tonumber(v));
55 | };
56 | };
57 | script = {
58 | _get = function(){
59 | return Script(owner.hwnd);
60 | };
61 | _set = function( v ){
62 | SetScript(owner.hwnd,v);
63 | };
64 | };
65 | underLine = {
66 | _get = function(){
67 | return Underline(owner.hwnd);
68 | };
69 | _set = function( v ){
70 | SetUnderline(owner.hwnd,v);
71 | };
72 | };
73 | name = {
74 | _get = function(){
75 | return Name(owner.hwnd);
76 | };
77 | _set = function( v ){
78 | SetName(owner.hwnd,v);
79 | };
80 | };
81 | )
82 |
83 | Size = libxl32.api("xlFontSize","int(ptr FontHandle)")
84 | SetSize = libxl32.api("xlFontSetSize","void(ptr FontHandle, int size)")
85 |
86 | Italic = libxl32.api("xlFontItalic","int(ptr FontHandle)")
87 | SetItalic = libxl32.api("xlFontSetItalic","void(ptr FontHandle, int italic)")
88 |
89 | StrikeOut = libxl32.api("xlFontStrikeOut","int(ptr FontHandle)")
90 | SetStrikeOut = libxl32.api("xlFontSetStrikeOut","void(ptr FontHandle, int strikeOut)")
91 |
92 | Color = libxl32.api("xlFontColor","int(ptr FontHandle)")
93 | SetColor = libxl32.api("xlFontSetColor","void(ptr FontHandle, int color)")
94 |
95 | Bold = libxl32.api("xlFontBold","int(ptr FontHandle)")
96 | SetBold = libxl32.api("xlFontSetBold","void(ptr FontHandle, int bold)")
97 |
98 | Script = libxl32.api("xlFontScript","int(ptr FontHandle)")
99 | SetScript = libxl32.api("xlFontSetScript","void(ptr FontHandle, int script)")
100 |
101 | Underline = libxl32.api("xlFontUnderline","int(ptr FontHandle)")
102 | SetUnderline = libxl32.api("xlFontSetUnderline","void(ptr FontHandle, int underline)")
103 |
104 | Name = libxl32.api("xlFontName","ustring(ptr FontHandle)")
105 | SetName = libxl32.api("xlFontSetName","int(ptr FontHandle, ustring name)")
106 |
107 | }
108 |
109 | /**intellisense()
110 | libxl.Format() = !xlFont.
111 | !libxl.Format() = !xlFont.
112 | !libxl.addFont() = !xlFont.
113 | !xlFont.size = 字号
114 | !xlFont.italic = 斜体
115 | !xlFont.strikeOut = 删除线
116 | !xlFont.color = 颜色,_COLOR_
117 | !xlFont.bold = 粗体
118 | !xlFont.script = 小字符样式,_SCRIPT_
119 | !xlFont.underLine = 下划线,_UNDERLINE_
120 | !xlFont.name = 字体
121 | _COLOR_BLACK=@8/*_COLOR_BLACK*/
122 | _COLOR_WHITE=@9/*_COLOR_WHITE*/
123 | _COLOR_RED=@10/*_COLOR_RED*/
124 | _COLOR_BRIGHTGREEN=@11/*_COLOR_BRIGHTGREEN*/
125 | _COLOR_BLUE=@12/*_COLOR_BLUE*/
126 | _COLOR_YELLOW=@13/*_COLOR_YELLOW*/
127 | _COLOR_PINK=@14/*_COLOR_PINK*/
128 | _COLOR_TURQUOISE=@15/*_COLOR_TURQUOISE*/
129 | _COLOR_DARKRED=@16/*_COLOR_DARKRED*/
130 | _COLOR_GREEN=@17/*_COLOR_GREEN*/
131 | _COLOR_DARKBLUE=@18/*_COLOR_DARKBLUE*/
132 | _COLOR_DARKYELLOW=@19/*_COLOR_DARKYELLOW*/
133 | _COLOR_VIOLET=@20/*_COLOR_VIOLET*/
134 | _COLOR_TEAL=@21/*_COLOR_TEAL*/
135 | _COLOR_GRAY25=@22/*_COLOR_GRAY25*/
136 | _COLOR_GRAY50=@23/*_COLOR_GRAY50*/
137 | _COLOR_PERIWINKLE_CF=@24/*_COLOR_PERIWINKLE_CF*/
138 | _COLOR_PLUM_CF=@25/*_COLOR_PLUM_CF*/
139 | _COLOR_IVORY_CF=@26/*_COLOR_IVORY_CF*/
140 | _COLOR_LIGHTTURQUOISE_CF=@27/*_COLOR_LIGHTTURQUOISE_CF*/
141 | _COLOR_DARKPURPLE_CF=@28/*_COLOR_DARKPURPLE_CF*/
142 | _COLOR_CORAL_CF=@29/*_COLOR_CORAL_CF*/
143 | _COLOR_OCEANBLUE_CF=@30/*_COLOR_OCEANBLUE_CF*/
144 | _COLOR_ICEBLUE_CF=@31/*_COLOR_ICEBLUE_CF*/
145 | _COLOR_DARKBLUE_CL=@32/*_COLOR_DARKBLUE_CL*/
146 | _COLOR_PINK_CL=@33/*_COLOR_PINK_CL*/
147 | _COLOR_YELLOW_CL=@34/*_COLOR_YELLOW_CL*/
148 | _COLOR_TURQUOISE_CL=@35/*_COLOR_TURQUOISE_CL*/
149 | _COLOR_VIOLET_CL=@36/*_COLOR_VIOLET_CL*/
150 | _COLOR_DARKRED_CL=@37/*_COLOR_DARKRED_CL*/
151 | _COLOR_TEAL_CL=@38/*_COLOR_TEAL_CL*/
152 | _COLOR_BLUE_CL=@39/*_COLOR_BLUE_CL*/
153 | _COLOR_SKYBLUE=@40/*_COLOR_SKYBLUE*/
154 | _COLOR_LIGHTTURQUOISE=@41/*_COLOR_LIGHTTURQUOISE*/
155 | _COLOR_LIGHTGREEN=@42/*_COLOR_LIGHTGREEN*/
156 | _COLOR_LIGHTYELLOW=@43/*_COLOR_LIGHTYELLOW*/
157 | _COLOR_PALEBLUE=@44/*_COLOR_PALEBLUE*/
158 | _COLOR_ROSE=@45/*_COLOR_ROSE*/
159 | _COLOR_LAVENDER=@46/*_COLOR_LAVENDER*/
160 | _COLOR_TAN=@47/*_COLOR_TAN*/
161 | _COLOR_LIGHTBLUE=@48/*_COLOR_LIGHTBLUE*/
162 | _COLOR_AQUA=@49/*_COLOR_AQUA*/
163 | _COLOR_LIME=@50/*_COLOR_LIME*/
164 | _COLOR_GOLD=@51/*_COLOR_GOLD*/
165 | _COLOR_LIGHTORANGE=@52/*_COLOR_LIGHTORANGE*/
166 | _COLOR_ORANGE=@53/*_COLOR_ORANGE*/
167 | _COLOR_BLUEGRAY=@54/*_COLOR_BLUEGRAY*/
168 | _COLOR_GRAY40=@55/*_COLOR_GRAY40*/
169 | _COLOR_DARKTEAL=@56/*_COLOR_DARKTEAL*/
170 | _COLOR_SEAGREEN=@57/*_COLOR_SEAGREEN*/
171 | _COLOR_DARKGREEN=@58/*_COLOR_DARKGREEN*/
172 | _COLOR_OLIVEGREEN=@59/*_COLOR_OLIVEGREEN*/
173 | _COLOR_BROWN=@60/*_COLOR_BROWN*/
174 | _COLOR_PLUM=@61/*_COLOR_PLUM*/
175 | _COLOR_INDIGO=@62/*_COLOR_INDIGO*/
176 | _COLOR_GRAY80=@63/*_COLOR_GRAY80*/
177 | _COLOR_DEFAULT_FOREGROUND=@64/*_COLOR_DEFAULT_FOREGROUND*/
178 | _COLOR_DEFAULT_BACKGROUND=@65/*_COLOR_DEFAULT_BACKGROUND*/
179 | _UNDERLINE_NONE=@0/*_UNDERLINE_NONE*/
180 | _UNDERLINE_SINGLE=@1/*_UNDERLINE_SINGLE*/
181 | _UNDERLINE_DOUBLE=@2/*_UNDERLINE_DOUBLE*/
182 | _UNDERLINE_SINGLEACC=@3/*_UNDERLINE_SINGLEACC*/
183 | _UNDERLINE_DOUBLEACC=@4/*_UNDERLINE_DOUBLEACC*/
184 | _SCRIPT_NORMAL=@0/*_SCRIPT_NORMAL*/
185 | _SCRIPT_SUPER=@1/*_SCRIPT_SUPER*/
186 | _SCRIPT_SUB=@2/*_SCRIPT_SUB*/
187 | end intellisense**/
--------------------------------------------------------------------------------
/libxl/format.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class Format{
8 | ctor( hwnd,p_shformat ){
9 | if !hwnd return null,"请指定格式句柄";
10 | this.hwnd = hwnd;
11 | this.p_shformat = p_shformat;
12 | };
13 | @_metaProperty;
14 | }
15 |
16 | namespace Format{
17 | _metaProperty = ..util.metaProperty(
18 | font = {
19 | _get = function(){
20 | var hwnd = Font(owner.hwnd)
21 | if !hwnd return hwnd;
22 | var s_font = owner.p_shformat.Fonts(hwnd);
23 | return s_font;
24 | };
25 | _set = function( fonts ){
26 | var hFont = fonts;
27 | if type(fonts) == type.table hFont = fonts.hwnd
28 | if !owner.p_shformat.Fonts[tonumber(hFont)]{
29 | hFont = owner.p_shformat.book.addFont(hFont).hwnd
30 | }
31 | return SetFont(owner.hwnd,hFont);
32 | };
33 | };
34 | numStyle = {
35 | _get = function(){
36 | return (NumFormat(owner.hwnd)+1);
37 | };
38 | _set = function( v ){
39 | SetNumFormat(owner.hwnd,v - 1);
40 | };
41 | };
42 | alignH = {
43 | _get = function(){
44 | return AlignH(owner.hwnd);
45 | };
46 | _set = function( v ){
47 | SetAlignH(owner.hwnd,v);
48 | };
49 | };
50 | alignV = {
51 | _get = function(){
52 | return AlignV(owner.hwnd);
53 | };
54 | _set = function( v ){
55 | SetAlignV(owner.hwnd,v);
56 | };
57 | };
58 | wrap = {
59 | _get = function(){
60 | return Wrap(owner.hwnd);
61 | };
62 | _set = function( v ){
63 | SetWrap(owner.hwnd,tonumber(v));
64 | };
65 | };
66 | rotation = {
67 | _get = function(){
68 | return Rotation(owner.hwnd);
69 | };
70 | _set = function( v ){
71 | return SetRotation(owner.hwnd,v);
72 | };
73 | };
74 | indent = {
75 | _get = function(){
76 | return Indent(owner.hwnd);
77 | };
78 | _set = function( v ){
79 | return SetIndent(owner.hwnd,v);
80 | };
81 | };
82 | fit = {
83 | _get = function(){
84 | return ShrinkToFit(owner.hwnd);
85 | };
86 | _set = function( v ){
87 | return SetShrinkToFit(owner.hwnd,tonumber(v));
88 | };
89 | };
90 | shrinkToFit = {
91 | _get = function(){
92 | return ShrinkToFit(owner.hwnd);
93 | };
94 | _set = function( v ){
95 | return SetShrinkToFit(owner.hwnd,tonumber(v));
96 | };
97 | };
98 | borderStyle = {
99 | _get = function(){
100 | return null;
101 | };
102 | _set = function(v){
103 | SetBorder(owner.hwnd,v);
104 | };
105 | };
106 | borderColor = {
107 | _get = function(){
108 | return null;
109 | };
110 | _set = function( v ){
111 | SetBorderColor(owner.hwnd,v);
112 | };
113 | };
114 | borderLeft = {
115 | _get = function(){
116 | return BorderLeft(owner.hwnd);
117 | };
118 | _set = function( v ){
119 | SetBorderLeft(owner.hwnd,v);
120 | };
121 | };
122 | borderRight = {
123 | _get = function(){
124 | return BorderRight(owner.hwnd);
125 | };
126 | _set = function( v ){
127 | SetBorderRight(owner.hwnd,v);
128 | };
129 | };
130 | borderTop = {
131 | _get = function(){
132 | return BorderTop(owner.hwnd);
133 | };
134 | _set = function( v ){
135 | SetBorderTop(owner.hwnd,v);
136 | };
137 | };
138 | borderBottom = {
139 | _get = function(){
140 | return BorderBottom(owner.hwnd);
141 | };
142 | _set = function( v ){
143 | SetBorderBottom(owner.hwnd,v);
144 | };
145 | };
146 | borderLeftColor = {
147 | _get = function(){
148 | return BorderLeftColor(owner.hwnd);
149 | };
150 | _set = function( v ){
151 | SetBorderLeftColor(owner.hwnd,v);
152 | };
153 | };
154 | borderRightColor = {
155 | _get = function(){
156 | return BorderRightColor(owner.hwnd);
157 | };
158 | _set = function( v ){
159 | SetBorderRightColor(owner.hwnd,v);
160 | };
161 | };
162 | borderTopColor = {
163 | _get = function(){
164 | return BorderTopColor(owner.hwnd);
165 | };
166 | _set = function( v ){
167 | SetBorderTopColor(owner.hwnd,v);
168 | };
169 | };
170 | borderBottomColor = {
171 | _get = function(){
172 | return BorderBottomColor(owner.hwnd);
173 | };
174 | _set = function( v ){
175 | SetBorderBottomColor(owner.hwnd,v);
176 | };
177 | };
178 | borderDiagonal = {
179 | _get = function(){
180 | return BorderDiagonal(owner.hwnd);
181 | };
182 | _set = function( v ){
183 | SetBorderDiagonal(owner.hwnd,v);
184 | };
185 | };
186 | borderDiagonalStyle = {
187 | _get = function(){
188 | return BorderDiagonalStyle(owner.hwnd);
189 | };
190 | _set = function( v ){
191 | SetBorderDiagonalStyle(owner.hwnd,v);
192 | };
193 | };
194 | borderDiagonalColor = {
195 | _get = function(){
196 | return BorderDiagonalColor(owner.hwnd);
197 | };
198 | _set = function( v ){
199 | SetBorderDiagonalColor(owner.hwnd,v);
200 | };
201 | };
202 | pattern = {
203 | _get = function(){
204 | return FillPattern(owner.hwnd);
205 | };
206 | _set = function( v ){
207 | SetFillPattern(owner.hwnd,v);
208 | };
209 | };
210 | patternForeColor = {
211 | _get = function(){
212 | return PatternForegroundColor(owner.hwnd);
213 | };
214 | _set = function( v ){
215 | SetPatternForegroundColor(owner.hwnd,v);
216 | };
217 | };
218 | patternBackColor = {
219 | _get = function(){
220 | return PatternBackgroundColor(owner.hwnd);
221 | };
222 | _set = function( v ){
223 | SetPatternBackgroundColor(owner.hwnd,v);
224 | };
225 | };
226 | lock = {
227 | _get = function(){
228 | return Locked(owner.hwnd);
229 | };
230 | _set = function( v ){
231 | SetLocked(owner.hwnd,tonumber(v));
232 | };
233 | };
234 | hidden = {
235 | _get = function(){
236 | return Hidden(owner.hwnd);
237 | };
238 | _set = function( v ){
239 | SetHidden(owner.hwnd,tonumber(v));
240 | };
241 | };
242 | )
243 |
244 |
245 | Font = libxl32.api("xlFormatFont","ptr(ptr FormatHandle)")//FontHandle
246 | SetFont = libxl32.api("xlFormatSetFont","int(ptr FormatHandle, ptr ))")
247 |
248 | NumFormat = libxl32.api("xlFormatNumFormat","int(ptr FormatHandle)")
249 | SetNumFormat = libxl32.api("xlFormatSetNumFormat","void(ptr FormatHandle, int numFormat)")
250 |
251 | AlignH = libxl32.api("xlFormatAlignH","int(ptr FormatHandle)")
252 | SetAlignH = libxl32.api("xlFormatSetAlignH","void(ptr FormatHandle, int align)")
253 | AlignV = libxl32.api("xlFormatAlignV","int(ptr FormatHandle)")
254 | SetAlignV = libxl32.api("xlFormatSetAlignV","void(ptr FormatHandle, int align)")
255 |
256 | Wrap = libxl32.api("xlFormatWrap","int(ptr FormatHandle)")
257 | SetWrap = libxl32.api("xlFormatSetWrap","void(ptr FormatHandle, int wrap)")
258 |
259 | Rotation = libxl32.api("xlFormatRotation","int(ptr FormatHandle)")
260 | SetRotation = libxl32.api("xlFormatSetRotation","int(ptr FormatHandle, int rotation)")
261 |
262 | Indent = libxl32.api("xlFormatIndent","int(ptr FormatHandle)")
263 | SetIndent = libxl32.api("xlFormatSetIndent","void(ptr FormatHandle, int indent)")
264 |
265 | ShrinkToFit = libxl32.api("xlFormatShrinkToFit","int(ptr FormatHandle)")
266 | SetShrinkToFit = libxl32.api("xlFormatSetShrinkToFit","void(ptr FormatHandle, int shrinkToFit)")
267 |
268 | SetBorder = libxl32.api("xlFormatSetBorder","void(ptr FormatHandle, int style)")
269 | SetBorderColor = libxl32.api("xlFormatSetBorderColor","void(ptr FormatHandle, int color)")
270 | BorderLeft = libxl32.api("xlFormatBorderLeft","int(ptr FormatHandle)")
271 | SetBorderLeft = libxl32.api("xlFormatSetBorderLeft","void(ptr FormatHandle, int style)")
272 | BorderRight = libxl32.api("xlFormatBorderRight","int(ptr FormatHandle)")
273 | SetBorderRight = libxl32.api("xlFormatSetBorderRight","void(ptr FormatHandle, int style)")
274 | BorderTop = libxl32.api("xlFormatBorderTop","int(ptr FormatHandle)")
275 | SetBorderTop = libxl32.api("xlFormatSetBorderTop","void(ptr FormatHandle, int style)")
276 | BorderBottom = libxl32.api("xlFormatBorderBottom","int(ptr FormatHandle)")
277 | SetBorderBottom = libxl32.api("xlFormatSetBorderBottom","void(ptr FormatHandle, int style)")
278 |
279 | BorderLeftColor = libxl32.api("xlFormatBorderLeftColor","int(ptr FormatHandle)")
280 | SetBorderLeftColor = libxl32.api("xlFormatSetBorderLeftColor","void(ptr FormatHandle, int color)")
281 | BorderRightColor = libxl32.api("xlFormatBorderRightColor","int(ptr FormatHandle)")
282 | SetBorderRightColor = libxl32.api("xlFormatSetBorderRightColor","void(ptr FormatHandle, int color)")
283 | BorderTopColor = libxl32.api("xlFormatBorderTopColor","int(ptr FormatHandle)")
284 | SetBorderTopColor = libxl32.api("xlFormatSetBorderTopColor","void(ptr FormatHandle, int color)")
285 | BorderBottomColor = libxl32.api("xlFormatBorderBottomColor","int(ptr FormatHandle)")
286 | SetBorderBottomColor = libxl32.api("xlFormatSetBorderBottomColor","void(ptr FormatHandle, int color)")
287 |
288 | BorderDiagonal = libxl32.api("xlFormatBorderDiagonal","int(ptr FormatHandle)")
289 | SetBorderDiagonal = libxl32.api("xlFormatSetBorderDiagonal","void(ptr FormatHandle, int border)")
290 | BorderDiagonalStyle = libxl32.api("xlFormatBorderDiagonalStyle","int(ptr FormatHandle)")
291 | SetBorderDiagonalStyle = libxl32.api("xlFormatSetBorderDiagonalStyle","void(ptr FormatHandle, int style)")
292 | BorderDiagonalColor = libxl32.api("xlFormatBorderDiagonalColor","int(ptr FormatHandle)")
293 | SetBorderDiagonalColor = libxl32.api("xlFormatSetBorderDiagonalColor","void(ptr FormatHandle, int color)")
294 |
295 | FillPattern = libxl32.api("xlFormatFillPattern","int(ptr FormatHandle)")
296 | SetFillPattern = libxl32.api("xlFormatSetFillPattern","void(ptr FormatHandle, int pattern)")
297 | PatternForegroundColor = libxl32.api("xlFormatPatternForegroundColor","int(ptr FormatHandle)")
298 | SetPatternForegroundColor = libxl32.api("xlFormatSetPatternForegroundColor","void(ptr FormatHandle, int color)")
299 | PatternBackgroundColor = libxl32.api("xlFormatPatternBackgroundColor","int(ptr FormatHandle)")
300 | SetPatternBackgroundColor = libxl32.api("xlFormatSetPatternBackgroundColor","void(ptr FormatHandle, int color)")
301 |
302 | Locked = libxl32.api("xlFormatLocked","int(ptr FormatHandle)")
303 | SetLocked = libxl32.api("xlFormatSetLocked","void(ptr FormatHandle, int locked)")
304 |
305 | Hidden = libxl32.api("xlFormatHidden","int(ptr FormatHandle)")
306 | SetHidden = libxl32.api("xlFormatSetHidden","void(ptr FormatHandle, int hidden)")
307 |
308 | }
309 |
310 | /**intellisense()
311 | libxl.Format() = !xlFormat.
312 | !libxl.Format() = !xlFormat.
313 | !libxl.addFormat() = !xlFormat.
314 | !xlFormat.font = 字体
315 | !xlFormat.font = !xlFont.
316 | !xlFormat.numStyle = 数字格式,_NUMFORMAT_
317 | !xlFormat.alignH = 水平对齐样式,_ALIGNH_
318 | !xlFormat.alignV = 垂直对齐样式,_ALIGNV
319 | !xlFormat.wrap = 环绕
320 | !xlFormat.rotation = 旋转角度,默认255
321 | !xlFormat.indent = 凹陷程度,小于等于15
322 | !xlFormat.fit = 自适应宽度
323 | !xlFormat.shrinkToFit = 自适应宽度
324 | !xlFormat.borderStyle = 边框样式,_BORDERSTYLE_
325 | !xlFormat.borderColor = 边框颜色
326 | !xlFormat.borderLeft = 左边框样式
327 | !xlFormat.borderRight = 右边框样式
328 | !xlFormat.borderTop = 上边框样式
329 | !xlFormat.borderBottom = 下边框样式
330 | !xlFormat.borderLeftColor = 左边框颜色
331 | !xlFormat.borderRightColor = 右边框颜色
332 | !xlFormat.borderTopColor = 上边框颜色
333 | !xlFormat.borderBottomColor = 下边框颜色
334 | !xlFormat.borderDiagonal = 对角线边框,_BORDERDIAGONAL_
335 | !xlFormat.borderDiagonalStyle = 对角线边框样式
336 | !xlFormat.borderDiagonalColor = 对角线边框颜色
337 | !xlFormat.pattern = 填充样式,_FILLPATTERN_
338 | !xlFormat.patternForeColor = 样式前景色
339 | !xlFormat.patternBackColor = 样式背景色
340 | !xlFormat.lock = 锁定单元格
341 | !xlFormat.hidden = 隐藏单元格
342 | _NUMFORMAT_GENERAL=@1/*_NUMFORMAT_GENERAL*/
343 | _NUMFORMAT_NUMBER=@2/*_NUMFORMAT_NUMBER*/
344 | _NUMFORMAT_NUMBER_D2=@3/*_NUMFORMAT_NUMBER_D2*/
345 | _NUMFORMAT_NUMBER_SEP=@4/*_NUMFORMAT_NUMBER_SEP*/
346 | _NUMFORMAT_NUMBER_SEP_D2=@5/*_NUMFORMAT_NUMBER_SEP_D2*/
347 | _NUMFORMAT_CURRENCY_NEGBRA=@6/*_NUMFORMAT_CURRENCY_NEGBRA*/
348 | _NUMFORMAT_CURRENCY_NEGBRARED=@7/*_NUMFORMAT_CURRENCY_NEGBRARED*/
349 | _NUMFORMAT_CURRENCY_D2_NEGBRA=@8/*_NUMFORMAT_CURRENCY_D2_NEGBRA*/
350 | _NUMFORMAT_CURRENCY_D2_NEGBRARED=@9/*_NUMFORMAT_CURRENCY_D2_NEGBRARED*/
351 | _NUMFORMAT_PERCENT=@10/*_NUMFORMAT_PERCENT*/
352 | _NUMFORMAT_PERCENT_D2=@11/*_NUMFORMAT_PERCENT_D2*/
353 | _NUMFORMAT_SCIENTIFIC_D2=@12/*_NUMFORMAT_SCIENTIFIC_D2*/
354 | _NUMFORMAT_FRACTION_ONEDIG=@13/*_NUMFORMAT_FRACTION_ONEDIG*/
355 | _NUMFORMAT_FRACTION_TWODIG=@14/*_NUMFORMAT_FRACTION_TWODIG*/
356 | _NUMFORMAT_DATE=@15/*_NUMFORMAT_DATE*/
357 | _NUMFORMAT_CUSTOM_D_MON_YY=@16/*_NUMFORMAT_CUSTOM_D_MON_YY*/
358 | _NUMFORMAT_CUSTOM_D_MON=@17/*_NUMFORMAT_CUSTOM_D_MON*/
359 | _NUMFORMAT_CUSTOM_MON_YY=@18/*_NUMFORMAT_CUSTOM_MON_YY*/
360 | _NUMFORMAT_CUSTOM_HMM_AM=@19/*_NUMFORMAT_CUSTOM_HMM_AM*/
361 | _NUMFORMAT_CUSTOM_HMMSS_AM=@20/*_NUMFORMAT_CUSTOM_HMMSS_AM*/
362 | _NUMFORMAT_CUSTOM_HMM=@21/*_NUMFORMAT_CUSTOM_HMM*/
363 | _NUMFORMAT_CUSTOM_HMMSS=@22/*_NUMFORMAT_CUSTOM_HMMSS*/
364 | _NUMFORMAT_CUSTOM_MDYYYY_HMM=@23/*_NUMFORMAT_CUSTOM_MDYYYY_HMM*/
365 | _NUMFORMAT_NUMBER_SEP_NEGBRA=@24/*_NUMFORMAT_NUMBER_SEP_NEGBRA*/
366 | _NUMFORMAT_NUMBER_SEP_NEGBRARED=@25/*_NUMFORMAT_NUMBER_SEP_NEGBRARED*/
367 | _NUMFORMAT_NUMBER_D2_SEP_NEGBRA=@26/*_NUMFORMAT_NUMBER_D2_SEP_NEGBRA*/
368 | _NUMFORMAT_NUMBER_D2_SEP_NEGBRARED=@27/*_NUMFORMAT_NUMBER_D2_SEP_NEGBRARED*/
369 | _NUMFORMAT_ACCOUNT=@28/*_NUMFORMAT_ACCOUNT*/
370 | _NUMFORMAT_ACCOUNTCUR=@29/*_NUMFORMAT_ACCOUNTCUR*/
371 | _NUMFORMAT_ACCOUNT_D2=@30/*_NUMFORMAT_ACCOUNT_D2*/
372 | _NUMFORMAT_ACCOUNT_D2_CUR=@31/*_NUMFORMAT_ACCOUNT_D2_CUR*/
373 | _NUMFORMAT_CUSTOM_MMSS=@32/*_NUMFORMAT_CUSTOM_MMSS*/
374 | _NUMFORMAT_CUSTOM_H0MMSS=@33/*_NUMFORMAT_CUSTOM_H0MMSS*/
375 | _NUMFORMAT_CUSTOM_MMSS0=@34/*_NUMFORMAT_CUSTOM_MMSS0*/
376 | _NUMFORMAT_CUSTOM_000P0E_PLUS0=@35/*_NUMFORMAT_CUSTOM_000P0E_PLUS0*/
377 | _NUMFORMAT_TEXT=@36/*_NUMFORMAT_TEXT*/
378 | _ALIGNH_GENERAL=@0/*ALIGNH_GENERAL*/
379 | _ALIGNH_LEFT=@1/*ALIGNH_LEFT*/
380 | _ALIGNH_CENTER=@2/*ALIGNH_CENTER*/
381 | _ALIGNH_RIGHT=@3/*ALIGNH_RIGHT*/
382 | _ALIGNH_FILL=@4/*ALIGNH_FILL*/
383 | _ALIGNH_JUSTIFY=@5/*ALIGNH_JUSTIFY*/
384 | _ALIGNH_MERGE=@6/*ALIGNH_MERGE*/
385 | _ALIGNH_DISTRIBUTED=@7/*ALIGNH_DISTRIBUTED*/
386 | _ALIGNV_TOP=@0/*ALIGNV_TOP*/
387 | _ALIGNV_CENTER=@1/*ALIGNV_CENTER*/
388 | _ALIGNV_BOTTOM=@2/*ALIGNV_BOTTOM*/
389 | _ALIGNV_JUSTIFY=@3/*ALIGNV_JUSTIFY*/
390 | _ALIGNV_DISTRIBUTED=@4/*ALIGNV_DISTRIBUTED*/
391 | _BORDERSTYLE_NONE=@0/*BORDERSTYLE_NONE*/
392 | _BORDERSTYLE_THIN=@1/*BORDERSTYLE_THIN*/
393 | _BORDERSTYLE_MEDIUM=@2/*BORDERSTYLE_MEDIUM*/
394 | _BORDERSTYLE_DASHED=@3/*BORDERSTYLE_DASHED*/
395 | _BORDERSTYLE_DOTTED=@4/*BORDERSTYLE_DOTTED*/
396 | _BORDERSTYLE_THICK=@5/*BORDERSTYLE_THICK*/
397 | _BORDERSTYLE_DOUBLE=@6/*BORDERSTYLE_DOUBLE*/
398 | _BORDERSTYLE_HAIR=@7/*BORDERSTYLE_HAIR*/
399 | _BORDERSTYLE_MEDIUMDASHED=@8/*BORDERSTYLE_MEDIUMDASHED*/
400 | _BORDERSTYLE_DASHDOT=@9/*BORDERSTYLE_DASHDOT*/
401 | _BORDERSTYLE_MEDIUMDASHDOT=@10/*BORDERSTYLE_MEDIUMDASHDOT*/
402 | _BORDERSTYLE_DASHDOTDOT=@11/*BORDERSTYLE_DASHDOTDOT*/
403 | _BORDERSTYLE_MEDIUMDASHDOTDOT=@12/*BORDERSTYLE_MEDIUMDASHDOTDOT*/
404 | _BORDERSTYLE_SLANTDASHDOT=@13/*BORDERSTYLE_SLANTDASHDOT*/
405 | _BORDERDIAGONAL_NONE=@0/*BORDERDIAGONAL_NONE*/
406 | _BORDERDIAGONAL_DOWN=@1/*BORDERDIAGONAL_DOWN*/
407 | _BORDERDIAGONAL_UP=@2/*BORDERDIAGONAL_UP*/
408 | _BORDERDIAGONAL_BOTH=@3/*BORDERDIAGONAL_BOTH*/
409 | _FILLPATTERN_NONE=@0/*FILLPATTERN_NONE*/
410 | _FILLPATTERN_SOLID=@1/*FILLPATTERN_SOLID*/
411 | _FILLPATTERN_GRAY50=@2/*FILLPATTERN_GRAY50*/
412 | _FILLPATTERN_GRAY75=@3/*FILLPATTERN_GRAY75*/
413 | _FILLPATTERN_GRAY25=@4/*FILLPATTERN_GRAY25*/
414 | _FILLPATTERN_HORSTRIPE=@5/*FILLPATTERN_HORSTRIPE*/
415 | _FILLPATTERN_VERSTRIPE=@6/*FILLPATTERN_VERSTRIPE*/
416 | _FILLPATTERN_REVDIAGSTRIPE=@7/*FILLPATTERN_REVDIAGSTRIPE*/
417 | _FILLPATTERN_DIAGSTRIPE=@8/*FILLPATTERN_DIAGSTRIPE*/
418 | _FILLPATTERN_DIAGCROSSHATCH=@9/*FILLPATTERN_DIAGCROSSHATCH*/
419 | _FILLPATTERN_THICKDIAGCROSSHATCH=@10/*FILLPATTERN_THICKDIAGCROSSHATCH*/
420 | _FILLPATTERN_THINHORSTRIPE=@11/*FILLPATTERN_THINHORSTRIPE*/
421 | _FILLPATTERN_THINVERSTRIPE=@12/*FILLPATTERN_THINVERSTRIPE*/
422 | _FILLPATTERN_THINREVDIAGSTRIPE=@13/*FILLPATTERN_THINREVDIAGSTRIPE*/
423 | _FILLPATTERN_THINDIAGSTRIPE=@14/*FILLPATTERN_THINDIAGSTRIPE*/
424 | _FILLPATTERN_THINHORCROSSHATCH=@15/*FILLPATTERN_THINHORCROSSHATCH*/
425 | _FILLPATTERN_THINDIAGCROSSHATCH=@16/*FILLPATTERN_THINDIAGCROSSHATCH*/
426 | _FILLPATTERN_GRAY12P5=@17/*FILLPATTERN_GRAY12P5*/
427 | _FILLPATTERN_GRAY6P25=@18/*FILLPATTERN_GRAY6P25*/
428 | end intellisense**/
--------------------------------------------------------------------------------
/libxl/sheet.aardio:
--------------------------------------------------------------------------------
1 | import util.metaProperty;
2 |
3 | namespace libxl;
4 |
5 | var libxl32 = _dll;
6 |
7 | class Sheet{
8 | ctor( hwnd,p_shformat ){
9 | if !hwnd return null,"请指定工作表句柄";
10 | this.hwnd = hwnd;
11 | this.Cell = Cell(this.hwnd);
12 | this.Cell.owner = this;//确保可调用父对象
13 | this.Column = Column(this.hwnd);
14 | this.Row = Row(this.hwnd);
15 | this.Range = Range(this.hwnd);
16 | this.Range.owner= this;//确保可调用父对象
17 | this.Cells = {//特殊的取值方法
18 | @{
19 | _get = function(k){//取值
20 | return this.Cell(k); //转回
21 | };
22 | _call = function(...){//调用
23 | return this.Cell(...);
24 | }
25 | }
26 | }
27 | this.p_shformat = p_shformat;//格式对象
28 | };
29 | @_metaProperty;
30 | }
31 |
32 | namespace Sheet{
33 | _metaProperty = ..util.metaProperty(
34 | name = { //工作表名
35 | _get = function(){
36 | return Name(owner.hwnd);
37 | }
38 | _set = function( v ){
39 | return SetName(owner.hwnd,v);
40 | }
41 | };
42 | mergeCount = {
43 | _get = function(){
44 | return MergeSize(owner.hwnd);
45 | }
46 | };
47 | pictureCount = {
48 | _get = function(){
49 | return PictureSize(owner.hwnd);
50 | }
51 | };
52 | horPageBreakCount = {
53 | _get = function(){
54 | return GetHorPageBreakSize(owner.hwnd);
55 | }
56 | };
57 | verPageBreakCount = {
58 | _get = function(){
59 | return GetVerPageBreakSize(owner.hwnd);
60 | }
61 | };
62 | split = {
63 | _get = function(){
64 | var int = 1
65 | var ok,row,col = SplitInfo(owner.hwnd,int,int);
66 | var cell = {row = row + 1; col = col + 1}
67 | if ok return cell;
68 | return null;
69 | }
70 | };
71 | groupSummaryBelow = {
72 | _get = function(){
73 | return GroupSummaryBelow(owner.hwnd);
74 | }
75 | _set = function( v ){
76 | return SetGroupSummaryBelow(owner.hwnd,tonumber(v));
77 | }
78 | };
79 | groupSummaryRight = {
80 | _get = function(){
81 | return groupSummaryRight(owner.hwnd);
82 | }
83 | _set = function( v ){
84 | return SetGroupSummaryRight(owner.hwnd,tonumber(v));
85 | }
86 | };
87 | firstRow = {
88 | _get = function(){
89 | return FirstRow(owner.hwnd) + 1;
90 | }
91 | }
92 | lastRow = {
93 | _get = function(){
94 | return LastRow(owner.hwnd);
95 | }
96 | }
97 | firstCol = {
98 | _get = function(){
99 | return FirstCol(owner.hwnd) + 1;
100 | }
101 | }
102 | lastCol = {
103 | _get = function(){
104 | return LastCol(owner.hwnd);
105 | }
106 | }
107 | displayGridlines = {
108 | _get = function(){
109 | return DisplayGridlines(owner.hwnd);
110 | }
111 | _set = function( v ){
112 | SetDisplayGridlines(owner.hwnd,tonumber(v));
113 | }
114 | };
115 | printGridlines = {
116 | _get = function(){
117 | return PrintGridlines(owner.hwnd);
118 | };
119 | _set = function( v ){
120 | SetPrintGridlines(owner.hwnd,tonumber(v));
121 | };
122 | };
123 | zoom = {
124 | _get = function(){
125 | return Zoom(owner.hwnd);
126 | };
127 | _set = function( v ){
128 | SetZoom(owner.hwnd,v);
129 | };
130 | };
131 | printZoom = {
132 | _get = function(){
133 | return PrintZoom(owner.hwnd);
134 | };
135 | _set = function( v ){
136 | SetPrintZoom(owner.hwnd,v);
137 | };
138 | };
139 | landscape = {
140 | _get = function(){
141 | return Landscape(owner.hwnd);
142 | };
143 | _set = function( v ){
144 | SetLandscape(owner.hwnd,tonumber(v));
145 | };
146 | };
147 | paperSize = {
148 | _get = function(){
149 | return Paper(owner.hwnd);
150 | };
151 | _set = function( v ){
152 | SetPaper(owner.hwnd,v);
153 | };
154 | };
155 | header = {
156 | _get = function(){
157 | return Header(owner.hwnd);
158 | };
159 | _set = function( v ){
160 | var hMargin = HeaderMargin(owner.hwnd)
161 | return SetPaper(owner.hwnd,v,hMargin);
162 | };
163 | };
164 | headerMargin = {
165 | _get = function(){
166 | return HeaderMargin(owner.hwnd);
167 | };
168 | _set = function( v ){
169 | var hText = Header(owner.hwnd)
170 | return SetPaper(owner.hwnd,hText,v);
171 | };
172 | };
173 | footer = {
174 | _get = function(){
175 | return Footer(owner.hwnd);
176 | };
177 | _set = function( v ){
178 | var hMargin = FooterMargin(owner.hwnd)
179 | return SetFooter(owner.hwnd,v,hMargin);
180 | };
181 | };
182 | footerMargin = {
183 | _get = function(){
184 | return FooterMargin(owner.hwnd);
185 | };
186 | _set = function( v ){
187 | var hText = Footer(owner.hwnd)
188 | return SetFooter(owner.hwnd,hText,v);
189 | };
190 | };
191 | hCenter = {
192 | _get = function(){
193 | return HCenter(owner.hwnd);
194 | };
195 | _set = function( v ){
196 | SetHCenter(owner.hwnd,tonumber(v));
197 | };
198 | };
199 | vCenter = {
200 | _get = function(){
201 | return VCenter(owner.hwnd);
202 | };
203 | _set = function( v ){
204 | SetVCenter(owner.hwnd,tonumber(v));
205 | };
206 | };
207 | marginLeft = {
208 | _get = function(){
209 | return MarginLeft(owner.hwnd);
210 | };
211 | _set = function( v ){
212 | SetMarginLeft(owner.hwnd,v);
213 | };
214 | };
215 | marginRight = {
216 | _get = function(){
217 | return MarginRight(owner.hwnd);
218 | };
219 | _set = function( v ){
220 | SetMarginRight(owner.hwnd,v);
221 | };
222 | };
223 | marginTop = {
224 | _get = function(){
225 | return MarginTop(owner.hwnd);
226 | };
227 | _set = function( v ){
228 | SetMarginTop(owner.hwnd,v);
229 | };
230 | };
231 | marginBottom = {
232 | _get = function(){
233 | return MarginBottom(owner.hwnd);
234 | };
235 | _set = function( v ){
236 | SetMarginBottom(owner.hwnd,v);
237 | };
238 | };
239 | printRowCol = {
240 | _get = function(){
241 | return PrintRowCol(owner.hwnd);
242 | };
243 | _set = function( v ){
244 | SetPrintRowCol(owner.hwnd,tonumber(v));
245 | };
246 | };
247 | namedRangeCount = {
248 | _get = function(){
249 | return NamedRangeSize(owner.hwnd);
250 | };
251 | }
252 | hyperlinkCount = {
253 | _get = function(){
254 | return HyperlinkSize(owner.hwnd);
255 | };
256 | }
257 | protect = {
258 | _get = function(){
259 | if Protect(owner.hwnd) return true;
260 | return false;
261 | };
262 | _set = function( v ){
263 | SetProtect(owner.hwnd,tonumber(v));
264 | };
265 | };
266 | rightToLeft = {
267 | _get = function(){
268 | return RightToLeft(owner.hwnd);
269 | };
270 | _set = function( v ){
271 | SetRightToLeft(owner.hwnd,tonumber(v));
272 | };
273 | };
274 | hidden = {
275 | _get = function(){
276 | return Hidden(owner.hwnd);
277 | };
278 | _set = function( v ){
279 | return SetHidden(owner.hwnd,v);
280 | };
281 | };
282 | merge = {
283 | _set = function( v ){
284 | if type(v) != type.table error("请使用cellRange对象填充数据")
285 | SetMerge(owner.hwnd,v.iniRow -1,v.lastRow -1,v.iniCol -1,v.lastCol -1);
286 | };
287 | };
288 | tableNum = {//table数量
289 | _get = function(){
290 | return TableSize(owner.hwnd);
291 | }
292 |
293 | }
294 | tabColor = {
295 | _set = function(v){
296 | SetTabColor(owner.hwnd,v);
297 | }
298 | }
299 | usedRange = {
300 | _get = function(){
301 | var cellRange = ..libxl.cellRange(owner.firstRow,owner.lastRow,owner.firstCol,owner.lastCol);
302 | var address = ..string.concat(owner.rowColToAddr(cellRange.iniRow,cellRange.iniCol),":",owner.rowColToAddr(cellRange.lastRow,cellRange.lastCol));
303 | return owner.Range(address);
304 | }
305 | }
306 | //函数方法
307 | setMerge = function(iniRow,lastRow,iniCol,lastCol){
308 | if iniRow && lastRow && iniCol && lastCol return SetMerge(owner.hwnd,iniRow-1,lastRow-1,iniCol-1,lastCol-1);
309 | return false;
310 | };
311 | delMerge = function(index){//delbyindex
312 | return DelMergeByIndex(owner.hwnd,index - 1);
313 | };
314 | getMerge = function(index){
315 | var int = 1
316 | var result,iniRow,lastRow,iniCol,lastCol = Merge(owner.hwnd,index - 1,int,int,int,int);
317 | if result == 0 return null;
318 | var mergeCells = ..libxl.cellRange();
319 | mergeCells.iniCol = iniCol + 1;
320 | mergeCells.lastCol = lastCol + 1;
321 | mergeCells.iniRow = iniRow + 1;
322 | mergeCells.lastRow = lastRow + 1;
323 | return mergeCells;
324 | }
325 | insertRow = function(row,rows = 0){
326 | return InsertRow(owner.hwnd,row - 1,row + rows - 1);
327 | };
328 | deleteRow = function(row,rows = 0){
329 | return RemoveRow(owner.hwnd,row - 1,row + rows - 1);
330 | };
331 | insertColumn = function(col,cols = 0){
332 | return InsertCol(owner.hwnd,col - 1,col + cols - 1);
333 | };
334 | deleteColumn = function(col,cols = 0){
335 | return RemoveCol(owner.hwnd,col - 1,col + cols - 1);
336 | };
337 | clearCell = function(topRow = 1,bottomRow = 1048576,leftCol = 1,rightCol = 16384){
338 | Clear(owner.hwnd,topRow - 1,bottomRow - 1,leftCol - 1,rightCol -1);
339 | };
340 | getPicture = function(index){
341 | var int = 1
342 | var result,top,left,bottom,right,width,height, offset_x,offset_y = GetPicture(owner.hwnd,index - 1,int,int,int,int,int,int,int,int)
343 | if result == -1 return null;
344 | var picturePos = ..libxl.picturePos(top,left,bottom,right,width,height, offset_x,offset_y)
345 | return picturePos;
346 | };
347 | setPicture = function(row,col,picId,sacle = 1.0,offset_x = 0, offset_y = 0){
348 | SetPicture(owner.hwnd,row - 1,col - 1,picId - 1,sacle,offset_x, offset_y)
349 | };
350 | setPicture2 = function(row, col, picId, width = -1, height =-1, offset_x = 0, offset_y = 0){
351 | SetPicture2(owner.hwnd,row - 1,col - 1,picId - 1,width, height, offset_x, offset_y)
352 | };
353 | horPageBreak = function(index){
354 | return GetHorPageBreak(owner.hwnd,index-1);
355 | };
356 | verPageBreak = function(index){
357 | return GetVerPageBreak(owner.hwnd,index-1);
358 | };
359 | setHorPageBreak = function(row,pageBreak = false){
360 | return SetHorPageBreak(owner.hwnd,row-1,pageBreak);
361 | };
362 | setVerPageBreak = function(col,pageBreak = false){
363 | return SetVerPageBreak(owner.hwnd,col-1,pageBreak);
364 | };
365 | setSplit = function(row = 0,col=0){
366 | Split(owner.hwnd,row-1,col-1);
367 | };
368 | setGroupRows = function(rowFirst,rowLast,collapsed = true){
369 | GroupRows(owner.hwnd,rowFirst-1,rowLast-1,collapsed);
370 | };
371 | setGroupCols = function(colFirst,colLast,collapsed = true){
372 | GroupCols(owner.hwnd,colFirst-1,colLast-1,collapsed);
373 | };
374 | getPrintFit = function(){
375 | var int = 1
376 | var result,width,hight = GetPrintFit(owner.hwnd,int,int);
377 | if !result return null;
378 | return width,hight;
379 | };
380 | setPrintFit = function(widthPage,highPage){
381 | SetPrintFit(owner.hwnd,widthPage,highPage);
382 | };
383 | printRepeatRows = function(){
384 | var int = 1
385 | var result,iniRow,lastRow = PrintRepeatRows(owner.hwnd,int,int);
386 | if !result return null;
387 | iniRow -= 1;
388 | lastRow -= 1;
389 | return iniRow,lastRow;
390 | };
391 | setPrintRepeatRows = function(iniRow,lastRow){
392 | SetPrintRepeatRows(owner.hwnd,iniRow-1,lastRow-1);
393 | };
394 | printRepeatCols = function(){
395 | var int = 1
396 | var result,iniCol,lastCol = PrintRepeatCols(owner.hwnd,int,int);
397 | if !result return null;
398 | iniCol += 1;
399 | lastCol += 1;
400 | return iniCol,lastCol;
401 | };
402 | setPrintRepeatCols = function(iniCol,lastCol){
403 | SetPrintRepeatCols(owner.hwnd,iniCol-1,lastCol-1);
404 | };
405 | printArea = function(){
406 | var int = 1;
407 | var result,iniRow,lastRow,iniCol,lastCol = PrintArea(owner.hwnd,int,int,int,int);
408 | if !result return null;
409 | var cellRange = ..libxl.cellRange();
410 | cellRange.iniCol = iniCol + 1;
411 | cellRange.lastCol = lastCol + 1;
412 | cellRange.iniRow = iniRow + 1;
413 | cellRange.lastRow = lastRow + 1;
414 | return cellRange;
415 | };
416 | setPrintArea = function(cellRange){
417 | SetPrintRepeatCols(owner.hwnd,iniCol-1,lastCol-1);
418 | };
419 | clearPrintRepeats = function(){
420 | ClearPrintRepeats(owner.hwnd);
421 | };
422 | clearPrintArea = function(){
423 | ClearPrintArea(owner.hwnd);
424 | };
425 | getNamedRangeByIndex = function(index){
426 | var int = 1;
427 | var name,iniRow,lastRow,iniCol,lastCol,scopeID,hidden = NamedRange(owner.hwnd,index,int,int,int,int,int,int);
428 | if !name return null;
429 | var nameRange = ..libxl.nameRange(name,iniRow +1,lastRow + 1,iniCol + 1,lastCol + 1,scopeID,hidden)
430 | return nameRange;
431 | };
432 | getNamedRangeByText = function(name,scopeID = 0){
433 | var int = 1
434 | var result,name,iniRow,lastRow,iniCol,lastCol,hidden = GetNamedRange(owner.hwnd,name,int,int,int,int,scopeID,int)
435 | if !result return null;
436 | var nameRange = ..libxl.nameRange(name,iniRow +1,lastRow + 1,iniCol + 1,lastCol + 1,scopeID,hidden)
437 | return nameRange;
438 | };
439 | setNamedRange = function(name,iniRow,lastRow,iniCol,lastCol,scopeID = 0){
440 | var int = 1
441 | var result,name = GetNamedRange(owner.hwnd,name,iniRow -1,lastRow -1,iniCol -1,lastCol -1,scopeID)
442 | if !result return null;
443 | return name;
444 | };
445 | getHyperlinkByIndex = function(index){
446 | var int = 1;
447 | var hyperlink,iniRow,lastRow,iniCol,lastCol = NamedRange(owner.hwnd,index,int,int,int,int);
448 | if !hyperlink return null;
449 | var cellRange = ..libxl.cellRange();
450 | cellRange.iniCol = iniCol + 1;
451 | cellRange.lastCol = lastCol + 1;
452 | cellRange.iniRow = iniRow + 1;
453 | cellRange.lastRow = lastRow + 1;
454 | cellRange.hyperlink = hyperlink;
455 | return cellRange;
456 |
457 | };
458 | delHyperlink = function(index){
459 | return DelHyperlink(owner.hwnd,index);
460 | };
461 | addHyperlink = function(hyperlink,iniRow,lastRow,iniCol,lastCol){
462 | return DelHyperlink(owner.hwnd,hyperlink,iniRow - 1,lastRow -1,iniCol - 1,lastCol -1);
463 | };
464 | getTopLeftView = function(){
465 | var int = 1;
466 | var row,col = GetTopLeftView(owner.hwnd,int,int)
467 | var cell = {row = row + 1; col = col + 1}
468 | if row return cell;
469 | return null;
470 | };
471 | setTopLeftView = function(row,col){
472 | SetTopLeftView(owner.hwnd,row - 1,col -1) ;
473 | };
474 | setAutoFitArea = function(iniRow,lastRow,iniCol,lastCol){
475 | SetAutoFitArea(owner.hwnd,iniRow -1,iniCol -1,lastRow -1,lastCol -1);
476 | };
477 | addrToRowCol = function(str){
478 | return ..libxl.Sheet.addrToRowCol(owner.hwnd,str);
479 | };
480 | rowColToAddr = function(row,col,rowRelative = true,colRelative = true){
481 | return RowColToAddr(owner.hwnd,row -1,col -1,rowRelative,colRelative);
482 | };
483 | autoFilter = function(){
484 | var hwnd = AutoFilter(owner.hwnd)
485 | if !hwnd return hwnd;
486 | var s_autofilter = ..libxl.AutoFilter(hwnd,owner.hwnd)//由于子方法调用了一个Sheet中的方法,所以需要传递此hwnd
487 | return s_autofilter;//AutoFilterhandle
488 | }
489 | applyFilter = function(){
490 | ApplyFilter(owner.hwnd);
491 | }
492 | removeFilter = function(){
493 | RemoveFilter(owner.hwnd)
494 | }
495 | setProtect = function(v,pass,enhanceType){
496 | if pass != null or enhanceType != null{
497 | SetProtectEx(owner.hwnd,tonumber(v),pass,enhanceType);
498 | }
499 | else {
500 | owner.protect = v;
501 | }
502 | }
503 | setTabColor = function(colorType){ //API没有提供获取功能
504 | if colorType != null SetTabColor(owner.hwnd,colorType);
505 | }
506 | setTabRgbColor = function(red,green,blue){
507 | if red != null && green != null && blue != null SetTabRgbColor(owner.hwnd,red,green,blue);
508 | }
509 | getTableArea = function(index){
510 | var name,rowFirst, rowLast, colFirst,colLast, headerRowCount, totalsRowCount = TableArea(owner.hwnd,index,0,0,0,0,0,0);
511 | //待修改,需要返回cellRange
512 | var cellRange = cellRange(rowFirst, rowLast, colFirst,colLast);
513 | cellRange.headerRowCount = headerRowCount;
514 | cellRange.totalsRowCount = totalsRowCount;
515 | cellRange.name = name;
516 | return cellRange;
517 | }
518 | removeDataValidations = function(){
519 | RemoveDataValidations(owner.hwnd);
520 | }
521 |
522 | )
523 | addrToRowCol = function(hwnd,str){ //不是属性,调用方法与实例不同
524 | var int,bool = 1,false;
525 | var row,col,rowRelative,colRelative = AddrToRowCol(hwnd,str,int,int,bool,bool)
526 | var cell = {row = row + 1; col = col + 1;rowRelative = rowRelative;colRelative = colRelative}
527 | if row >= 0 && col >=0 return cell;
528 | return null;
529 | };
530 |
531 | //Column对象字段;
532 | class Column{
533 | ctor( hwnd,first=1,last ){
534 | if !hwnd return null,"请指定本地句柄";
535 | this.hwnd = hwnd;//仍然是SheetHwnd
536 | this.first = first;
537 | this.last = last;
538 | }
539 | @_metaProperty;
540 | }
541 | namespace Column{
542 | _metaProperty = ..util.metaProperty(
543 | _call = function(first,last){
544 | owner.first = first;
545 | owner.last = last;
546 | return owner;
547 | };
548 | width = {
549 | _get = function(){
550 | return ColWidth(owner.hwnd,owner.first - 1);
551 | };
552 | _set = function( v ){
553 | var last,hidden = owner.last,ColHidden(owner.hwnd,owner.first - 1);
554 | if !last last = owner.first;
555 | if last != null last -= 1;
556 | //..io.print(owner.first - 1,last,v)
557 | return SetCol(owner.hwnd,owner.first - 1,last,v,,hidden);
558 | }
559 | }
560 | hidden = {
561 | _get = function(){
562 | return ColHidden(owner.hwnd,owner.first - 1);
563 | };
564 | _set = function( v ){
565 | return SetColHidden(owner.hwnd,owner.first - 1,tonumber(v));
566 | }
567 | }
568 | )
569 |
570 | ColWidth = libxl32.api("xlSheetColWidth","double(ptr SheetHandle, int col)")
571 | SetCol = libxl32.api("xlSheetSetCol","int(ptr SheetHandle, int colFirst, int colLast, double width,ptr FormatHandle, int hidden)")
572 | ColHidden = libxl32.api("xlSheetColHidden","int(ptr SheetHandle, int col)")
573 | SetColHidden = libxl32.api("xlSheetSetColHidden","int(ptr SheetHandle, int col, int hidden)")
574 | }//Column声明结束
575 |
576 | //Column对象字段;
577 | class Row{
578 | ctor( hwnd,first=1,last ){
579 | if !hwnd return null,"请指定本地句柄";
580 | this.hwnd = hwnd;//仍然是SheetHwnd
581 | this.first = first;
582 | this.last = last;
583 | }
584 | @_metaProperty;
585 | }
586 | namespace Row{
587 | _metaProperty = ..util.metaProperty(
588 | _call = function(first,last){
589 | owner.first = first;
590 | owner.last = last;
591 | return owner;
592 | };
593 | height = {
594 | _get = function(){
595 | return RowHeight(owner.hwnd,owner.first - 1);
596 | };
597 | _set = function( v ){
598 | var hidden = RowHidden(owner.hwnd,owner.first - 1);
599 | SetRow(owner.hwnd,owner.first - 1,v,,hidden);
600 | }
601 | }
602 | hidden = {
603 | _get = function(){
604 | return RowHidden(owner.hwnd,owner.first - 1);
605 | };
606 | _set = function( v ){
607 | SetRowHidden(owner.hwnd,owner.first - 1,tonumber(v));
608 | }
609 | }
610 | )
611 |
612 | RowHeight = libxl32.api("xlSheetRowHeight","double(ptr SheetHandle, int row)")
613 | SetRow = libxl32.api("xlSheetSetRow","int(ptr SheetHandle, int row, double height, ptr FormatHandle, int hidden)")
614 | RowHidden = libxl32.api("xlSheetRowHidden","int(ptr SheetHandle, int row)")
615 | SetRowHidden = libxl32.api("xlSheetSetRowHidden","int(ptr SheetHandle, int row, int hidden)")
616 | }//Row结束
617 | //Range
618 | class Range{
619 | ctor( hwnd ){
620 | if !hwnd return null,"请指定本地句柄";
621 | this.hwnd = hwnd;//仍然是SheetHwnd
622 | this.areastr = "";
623 | this.area = {};//值为文本,如{"A1B2";"C3"}
624 | this.areaSplit = {};//值为数值,如{[1] = {iniRow;iniCol;LastRow;LastCol};}
625 | //-----------统一功能参数---------
626 | this.method = "value";
627 | this.setvalue = {};
628 | this.setformat = {};
629 | this.setformulat = {};
630 | }
631 | @_metaProperty;
632 | }
633 | namespace Range{
634 | import preg;
635 | _metaProperty = ..util.metaProperty(
636 | _call = function(str){
637 | //清空上次调用信息
638 | owner.area = {};
639 | owner.areaSplit = {}
640 | //-----正常处理-------
641 | owner.areastr = str;
642 | owner.area[1] = str;
643 | var area = ..string.split(str,",");//拆分区域
644 | if type(area) == type.table owner.area = area;//拆对了就赋值,否则按原来的
645 | owner.areaSplit = owner.getAreaPosition(owner.area);
646 | return owner;
647 | };
648 | //保留设取值/公式/格式/合并/Copyto功能; 2017-06-20,copyTo没有优化
649 | value = {
650 | _get = function(){//考虑多个区域
651 | owner.method = "value";
652 | return owner.getMetaFunction();
653 | };
654 | _set = function(v){//考虑多个区域
655 | owner.method = "value";
656 | owner.setMetaFunction(v,true);
657 | }
658 | };
659 | format = { //格式
660 | _get = function(){
661 | owner.method = "format";
662 | return owner.getMetaFunction();
663 | };
664 | _set = function( v ){
665 | owner.method = "format";
666 | v = owner.destructFormat(v);
667 | owner.setMetaFunction(v,true);
668 | }
669 | }//format
670 | formula = {
671 | _get = function(){
672 | owner.method = "formula";
673 | return owner.getMetaFunction();
674 | };
675 | _set = function(v){
676 | owner.method = "formula";
677 | owner.setMetaFunction(v,true);
678 | };
679 | }
680 | //以下不在!xlRange中提示,仅作为usedRange的功能
681 | address = {
682 | _get = function(){
683 | return owner.areastr;
684 | };
685 | }
686 |
687 | Rows = {
688 | _get = function(){
689 | var areaSplit = owner.areaSplit
690 | var eachRange = areaSplit[1];
691 | var rowcounts = (eachRange.lastRow - eachRange.iniRow) + 1//数量应该是行数相减后加1
692 | return {Count = rowcounts};
693 | }
694 | }
695 | Columns = {
696 | _get = function(){
697 | var areaSplit = owner.areaSplit
698 | var eachRange = areaSplit[1];
699 | var colcounts = (eachRange.lastCol - eachRange.iniCol) + 1
700 | return {Count = colcounts};
701 | }
702 | }
703 |
704 | //函数段
705 | getMetaFunction = function(returnMode = 1){//获取信息
706 | var areaSplit,cur_Sheet,method = owner.areaSplit,owner.owner,owner.method;
707 | var values,eachArea = {};
708 |
709 | if ( returnMode == 1 ){ //普通模式,不带定位,返回值,按数值定位
710 | for i=1;#areaSplit;1{
711 | eachArea = {};
712 | var eachRange,eachRow,v = areaSplit[i];
713 | for row = eachRange.iniRow;eachRange.lastRow;1{
714 | eachRow = {};
715 | for col = eachRange.iniCol;eachRange.lastCol;1{
716 | v = cur_Sheet.Cell(row,col)[method];
717 | eachRow[(col-eachRange.iniCol+1)] = v;//按位赋值,null值不影响
718 | }
719 | eachArea[(row - eachRange.iniRow +1)] = eachRow;//按行赋值,null行不影响
720 | };
721 | ..table.push(values,eachArea);
722 | }
723 | if #areaSplit == 1 return values[1];
724 | }
725 | elseif( returnMode == 2){ //带区域描述的
726 | for i=1;#areaSplit;1{
727 | eachArea = {};
728 | var eachRange,eachRow,v,pos = areaSplit[i];
729 | for row = eachRange.iniRow;eachRange.lastRow;1{
730 | for col = eachRange.iniCol;eachRange.lastCol;1{
731 | v = cur_Sheet.Cell(row,col)[method];
732 | pos = cur_Sheet.rowColToAddr(row,col);
733 | eachArea[pos] = v;//按位赋值,null值不影响
734 | };
735 | };
736 | ..table.push(values,eachArea);
737 | }
738 | if #areaSplit == 1 return values[1];
739 | }
740 | return values;
741 | };
742 | setMetaFunction = function(v,copymode = false,format){ //传值,及格式
743 | var areaSplit,cur_Sheet,method = owner.areaSplit,owner.owner,owner.method;
744 | var values,eachArea,eachRange,eachValue,rangeValues = {};
745 | //----------将值赋予到values中,后续将按values逐一匹配,减少判断项目
746 | if type(v) != type.table{//v为单值的时候,每个区域都写入单值v;
747 | for i=1;#areaSplit;1{..table.push(values,v);};
748 | }
749 | else {;
750 |
751 | if #areaSplit == 1 v = {v};//解决range.value = range.value 的问题;
752 |
753 | for i=1;#areaSplit;1{
754 | eachRange = areaSplit[i];
755 | rangeValues = v[i];//有可能为null,有可能为单值,有可能为table;
756 | if type(rangeValues) != type.table{//null或单值时;
757 | values[i] = rangeValues;
758 | }
759 | else {//同时存在一维数组及二维数组,即每行单值或者多值
760 | //区域为一个单元格的时候
761 | if eachRange.iniRow == eachRange.lastRow && eachRange.iniCol == eachRange.lastCol {
762 | values[i] = rangeValues;//不做任何处理
763 | continue ;
764 | }
765 | //标准情况
766 | var formatValue,rowValue,rowIndex = {};//将一维数组扩展为二维
767 | for row = eachRange.iniRow;eachRange.lastRow;1{
768 | rowIndex = (row - eachRange.iniRow + 1)
769 | rowValue = rangeValues[ rowIndex ];
770 | if type(rowValue) != type.table{//行为一个值的情况
771 | formatValue[rowIndex] = {};
772 | for col = eachRange.iniCol;eachRange.lastCol;1{
773 | formatValue[rowIndex][col - eachRange.iniCol +1] = rowValue;
774 | }
775 | }
776 | else {//行为数组的情况,有可能值会少于区域
777 | var areaCols = eachRange.lastCol - eachRange.iniCol + 1
778 | if ( #rowValue < areaCols ){//少的情况
779 | formatValue[rowIndex] = {};
780 | var count = 0;
781 | for col = eachRange.iniCol;eachRange.lastCol;1{
782 | count += 1;
783 | formatValue[rowIndex][col - eachRange.iniCol +1] = rowValue[count];
784 | if count >= areaCols {
785 | if copymode { count = 0; continue };//复制模式时,重置count
786 | break ;//否则跳出
787 | };
788 | };
789 | };
790 | else {//相等或多的情况
791 | formatValue[rowIndex] = rowValue;
792 | };
793 | }
794 | }
795 | values[i] = formatValue;
796 | }
797 | };
798 | };
799 | //..console.log("value",owner.method,values)
800 | //开始赋值操作;
801 | for i=1;#areaSplit;1{
802 | eachRange = areaSplit[i];
803 | rangeValues = values[i];
804 | //区域为一个单元格的时候
805 | if eachRange.iniRow == eachRange.lastRow && eachRange.iniCol == eachRange.lastCol {
806 | if type(rangeValues) != type.table{//单值的时候就直接调用cell就好了
807 | cur_Sheet.Cell(eachRange.iniRow,eachRange.iniCol)[method] = rangeValues;
808 | }
809 | else {
810 | for row = 1;#rangeValues;1{
811 | if type(rangeValues[row]) != type.table { //行里是单值的时候
812 | cur_Sheet.Cell(eachRange.iniRow + row - 1,eachRange.iniCol)[method] = rangeValues[row];
813 | }
814 | else {
815 | for col = 1;#rangeValues[row];1{
816 | cur_Sheet.Cell(eachRange.iniRow + row - 1,eachRange.iniCol + col - 1)[method] = rangeValues[row][col];
817 | }
818 | }
819 | }
820 | }
821 | continue ;
822 | }
823 | //标准情况
824 | for row = eachRange.iniRow;eachRange.lastRow;1{
825 | if type(rangeValues) != type.table{ //单值的情况
826 | for col = eachRange.iniCol;eachRange.lastCol;1{
827 | cur_Sheet.Cell(row,col)[method] = rangeValues;
828 | }
829 | }
830 | else {
831 | rowIndex = (row - eachRange.iniRow + 1)
832 | rowValue = rangeValues[ rowIndex ];
833 | for col = eachRange.iniCol;eachRange.lastCol;1{
834 | cur_Sheet.Cell(row,col)[method] = rowValue[( col - eachRange.iniCol + 1)];
835 | }
836 | };
837 | };
838 | }
839 | if format { //格式的话,就拆开处理,速度慢些,但减轻代码复杂度
840 | owner.method = "format";
841 | v = owner.destructFormat(format);
842 | owner.setMetaFunction(v,true);
843 | }
844 | };
845 | destructFormat = function(v){ //解构Format对象,只传递句柄,方便统一调用
846 | var values = {};
847 | for k,j in v{
848 | if type(j) == type.table {
849 | if j.hwnd {
850 | values[k] = j.hwnd;
851 | }
852 | else {
853 | values[k] = owner.destructFormat(j);
854 | }
855 | }
856 | else {
857 | values[k] = j
858 | }
859 | }
860 | return values;
861 | };
862 | getAreaPosition = function(sourceArea){
863 | var areaS,cellRange = {}
864 | for areaIndex = 1;#sourceArea;1{
865 | cellRange = reCalcuCellRange(owner.hwnd,sourceArea[areaIndex]);
866 | ..table.push(areaS,cellRange);//加入区域
867 | }
868 | return areaS;
869 | }
870 | setValue = function(data,format,copyMode = true){
871 | owner.method = "value";
872 | owner.setMetaFunction(v,copyMode,format);
873 | }//setValue;
874 | getValue = function(mode=2){
875 | owner.method = "value";
876 | return owner.getMetaFunction(mode);
877 | }//自定义返回是否是区域模式
878 | setFormula = function(data,format){
879 | owner.method = "formula";
880 | owner.setMetaFunction(v,copyMode,format);
881 | }//setFormat
882 | copyTo = function(cell,setFormat = false){//待改进,应该用CopyTo方法
883 | var data,format = owner.value,{};
884 | if setFormat format = owner.format;
885 | owner.owner.Range(cell).value = data;
886 | if setFormat owner.owner.Range(cell).format = format;
887 | }//copyTo
888 | merge = function(){
889 | var areaSplit,eachRange = owner.areaSplit;
890 | for i=1;#areaSplit;1{
891 | eachRange = areaSplit[i];
892 | owner.owner.setMerge(eachRange.iniRow,eachRange.lastRow,eachRange.iniCol,eachRange.lastCol);
893 | };
894 | }
895 | ignoreError = function(errorType){
896 | var areaSplit,eachRange = owner.areaSplit;
897 | for i=1;#areaSplit;1{
898 | eachRange = areaSplit[i];
899 | owner.owner.AddIgnoredError(owner.hwnd,eachRange.iniRow,eachRange.iniCol,eachRange.lastRow,eachRange.lastCol,errorType)
900 | }
901 | }
902 | dataValidation = function(dataType,operaType,value_op,value_between,blank = true,hideDropdown = false,
903 | inputMsg = true,errorMsg = true,proTitle = "",proText ="",errorTitle ="",errorText = "",errorType = 0){
904 | //原函数分四个版本,分别是str和double,正常与Ex,这里直接调用Ex
905 | var func;
906 | if type(value_op) == type.number && type(value_between) == type.number{
907 | func = owner.owner.AddDataValidationDoubleEx
908 | }
909 | else {
910 | func = owner.owner.AddDataValidationEx
911 | if type(value_op) != type.string value_op = tostring(value_op);
912 | if type(value_between) != type.string value_between = tostring(value_between);
913 | }
914 | var areaSplit,eachRange = owner.areaSplit;
915 | for i=1;#areaSplit;1{
916 | eachRange = areaSplit[i];
917 | func(dataType,operaType,eachRange.iniRow,eachRange.iniCol,eachRange.lastRow,eachRange.lastCol,
918 | )
919 | }
920 | }
921 |
922 | )//属性结束
923 | getAreaFromStr = function(str){
924 | var regex = preg("(\w{1,}?\d{1,})");
925 | var area = {};
926 | for m in regex.gmatch( str) {
927 | ..table.push(area,m);
928 | };
929 | return area;
930 | }
931 | reCalcuCellRange = function(hwnd,srcArea){ //非实例化的方法,所以需要传递hwnd
932 | var areaRange = {iniRow = 0;iniCol = 0;lastRow = 0;lastCol = 0;};
933 | var areaSplit = getAreaFromStr(srcArea)
934 | var cells = {};
935 | for i=1;#areaSplit;1{
936 | var cell = ..libxl.Sheet.addrToRowCol(hwnd,areaSplit[i]) //成功返回cell,失败为null
937 | ..table.push(cells,cell);
938 | }
939 | if #cells = 1 ..table.push(cells,cells[1]); //只有一个时,补全
940 | //---------转换区域为数值数组----------
941 | var cellRange = ..table.clone(areaRange);
942 | cellRange.iniRow = cells[1].row;
943 | cellRange.iniCol = cells[1].col;
944 | cellRange.lastRow = cells[2].row;
945 | cellRange.lastCol = cells[2].col;
946 | //---------重排区域-------------------
947 | if cellRange.iniRow > cellRange.lastRow{
948 | cellRange.iniRow = cells[2].row;
949 | cellRange.lastRow = cells[1].row;
950 | };
951 | if cellRange.iniCol > cellRange.lastCol{
952 | cellRange.iniCol = cells[2].col;
953 | cellRange.lastCol = cells[1].col;
954 | };
955 | return cellRange;
956 | }
957 |
958 | }//Range结束
959 | //Cell对象字段;
960 | class Cell{
961 | ctor( hwnd,x=1,y=1 ){
962 | if !hwnd return null,"请指定本地句柄";
963 | this.hwnd = hwnd;//仍然是SheetHwnd
964 | this.x = x
965 | this.y = y
966 | }
967 | @_metaProperty;
968 | }
969 | namespace Cell{
970 | _metaProperty = ..util.metaProperty(
971 | _call = function(row,col){
972 | if type(row) = type.string{
973 |
974 | var areaSplit = ..libxl.Sheet.Range.getAreaFromStr(row);
975 | if #areaSplit > 1 return owner.owner.Range(row);
976 |
977 | var cell = owner.owner.addrToRowCol(row)
978 | owner.x = cell.row;
979 | owner.y = cell.col;
980 | return owner;
981 | }
982 | if type(row) = type.number{
983 | owner.x = row;
984 | owner.y = col;
985 | return owner;
986 | }
987 | return null;
988 | };
989 | delMerge = function(){//删除合并单元格
990 | return DelMerge(owner.hwnd,owner.x-1,owner.y-1);
991 | };
992 | copyTo = function(row,col){
993 | return CopyCell(owner.hwnd,owner.x-1,owner.y-1,row-1,col-1)
994 | }
995 | setValue = function(value,format){
996 | if type(format) == type.table format = format.hwnd
997 | select(type(value)) {
998 | case type.number {
999 | WriteNum(owner.hwnd,owner.x-1,owner.y-1,value,format);
1000 | }
1001 | case type.string {
1002 | WriteStr(owner.hwnd,owner.x-1,owner.y-1,value,format);
1003 | }
1004 | case type.boolean {
1005 | WriteBool(owner.hwnd,owner.x-1,owner.y-1,tonumber(value),format);
1006 | }
1007 | case type.null{
1008 | WriteStr(owner.hwnd,owner.x-1,owner.y-1,"",format);
1009 | }
1010 | case type.table {
1011 | if value.year return WriteStr(owner.hwnd,owner.x-1,owner.y-1,tostring(value),format);//时间格式
1012 | owner.owner.Range(owner.owner.rowColToAddr(owner.x,owner.y)).setValue(value,format)//待测试
1013 | }
1014 | }
1015 | }
1016 | setFormula = function(str,cellvalue,format){
1017 | if type(format) == type.table format = format.hwnd
1018 | if cellvalue{
1019 | select(type(cellvalue)) {
1020 | case type.number {
1021 | WriteFormulaNum(owner.hwnd,owner.x-1,owner.y-1,str,cellvalue,format)
1022 | }
1023 | case type.string {
1024 | WriteFormulaStr(owner.hwnd,owner.x-1,owner.y-1,str,cellvalue,format)
1025 | }
1026 | case type.boolean {
1027 | WriteFormulaBool(owner.hwnd,owner.x-1,owner.y-1,str,cellvalue,format)
1028 | }
1029 | }
1030 | }
1031 | else {
1032 | WriteFormula(owner.hwnd,owner.x-1,owner.y-1,str,format);
1033 | }
1034 | };
1035 | setError = function(errType,format){
1036 | if type(format) == type.table format = format.hwnd
1037 | WriteError(owner.hwnd,owner.x-1,owner.y-1,errType,format);
1038 | }
1039 | removeComment = function(){
1040 | RemoveComment(owner.hwnd,owner.x-1,owner.y-1);
1041 | }
1042 | value = {
1043 | _get = function(){ ;
1044 | var celltype = CellType(owner.hwnd,owner.x-1,owner.y-1)
1045 | select(celltype) {
1046 | case 1/*_CELLTYPE_NUMBER*/ {
1047 | return ReadNum(owner.hwnd,owner.x-1,owner.y-1);
1048 | }
1049 | case 2/*_CELLTYPE_STRING*/{
1050 | return ReadStr(owner.hwnd,owner.x-1,owner.y-1);
1051 | }
1052 | case 3/*_CELLTYPE_BOOLEAN*/ {
1053 | return ReadBool(owner.hwnd,owner.x-1,owner.y-1);
1054 | }
1055 | case 4/*_CELLTYPE_BLANK*/ {
1056 | return ;
1057 | }
1058 | else { //错误值应该由用户自己调用
1059 | return ;
1060 | }
1061 | }
1062 | };
1063 | _set = function( v ){;
1064 | owner.setValue(v);
1065 | };
1066 | };
1067 | text = {
1068 | _get = function(){
1069 | return ReadStr(owner.hwnd,owner.x-1,owner.y-1);
1070 | };
1071 | _set = function( v ){
1072 | WriteStr(owner.hwnd,owner.x-1,owner.y-1,v);
1073 | };
1074 | };
1075 | num = {
1076 | _get = function(){
1077 | return ReadNum(owner.hwnd,owner.x-1,owner.y-1);
1078 | };
1079 | _set = function( v ){
1080 | WriteNum(owner.hwnd,owner.x-1,owner.y-1,v);
1081 | };
1082 | };
1083 | formula = {
1084 | _get = function(){
1085 | return ReadFormula(owner.hwnd,owner.x-1,owner.y-1);
1086 | };
1087 | _set = function( v ){
1088 | WriteFormula(owner.hwnd,owner.x-1,owner.y-1,v);
1089 | };
1090 | };
1091 | cellType = {
1092 | _get = function(){
1093 | return CellType(owner.hwnd,owner.x-1,owner.y-1);
1094 | };
1095 | }
1096 | format = { //格式
1097 | _get = function(){
1098 | var hwnd = CellFormat(owner.hwnd,owner.x-1,owner.y-1)
1099 | if !hwnd return hwnd;
1100 | var s_format = owner.owner.p_shformat.Formats(hwnd,owner.owner.p_shformat)
1101 | return s_format;
1102 | };
1103 | _set = function( format ){
1104 | var hFormat = format;
1105 | if type(format) == type.table hFormat = format.hwnd
1106 | if !owner.owner.p_shformat.Formats[tonumber(hFormat)]{
1107 | hFormat = owner.owner.p_shformat.book.addFormat(hFormat).hwnd
1108 | }
1109 | SetCellFormat(owner.hwnd,owner.x-1,owner.y-1, hFormat);
1110 | }
1111 | }
1112 | comment = {//注释,2003的才可以
1113 | _get = function(){
1114 | return ReadComment(owner.hwnd,owner.x-1,owner.y-1);
1115 | };
1116 | _set = function( v ){
1117 | if type(v) != type.table error("请使用cellComment对象填充数据")
1118 | WriteComment(owner.hwnd,owner.x-1,owner.y-1,v.value,v.author,v.width,v.height);
1119 | }
1120 | }
1121 | isFormula = {
1122 | _get = function(){
1123 | return IsFormula(owner.hwnd,owner.x-1,owner.y-1);
1124 | };
1125 | };
1126 | isDate = {
1127 | _get = function(){
1128 | return IsDate(owner.hwnd,owner.x-1,owner.y-1);
1129 | };
1130 | };
1131 | errType = {
1132 | _get = function(){
1133 | return ReadError(owner.hwnd,owner.x-1,owner.y-1);
1134 | };
1135 | }
1136 | merge = {
1137 | _get = function(){
1138 | var int = 1
1139 | var result,iniRow,lastRow,iniCol,lastCol = GetMerge(owner.hwnd,owner.x-1,owner.y-1,int,int,int,int);
1140 | if result == 0 return null;
1141 | var mergeCells = ..libxl.cellRange();
1142 | mergeCells.iniCol = iniCol + 1;
1143 | mergeCells.lastCol = lastCol + 1;
1144 | mergeCells.iniRow = iniRow + 1;
1145 | mergeCells.lastRow = lastRow + 1;
1146 | return mergeCells;
1147 | };
1148 | }
1149 | blank = {
1150 | _get = function(){
1151 | var result,ptr ReadFormula(owner.hwnd,owner.x-1,owner.y-1);
1152 | return ptr;
1153 | };
1154 | _set = function( hFormat ){
1155 | if type(hFormat) == type.table hFormat = hFormat.hwnd
1156 | WriteBlank(owner.hwnd,owner.x-1,owner.y-1,hFormat);
1157 | };
1158 | }
1159 |
1160 | )
1161 | ReadStr = libxl32.api("xlSheetReadStr", "ustring(ptr SheetHandle, int row, int col, ptr FormatHandle)")
1162 | WriteStr = libxl32.api("xlSheetWriteStr","int(ptr SheetHandle, int row, int col, ustring value, ptr FormatHandle)")
1163 |
1164 | ReadNum = libxl32.api("xlSheetReadNum","double(ptr SheetHandle, int row, int col, ptr FormatHandle)")
1165 | WriteNum = libxl32.api("xlSheetWriteNum","int(ptr SheetHandle, int row, int col, double value, ptr FormatHandle)")
1166 |
1167 | ReadBool = libxl32.api("xlSheetReadBool","int(ptr SheetHandle, int row, int col, ptr FormatHandle)")
1168 | WriteBool = libxl32.api("xlSheetWriteBool","int(ptr SheetHandle, int row, int col, int value, ptr FormatHandle)")
1169 |
1170 | ReadBlank = libxl32.api("xlSheetReadBlank","int(ptr SheetHandle, int row, int col, ptr& FormatHandle)") //返回空单元格的格式
1171 | WriteBlank = libxl32.api("xlSheetWriteBlank","int(ptr SheetHandle, int row, int col, ptr FormatHandle)")
1172 |
1173 | ReadFormula = libxl32.api("xlSheetReadFormula","ustring(ptr SheetHandle, int row, int col, pointer FormatHandle)")
1174 | WriteFormula = libxl32.api("xlSheetWriteFormula","int(ptr SheetHandle, int row, int col, ustring value, ptr FormatHandle)")
1175 | WriteFormulaNum = libxl32.api("xlSheetWriteFormulaNum","int(ptr SheetHandle, int row, int col, ustring expr, double value, ptr FormatHandle)");
1176 | WriteFormulaStr = libxl32.api("xlSheetWriteFormulaStr","int(ptr SheetHandle, int row, int col, ustring expr, ustring value, ptr FormatHandle)");
1177 | WriteFormulaBool = libxl32.api("xlSheetWriteFormulaBool","int(ptr SheetHandle, int row, int col, ustring expr, int value, ptr FormatHandle)");
1178 |
1179 | WriteError = libxl32.api("xlSheetWriteError","void(ptr SheetHandle, int row, int col, int error, ptr FormatHandle)");
1180 | CellType = libxl32.api("xlSheetCellType","int(ptr SheetHandle, int row, int col)")
1181 |
1182 | ReadComment = libxl32.api("xlSheetReadComment","ustring(ptr SheetHandle, int row, int col)")
1183 | WriteComment = libxl32.api("xlSheetWriteComment","void(ptr SheetHandle, int row, int col, ustring& value, ustring& author, int width, int height)")
1184 | RemoveComment = libxl32.api("xlSheetRemoveComment","void(ptr SheetHandle, int row, int col)");
1185 |
1186 | IsFormula = libxl32.api("xlSheetIsFormula","int(ptr SheetHandle, int row, int col)")
1187 | IsDate = libxl32.api("xlSheetIsDate","int(ptr SheetHandle, int row, int col)")
1188 |
1189 | ReadError = libxl32.api("xlSheetReadError","int(ptr SheetHandle, int row, int col)")
1190 |
1191 | GetMerge = libxl32.api("xlSheetGetMerge","int(ptr SheetHandle, int row, int col, int& rowFirst, int& rowLast, int& colFirst, int& colLast)")
1192 | DelMerge = libxl32.api("xlSheetDelMerge","int(ptr SheetHandle, int row, int col)")
1193 |
1194 | CellFormat = libxl32.api("xlSheetCellFormat","ptr(ptr SheetHandle, int row, int col)") //FormatHandle
1195 | SetCellFormat = libxl32.api("xlSheetSetCellFormat","void(ptr SheetHandle, int row, int col, ptr FormatHandle)")
1196 |
1197 | CopyCell = libxl32.api("xlSheetCopyCell","int(ptr SheetHandle, int rowSrc, int colSrc, int rowDst, int colDst)")
1198 |
1199 | }//Cell 声明结束
1200 |
1201 | //Sheet函数
1202 | Name = libxl32.api("xlSheetName","ustring(ptr SheetHandle)")
1203 | SetName = libxl32.api("xlSheetSetName","void(ptr SheetHandle, ustring& name)")
1204 |
1205 | MergeSize = libxl32.api("xlSheetMergeSize","int(ptr SheetHandle)")
1206 | DelMergeByIndex = libxl32.api("xlSheetDelMergeByIndex","int(ptr SheetHandle, int index)")
1207 | Merge = libxl32.api("xlSheetMerge","int(ptr SheetHandle, int index, int& rowFirst, int& rowLast, int& colFirst, int& colLast)")
1208 |
1209 | InsertRow = libxl32.api("xlSheetInsertRow","int(ptr SheetHandle, int rowFirst, int rowLast)")
1210 | RemoveRow = libxl32.api("xlSheetRemoveRow","int(ptr SheetHandle, int rowFirst, int rowLast)")
1211 |
1212 | InsertCol = libxl32.api("xlSheetInsertCol","int(ptr SheetHandle, int colFirst, int colLast)")
1213 | RemoveCol = libxl32.api("xlSheetRemoveCol","int(ptr SheetHandle, int colFirst, int colLast)")
1214 |
1215 | Clear = libxl32.api("xlSheetClear","void(ptr SheetHandle, int rowFirst, int rowLast, int colFirst, int colLast)")
1216 |
1217 | PictureSize = libxl32.api("xlSheetPictureSize","int(ptr SheetHandle)")
1218 | GetPicture = libxl32.api("xlSheetGetPicture","int(ptr SheetHandle, int index, int& rowTop, int& colLeft, int& rowBottom, int& colRight, int& width, int& height, int& offset_x, int& offset_y)")
1219 | SetPicture = libxl32.api("xlSheetSetPicture","void(ptr SheetHandle, int row, int col, int pictureId, double scale, int offset_x, int offset_y)")
1220 | SetPicture2 = libxl32.api("xlSheetSetPicture2","void(ptr SheetHandle, int row, int col, int pictureId, int width, int height, int offset_x, int offset_y)")
1221 |
1222 | GetHorPageBreak = libxl32.api("xlSheetGetHorPageBreak","int(ptr SheetHandle, int index)")
1223 | GetHorPageBreakSize = libxl32.api("xlSheetGetHorPageBreakSize","int(ptr SheetHandle)")
1224 | GetVerPageBreak = libxl32.api("xlSheetGetVerPageBreak","int(ptr SheetHandle, int index)")
1225 | GetVerPageBreakSize = libxl32.api("xlSheetGetVerPageBreakSize","int(ptr SheetHandle)")
1226 |
1227 | SetHorPageBreak = libxl32.api("xlSheetSetHorPageBreak","int(ptr SheetHandle, int row, int pageBreak)")
1228 | SetVerPageBreak = libxl32.api("xlSheetSetVerPageBreak","int(ptr SheetHandle, int col, int pageBreak)")
1229 |
1230 | Split = libxl32.api("xlSheetSplit","void(ptr SheetHandle, int row, int col)")
1231 | SplitInfo = libxl32.api("xlSheetSplitInfo","bool(ptr SheetHandle, int& row, int& col)")
1232 |
1233 | GroupRows = libxl32.api("xlSheetGroupRows","int(ptr SheetHandle, int rowFirst, int rowLast, bool collapsed)")
1234 | GroupCols = libxl32.api("xlSheetGroupCols","int(ptr SheetHandle, int colFirst, int colLast, bool collapsed)")
1235 |
1236 | GroupSummaryBelow = libxl32.api("xlSheetGroupSummaryBelow","int(ptr SheetHandle)")
1237 | SetGroupSummaryBelow = libxl32.api("xlSheetSetGroupSummaryBelow","void(ptr SheetHandle, int below)")
1238 | GroupSummaryRight = libxl32.api("xlSheetGroupSummaryRight","int(ptr SheetHandle)")
1239 | SetGroupSummaryRight = libxl32.api("xlSheetSetGroupSummaryRight","void(ptr SheetHandle, int right)")
1240 |
1241 | FirstRow = libxl32.api("xlSheetFirstRow","int(ptr SheetHandle)")
1242 | LastRow = libxl32.api("xlSheetLastRow","int(ptr SheetHandle)")
1243 | FirstCol = libxl32.api("xlSheetFirstCol","int(ptr SheetHandle)")
1244 | LastCol = libxl32.api("xlSheetLastCol","int(ptr SheetHandle)")
1245 |
1246 | DisplayGridlines = libxl32.api("xlSheetDisplayGridlines","int(ptr SheetHandle)")
1247 | SetDisplayGridlines = libxl32.api("xlSheetSetDisplayGridlines","void(ptr SheetHandle, int show)")
1248 | PrintGridlines = libxl32.api("xlSheetPrintGridlines","int(ptr SheetHandle)")
1249 | SetPrintGridlines = libxl32.api("xlSheetSetPrintGridlines","void(ptr SheetHandle, int print)")
1250 |
1251 | Zoom = libxl32.api("xlSheetZoom","int(ptr SheetHandle)")
1252 | SetZoom = libxl32.api("xlSheetSetZoom","void(ptr SheetHandle, int zoom)")
1253 | PrintZoom = libxl32.api("xlSheetPrintZoom","int(ptr SheetHandle)")
1254 | SetPrintZoom = libxl32.api("xlSheetSetPrintZoom","void(ptr SheetHandle, int zoom)")
1255 |
1256 | Landscape = libxl32.api("xlSheetLandscape","int(ptr SheetHandle)")
1257 | SetLandscape = libxl32.api("xlSheetSetLandscape","void(ptr SheetHandle, int landscape)")
1258 |
1259 | GetPrintFit = libxl32.api("xlSheetGetPrintFit","int(ptr SheetHandle, int& wPages, int& hPages)")
1260 | SetPrintFit = libxl32.api("xlSheetSetPrintFit","void(ptr SheetHandle, int wPages, int hPages)")
1261 |
1262 | Paper = libxl32.api("xlSheetPaper","int(ptr SheetHandle)")
1263 | SetPaper = libxl32.api("xlSheetSetPaper","void(ptr SheetHandle, int paper)")
1264 |
1265 | SetMerge = libxl32.api("xlSheetSetMerge","int(ptr SheetHandle, int rowFirst, int rowLast, int colFirst, int colLast)")
1266 |
1267 | Header = libxl32.api("xlSheetHeader","string(ptr SheetHandle)")
1268 | SetHeader = libxl32.api("xlSheetSetHeader","int(ptr SheetHandle, ustring& header, double margin)")
1269 | HeaderMargin = libxl32.api("xlSheetHeaderMargin","double(ptr SheetHandle)")
1270 |
1271 | Footer = libxl32.api("xlSheetFooter","string(ptr SheetHandle)")
1272 | SetFooter = libxl32.api("xlSheetSetFooter","int(ptr SheetHandle, ustring& footer, double margin)")
1273 | FooterMargin = libxl32.api("xlSheetFooterMargin","double(ptr SheetHandle)")
1274 |
1275 | HCenter = libxl32.api("xlSheetHCenter","int(ptr SheetHandle)")
1276 | SetHCenter = libxl32.api("xlSheetSetHCenter","void(ptr SheetHandle, int hCenter)")
1277 | VCenter = libxl32.api("xlSheetVCenter","int(ptr SheetHandle)")
1278 | SetVCenter = libxl32.api("xlSheetSetVCenter","void(ptr SheetHandle, int vCenter)")
1279 |
1280 | MarginLeft = libxl32.api("xlSheetMarginLeft","double(ptr SheetHandle)")
1281 | SetMarginLeft = libxl32.api("xlSheetSetMarginLeft","void(ptr SheetHandle, double margin)")
1282 | MarginRight = libxl32.api("xlSheetMarginRight","double(ptr SheetHandle)")
1283 | SetMarginRight = libxl32.api("xlSheetSetMarginRight","void(ptr SheetHandle, double margin)")
1284 | MarginTop = libxl32.api("xlSheetMarginTop","double(ptr SheetHandle)")
1285 | SetMarginTop = libxl32.api("xlSheetSetMarginTop","void(ptr SheetHandle, double margin)")
1286 | MarginBottom = libxl32.api("xlSheetMarginBottom","double(ptr SheetHandle)")
1287 | SetMarginBottom = libxl32.api("xlSheetSetMarginBottom","void(ptr SheetHandle, double margin)")
1288 |
1289 | PrintRowCol = libxl32.api("xlSheetPrintRowCol","int(ptr SheetHandle)")
1290 | SetPrintRowCol = libxl32.api("xlSheetSetPrintRowCol","void(ptr SheetHandle, int print)")
1291 |
1292 | PrintRepeatRows = libxl32.api("xlSheetPrintRepeatRows","int(ptr SheetHandle, int& rowFirst, int& rowLast)")
1293 | SetPrintRepeatRows = libxl32.api("xlSheetSetPrintRepeatRows","void(ptr SheetHandle, int rowFirst, int rowLast)")
1294 | PrintRepeatCols = libxl32.api("xlSheetPrintRepeatCols","int(ptr SheetHandle, int& colFirst, int& colLast)")
1295 | SetPrintRepeatCols = libxl32.api("xlSheetSetPrintRepeatCols","void(ptr SheetHandle, int colFirst, int colLast)")
1296 | PrintArea = libxl32.api("xlSheetPrintArea","int(ptr SheetHandle, int& rowFirst, int& rowLast, int& colFirst, int& colLast)")
1297 | SetPrintArea = libxl32.api("xlSheetSetPrintArea","void(ptr SheetHandle, int rowFirst, int rowLast, int colFirst, int colLast)")
1298 |
1299 | ClearPrintRepeats = libxl32.api("xlSheetClearPrintRepeats","void(ptr SheetHandle)")
1300 | ClearPrintArea = libxl32.api("xlSheetClearPrintArea","void(ptr SheetHandle)")
1301 |
1302 | GetNamedRange = libxl32.api("xlSheetGetNamedRange","int(ptr SheetHandle, ustring& name, int& rowFirst, int& rowLast, int& colFirst, int& colLast, int scopeId, int& hidden)")
1303 | SetNamedRange = libxl32.api("xlSheetSetNamedRange","int(ptr SheetHandle, ustring& name, int rowFirst, int rowLast, int colFirst, int colLast, int scopeId)")
1304 | DelNamedRange = libxl32.api("xlSheetDelNamedRange","int(ptr SheetHandle, ustring& name, int scopeId)")
1305 | NamedRangeSize = libxl32.api("xlSheetNamedRangeSize","int(ptr SheetHandle)")
1306 | NamedRange = libxl32.api("xlSheetNamedRange", "ustring(ptr SheetHandle, int index, int& rowFirst, int& rowLast, int& colFirst,int& colLast, int& scopeId, int& hidden)")
1307 |
1308 | HyperlinkSize = libxl32.api("xlSheetHyperlinkSize","int(ptr SheetHandle)")
1309 | Hyperlink = libxl32.api("xlSheetHyperlink", "ustring(ptr SheetHandle, int index, int& rowFirst, int& rowLast, int& colFirst, int& colLast)")
1310 | DelHyperlink = libxl32.api("xlSheetDelHyperlink","int(ptr SheetHandle, int index)")
1311 | AddHyperlink = libxl32.api("xlSheetAddHyperlink","void(ptr SheetHandle, ustring& hyperlink, int rowFirst, int rowLast, int colFirst, int colLast)")
1312 |
1313 | Protect = libxl32.api("xlSheetProtect","int(ptr SheetHandle)")
1314 | SetProtect = libxl32.api("xlSheetSetProtect","void(ptr SheetHandle, int protect)")
1315 |
1316 | RightToLeft = libxl32.api("xlSheetRightToLeft","int(ptr SheetHandle)")
1317 | SetRightToLeft = libxl32.api("xlSheetSetRightToLeft","void(ptr SheetHandle, int rightToLeft)")
1318 |
1319 | Hidden = libxl32.api("xlSheetHidden","int(ptr SheetHandle)")
1320 | SetHidden = libxl32.api("xlSheetSetHidden","int(ptr SheetHandle, int hidden)")
1321 |
1322 | GetTopLeftView = libxl32.api("xlSheetGetTopLeftView","void(ptr SheetHandle, int& row, int& col)")
1323 | SetTopLeftView = libxl32.api("xlSheetSetTopLeftView","void(ptr SheetHandle, int row, int col)")
1324 |
1325 | SetAutoFitArea = libxl32.api("xlSheetSetAutoFitArea","void(ptr SheetHandle, int rowFirst, int colFirst, int rowLast, int colLast)")
1326 |
1327 | AddrToRowCol = libxl32.api("xlSheetAddrToRowCol","void(ptr SheetHandle, ustring addr, int& row, int& col, bool& rowRelative, bool& colRelative)")
1328 | RowColToAddr = libxl32.api("xlSheetRowColToAddr","ustring(ptr SheetHandle, int row, int col, bool rowRelative, bool colRelative)")
1329 |
1330 | AutoFilter = libxl32.api("xlSheetAutoFilter","ptr(ptr SheetHandle)");
1331 | ApplyFilter = libxl32.api("xlSheetApplyFilter","void(ptr SheetHandle)");
1332 | RemoveFilter = libxl32.api("xlSheetRemoveFilter","void(ptr SheetHandle)");
1333 |
1334 | AddIgnoredError = libxl32.api("xlSheetAddIgnoredError","int(ptr SheetHandle, int rowFirst, int colFirst, int rowLast, int colLast, int iError)");
1335 | SetProtectEx = libxl32.api("xlSheetSetProtectEx","void(ptr SheetHandle, int protect, ustring password, int enhancedProtection)");
1336 |
1337 | SetTabColor = libxl32.api("xlSheetSetTabColor","void(ptr SheetHandle, int color)");
1338 | SetTabRgbColor = libxl32.api("xlSheetSetTabRgbColor","void(ptr SheetHandle, int red, int green, int blue)");
1339 |
1340 | TableSize = libxl32.api("xlSheetTableSize","int(ptr SheetHandle)");
1341 | TableArea = libxl32.api('xlSheetTable',"ustring(ptr SheetHandle, int index, int& rowFirst, int& rowLast, int& colFirst, int& colLast, int& headerRowCount, int& totalsRowCount)");
1342 |
1343 | //新增
1344 | AddDataValidation = libxl32.api("xlSheetAddDataValidation","void(ptr SheetHandle, int type, int op, int rowFirst, int rowLast, int colFirst, int colLast, ustring value1, ustring value2)");
1345 | AddDataValidationEx = libxl32.api("xlSheetAddDataValidationEx","void(ptr SheetHandle, int type, int op, int rowFirst, int rowLast, int colFirst, int colLast, ustring value1, ustring value2,
1346 | bool allowBlank, bool hideDropDown, bool showInputMessage, bool showErrorMessage, ustring promptTitle, ustring prompt, ustring errorTitle, ustring error, int errorStyle)");
1347 | AddDataValidationDouble = libxl32.api("xlSheetAddDataValidationDouble","void(ptr SheetHandle, int type, int op, int rowFirst, int rowLast, int colFirst, int colLast, double value1, double value2)");
1348 | AddDataValidationDoubleEx = libxl32.api("xlSheetAddDataValidationDoubleEx","void(ptr SheetHandle, int type, int op, int rowFirst, int rowLast, int colFirst, int colLast, double value1, double value2,
1349 | bool allowBlank, bool hideDropDown, bool showInputMessage, bool showErrorMessage, ustring promptTitle, ustring prompt, ustring errorTitle, ustring error, int errorStyle)");
1350 | RemoveDataValidations = libxl32.api("xlSheetRemoveDataValidations","void(ptr SheetHandle)");
1351 |
1352 |
1353 | }
1354 |
1355 | /**intellisense()
1356 | !libxl.Sheet() = !xlSheet.
1357 | !xlSheet.name = 工作表名称
1358 | !xlSheet.mergeCount = 合并单元格数量
1359 | !xlSheet.pictureCount = 图片数量
1360 | !xlSheet.horPageBreakCount = 行中断数量
1361 | !xlSheet.verPageBreakCount = 列中断数量
1362 | !xlSheet.split = 返回拆分单元格信息,Cell对象,row 和 col 分别代表行列。
1363 | !xlSheet.groupSummaryBelow = 在下方返回合计数
1364 | !xlSheet.groupSummaryRight = 在后侧返回合计数
1365 | !xlSheet.firstRow = 工作表首行
1366 | !xlSheet.lastRow = 工作表终止行
1367 | !xlSheet.firstCol = 工作表首列
1368 | !xlSheet.lastCol = 工作表终止列
1369 | !xlSheet.displayGridlines = 显示网格线
1370 | !xlSheet.printGridlines = 打印网格线
1371 | !xlSheet.zoom = 缩放比例
1372 | !xlSheet.printZoom = 打印时缩放比例
1373 | !xlSheet.landscape = 是否为Landscape模式
1374 | !xlSheet.paperSize = 纸张尺寸,_Paper_A4等
1375 | !xlSheet.header = 页眉内容
1376 | !xlSheet.headerMargin = 页眉边距
1377 | !xlSheet.footer = 页脚内容
1378 | !xlSheet.footerMargin = 页脚边距
1379 | !xlSheet.hCenter = 打印时水平居中
1380 | !xlSheet.vCenter = 打印时垂直居中
1381 | !xlSheet.marginLeft = 左边距
1382 | !xlSheet.marginRight = 右边距
1383 | !xlSheet.marginTop = 上边距
1384 | !xlSheet.marginBottom = 下边距
1385 | !xlSheet.printRowCol = 打印时是否打印行列标签
1386 | !xlSheet.namedRangeCount = 工作表命名空间数量
1387 | !xlSheet.hyperlinkCount = 工作表超链接数量
1388 | !xlSheet.protect = 是否保护工作表
1389 | !xlSheet.usedRange = 返回使用区域对象
1390 | !xlSheet.usedRange = !xlRange.
1391 | !xlSheet.usedRange.Rows.Count = 返回已使用行数
1392 | !xlSheet.usedRange.Columns.Count = 返回已使用列数
1393 | !xlSheet.usedRange.address = 返回区域描述
1394 | !xlSheet.rightToLeft = 是否启右对齐模式
1395 | !xlSheet.hidden = 是否隐藏
1396 | !xlSheet.tableNum = 获取区域数量
1397 | !xlSheet.tabColor = 设置工作表名颜色(颜色序列)
1398 | !xlSheet.delMerge(.(index) = 删除指定Index的合并单元格
1399 | !xlSheet.getMerge(.(index) = 获取指定Index的合并单元格信息
1400 | !xlSheet.setMerge(.(iniRow,lastRow,iniCol,lastCol) = 合并单元格
1401 | !xlSheet.insertRow(.(row,rows = 0) = 插入行
1402 | !xlSheet.deleteRow(.(row,rows = 0) = 删除行
1403 | !xlSheet.insertColumn(.(col,cols = 0) = 插入列
1404 | !xlSheet.deleteColumn(.(col,cols = 0) = 删除列
1405 | !xlSheet.clearCell(.(topRow = 1,bottomRow = 1048576,leftCol = 1,rightCol = 16384) = 清除单元格内容
1406 | !xlSheet.getPicture(.(index) = 获取指定Index的图片信息
1407 | !xlSheet.setPicture(.(row,col,picId,sacle = 1.0,offset_x = 0, offset_y = 0) = 设置图片信息
1408 | !xlSheet.setPicture2(.(row, col, picId, width = -1, height =-1, offset_x = 0, offset_y = 0) = 设置图片信息
1409 | !xlSheet.horPageBreak(.(index) = 获取指定Index的水平中断
1410 | !xlSheet.verPageBreak(.(index) = 获取指定Index的垂直中断
1411 | !xlSheet.setHorPageBreak(.(row,pageBreak = false) = 设置水平中断
1412 | !xlSheet.setVerPageBreak(.(col,pageBreak = false) = 设置垂直中断
1413 | !xlSheet.setSplit(.(row = 0,col=0) = 设置拆分试图
1414 | !xlSheet.setGroupRows(.(rowFirst,rowLast,collapsed = true) = 设置行组合
1415 | !xlSheet.setGroupCols(.(colFirst,colLast,collapsed = true) = 设置列组合
1416 | !xlSheet.getPrintFit(.() = 获取打印是否自动调整
1417 | !xlSheet.setPrintFit(.(widthPage,highPage) = 设置打印时调整为几页长或宽
1418 | !xlSheet.printRepeatRows(.() = 获取打印时是否重复行
1419 | !xlSheet.setPrintRepeatRows(.(iniRow,lastRow) = 设置打印时重复行
1420 | !xlSheet.printRepeatCols(.() = 获取打印时是否重复列
1421 | !xlSheet.setPrintRepeatCols(.(iniCol,lastCol) = 设置打印时重复列
1422 | !xlSheet.printArea(.() = 获取打印区域
1423 | !xlSheet.autoFilter(.() = 获取或创建自动筛选区域
1424 | !xlSheet.applyFilter(.() = 应用筛选设定
1425 | !xlSheet.removeFilter(.() = 删除自动筛选
1426 | !xlSheet.setPrintArea(.(cellRange) = 设置打印区域,使用cellRange对象
1427 | !xlSheet.clearPrintRepeats(.() = 清除打印重复行、列
1428 | !xlSheet.clearPrintArea(.() = 清楚打印区域
1429 | !xlSheet.getNamedRangeByIndex(.(index) = 获取指定Index的命名空间信息
1430 | !xlSheet.getNamedRangeByText(.(name,scopeID = 0) = 获取指定名称的命名空间信息
1431 | !xlSheet.setNamedRange(.(name,iniRow,lastRow,iniCol,lastCol,scopeID = 0) = 设置命名空间
1432 | !xlSheet.getHyperlinkByIndex(.(index) = 获取指定Index的超链接信息
1433 | !xlSheet.delHyperlink(.(index) = 删除指定Index的超链接
1434 | !xlSheet.addHyperlink(.(hyperlink,iniRow,lastRow,iniCol,lastCol) = 添加超链接
1435 | !xlSheet.setProtect(.(是否保护,密码,保护类型) = 设置工作表保护
1436 | !xlSheet.getTopLeftView(.() = 获取冻结单元格信息
1437 | !xlSheet.setTopLeftView(.(row,col) = 设置冻结单元格
1438 | !xlSheet.setAutoFitArea(.(iniRow,lastRow,iniCol,lastCol) = 设置自动对齐区域
1439 | !xlSheet.addrToRowCol(.() = 将A1类型定位转为行列,返回cell结构
1440 | !xlSheet.rowColToAddr(.(row,col,rowRelative,colRelative) = rowColToAddr
1441 | !xlSheet.setTabColor(.(colorType) = 使用颜色序列设置工作表名
1442 | !xlSheet.setTabRgbColor(.(red,green,blue) = 使用RGB颜色设置工作表名
1443 | !xlSheet.removeDataValidations(.() =
1444 | !xlSheet.Cell(.(行,列) = 设置单元格对象
1445 | !xlSheet.Cell(.(R1) = 设置单元格对象
1446 | !xlSheet.Cells(.(行,列) = 设置单元格对象
1447 | !xlSheet.Column(.(起始列,[终止列]) = 设置列对象
1448 | !xlSheet.Row(.(起始行,[终止行]) = 设置行对象
1449 | !xlSheet.Range(.("区域描述") = 设置区域对象
1450 | !xlSheet.Range() = !xlRange.
1451 | !xlRange.setValue(.(值或数组,[格式]) = 设置区域的值,并使用单一格式格式化单元格
1452 | !xlRange.setFormula(.(值或数组,[格式]) = 设置区域的公式,并使用单一格式格式化单元格
1453 | !xlRange.copyTo(.(单元格描述) = 复制区域的值到以指定单元格为起始的区域
1454 | !xlRange.merge(.()) = 合并单元格
1455 | !xlRange.ignoreError(.(错误类型)) = 忽略错误
1456 | !xlRange.dataValidation(.(dataType,operaType,value_op,value_between,[允许空值=是],[隐藏下拉选项=否],[输入提示=是],[错误提示=是],[提示标题],[提示文本],[错误标题],[错误文本],[错误类型]) = 设置数据有效性
1457 | !xlRange.value = 获取或设置区域的值
1458 | !xlRange.formula = 获取或设置区域的公式
1459 | !xlRange.format = 获取或设置区域的格式
1460 | !xlSheet.Row() = !xlRow.
1461 | !xlRow.height = 获取或设置行高
1462 | !xlRow.hidden = 获取或设置隐藏行
1463 | !xlSheet.Column() = !xlColumn.
1464 | !xlColumn.width = 获取或设置列宽
1465 | !xlColumn.hidden = 获取或设置隐藏列
1466 | !xlSheet.Cell() = !xlCell.
1467 | !xlSheet.Cells() = !xlCell.
1468 | !xlCell.delMerge(.() = 删除合并单元格
1469 | !xlCell.copyTo(.(行,列) = 复制单元格到指定单元格
1470 | !xlCell.setValue(.(值,[格式]) = 设置单元格的值,并格式化单元格
1471 | !xlCell.setFormula(.(值,[预计算值],[格式]) = 设置单元格的公式,并格式化单元格
1472 | !xlCell.removeComment(.() = 删除注释
1473 | !xlCell.value = 获取或设置单元格的值
1474 | !xlCell.text = 获取或设置单元格的文本
1475 | !xlCell.num = 获取或设置单元格的数值
1476 | !xlCell.formula = 获取或设置单元格的公式
1477 | !xlCell.cellType = 获取单元格的值类型
1478 | !xlCell.format = 获取或设置单元格的格式
1479 | !xlCell.format = !xlFormat.
1480 | !xlCell.isFormula = 获取单元格是否含公式
1481 | !xlCell.isDate = 获取单元格是否是时间
1482 | !xlCell.errType = 获取单元格的错误类型
1483 | !xlCell.merge = 获取当前单元格所在的合并单元格信息,返回mergeCell对象
1484 | !xlCell.blank = 获取或设置单元格是否为空
1485 | _CELLTYPE_EMPTY=@0/*_CELLTYPE_EMPTY*/
1486 | _CELLTYPE_NUMBER=@1/*_CELLTYPE_NUMBER*/
1487 | _CELLTYPE_STRING=@2/*_CELLTYPE_STRING*/
1488 | _CELLTYPE_BOOLEAN=@3/*_CELLTYPE_BOOLEAN*/
1489 | _CELLTYPE_BLANK=@4/*_CELLTYPE_BLANK*/
1490 | _CELLTYPE_ERROR=@5/*_CELLTYPE_ERROR*/
1491 | _PAPER_DEFAULT=@0/*_PAPER_DEFAULT*/
1492 | _PAPER_LETTER=@1/*_PAPER_LETTER*/
1493 | _PAPER_LETTERSMALL=@2/*_PAPER_LETTERSMALL*/
1494 | _PAPER_TABLOID=@3/*_PAPER_TABLOID*/
1495 | _PAPER_LEDGER=@4/*_PAPER_LEDGER*/
1496 | _PAPER_LEGAL=@5/*_PAPER_LEGAL*/
1497 | _PAPER_STATEMENT=@6/*_PAPER_STATEMENT*/
1498 | _PAPER_EXECUTIVE=@7/*_PAPER_EXECUTIVE*/
1499 | _PAPER_A3=@8/*_PAPER_A3*/
1500 | _PAPER_A4=@9/*_PAPER_A4*/
1501 | _PAPER_A4SMALL=@10/*_PAPER_A4SMALL*/
1502 | _PAPER_A5=@11/*_PAPER_A5*/
1503 | _PAPER_B4=@12/*_PAPER_B4*/
1504 | _PAPER_B5=@13/*_PAPER_B5*/
1505 | _PAPER_FOLIO=@14/*_PAPER_FOLIO*/
1506 | _PAPER_QUATRO=@15/*_PAPER_QUATRO*/
1507 | _PAPER_10x14=@16/*_PAPER_10x14*/
1508 | _PAPER_10x17=@17/*_PAPER_10x17*/
1509 | _PAPER_NOTE=@18/*_PAPER_NOTE*/
1510 | _PAPER_ENVELOPE_9=@19/*_PAPER_ENVELOPE_9*/
1511 | _PAPER_ENVELOPE_10=@20/*_PAPER_ENVELOPE_10*/
1512 | _PAPER_ENVELOPE_11=@21/*_PAPER_ENVELOPE_11*/
1513 | _PAPER_ENVELOPE_12=@22/*_PAPER_ENVELOPE_12*/
1514 | _PAPER_ENVELOPE_14=@23/*_PAPER_ENVELOPE_14*/
1515 | _PAPER_C_SIZE=@24/*_PAPER_C_SIZE*/
1516 | _PAPER_D_SIZE=@25/*_PAPER_D_SIZE*/
1517 | _PAPER_E_SIZE=@26/*_PAPER_E_SIZE*/
1518 | _PAPER_ENVELOPE_DL=@27/*_PAPER_ENVELOPE_DL*/
1519 | _PAPER_ENVELOPE_C5=@28/*_PAPER_ENVELOPE_C5*/
1520 | _PAPER_ENVELOPE_C3=@29/*_PAPER_ENVELOPE_C3*/
1521 | _PAPER_ENVELOPE_C4=@30/*_PAPER_ENVELOPE_C4*/
1522 | _PAPER_ENVELOPE_C6=@31/*_PAPER_ENVELOPE_C6*/
1523 | _PAPER_ENVELOPE_C65=@32/*_PAPER_ENVELOPE_C65*/
1524 | _PAPER_ENVELOPE_B4=@33/*_PAPER_ENVELOPE_B4*/
1525 | _PAPER_ENVELOPE_B5=@34/*_PAPER_ENVELOPE_B5*/
1526 | _PAPER_ENVELOPE_B6=@35/*_PAPER_ENVELOPE_B6*/
1527 | _PAPER_ENVELOPE=@36/*_PAPER_ENVELOPE*/
1528 | _PAPER_ENVELOPE_MONARCH=@37/*_PAPER_ENVELOPE_MONARCH*/
1529 | _PAPER_US_ENVELOPE=@38/*_PAPER_US_ENVELOPE*/
1530 | _PAPER_FANFOLD=@39/*_PAPER_FANFOLD*/
1531 | _PAPER_GERMAN_STD_FANFOLD=@40/*_PAPER_GERMAN_STD_FANFOLD*/
1532 | _PAPER_GERMAN_LEGAL_FANFOLD=@41/*_PAPER_GERMAN_LEGAL_FANFOLD*/
1533 | _SHEETSTATE_VISIBLE=@0/*_SHEETSTATE_VISIBLE*/
1534 | _SHEETSTATE_HIDDEN=@1/*_SHEETSTATE_HIDDEN*/
1535 | _SHEETSTATE_VERYHIDDEN=@2/*_SHEETSTATE_VERYHIDDEN*/
1536 | _IERR_NO_ERROR=@0/*_IERR_NO_ERROR*/
1537 | _IERR_EVAL_ERROR=@1/*_IERR_EVAL_ERROR*/
1538 | _IERR_EMPTY_CELLREF=@2/*_IERR_EMPTY_CELLREF*/
1539 | _IERR_NUMBER_STORED_AS_TEXT=@4/*_IERR_NUMBER_STORED_AS_TEXT*/
1540 | _IERR_INCONSIST_RANGE=@8/*_IERR_INCONSIST_RANGE*/
1541 | _IERR_INCONSIST_FMLA=@16/*_IERR_INCONSIST_FMLA*/
1542 | _IERR_TWODIG_TEXTYEAR=@32/*_IERR_TWODIG_TEXTYEAR*/
1543 | _IERR_UNLOCK_FMLA=@64/*_IERR_UNLOCK_FMLA*/
1544 | _IERR_DATA_VALIDATION=@128/*_IERR_DATA_VALIDATION*/
1545 | _PROT_DEFAULT =@-1/*_PROT_DEFAULT */
1546 | _PROT_ALL =@0/*_PROT_ALL */
1547 | _PROT_OBJECTS =@1/*_PROT_OBJECTS */
1548 | _PROT_SCENARIOS =@2/*_PROT_SCENARIOS */
1549 | _PROT_FORMAT_CELLS =@4/*_PROT_FORMAT_CELLS */
1550 | _PROT_FORMAT_COLUMNS =@8/*_PROT_FORMAT_COLUMNS */
1551 | _PROT_FORMAT_ROWS =@16/*_PROT_FORMAT_ROWS */
1552 | _PROT_INSERT_COLUMNS =@32/*_PROT_INSERT_COLUMNS */
1553 | _PROT_INSERT_ROWS =@64/*_PROT_INSERT_ROWS */
1554 | _PROT_INSERT_HYPERLINKS =@128/*_PROT_INSERT_HYPERLINKS */
1555 | _PROT_DELETE_COLUMNS =@256/*_PROT_DELETE_COLUMNS */
1556 | _PROT_DELETE_ROWS =@512/*_PROT_DELETE_ROWS */
1557 | _PROT_SEL_LOCKED_CELLS =@1024/*_PROT_SEL_LOCKED_CELLS */
1558 | _PROT_SORT =@2048/*_PROT_SORT */
1559 | _PROT_AUTOFILTER =@4096/*_PROT_AUTOFILTER */
1560 | _PROT_PIVOTTABLES =@8192/*_PROT_PIVOTTABLES */
1561 | _PROT_SEL_UNLOCKED_CELLS =@16384/*_PROT_SEL_UNLOCKED_CELLS */
1562 | _VALIDATION_TYPE_NONE=@0/*_VALIDATION_TYPE_NONE*/
1563 | _VALIDATION_TYPE_WHOLE=@1/*_VALIDATION_TYPE_WHOLE*/
1564 | _VALIDATION_TYPE_DECIMAL=@2/*_VALIDATION_TYPE_DECIMAL*/
1565 | _VALIDATION_TYPE_LIST=@3/*_VALIDATION_TYPE_LIST*/
1566 | _VALIDATION_TYPE_DATE=@4/*_VALIDATION_TYPE_DATE*/
1567 | _VALIDATION_TYPE_TIME=@5/*_VALIDATION_TYPE_TIME*/
1568 | _VALIDATION_TYPE_TEXTLENGTH=@6/*_VALIDATION_TYPE_TEXTLENGTH*/
1569 | _VALIDATION_TYPE_CUSTOM =@7/*_VALIDATION_TYPE_CUSTOM */
1570 | _VALIDATION_OP_BETWEEN=@0/*_VALIDATION_OP_BETWEEN*/
1571 | _VALIDATION_OP_NOTBETWEEN=@1/*_VALIDATION_OP_NOTBETWEEN*/
1572 | _VALIDATION_OP_EQUAL=@2/*_VALIDATION_OP_EQUAL*/
1573 | _VALIDATION_OP_NOTEQUAL,=@3/*_VALIDATION_OP_NOTEQUAL,*/
1574 | _VALIDATION_OP_LESSTHAN=@4/*_VALIDATION_OP_LESSTHAN*/
1575 | _VALIDATION_OP_LESSTHANOREQUAL=@5/*_VALIDATION_OP_LESSTHANOREQUAL*/
1576 | _VALIDATION_OP_GREATERTHAN=@6/*_VALIDATION_OP_GREATERTHAN*/
1577 | _VALIDATION_OP_GREATERTHANOREQUAL =@7/*_VALIDATION_OP_GREATERTHANOREQUAL */
1578 | _VALIDATION_ERRSTYLE_STOP=@0/*_VALIDATION_ERRSTYLE_STOP*/
1579 | _VALIDATION_ERRSTYLE_WARNING=@1/*_VALIDATION_ERRSTYLE_WARNING*/
1580 | _VALIDATION_ERRSTYLE_INFORMATION =@2/*_VALIDATION_ERRSTYLE_INFORMATION */
1581 | end intellisense**/
--------------------------------------------------------------------------------