1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 |
static
void test(Args _args) { int
lineNum; int
titleLines; SysExcelApplication excel; SysExcelWorkbooks books; SysExcelWorkbook book; SysExcelWorksheets sheets; SysExcelWorksheet sheet; SysExcelRange columns; SysExcelRange column; SysExcelCells cells; SysExcelCell cell; SysExcelStyles ExcelStyles; SysExcelStyle ExcelStyle; SysExcelFont ExcelFont; COM range; COM ExcelCom; int
newLines,beginLines; int
maxLines = 1000; TextBuffer txtBuffer; CustTable ct; ; excel = SysExcelApplication::construct(); books = excel.workbooks(); book = books.add(); sheets = book.worksheets(); sheet = sheets.itemFromNum(1); ExcelCOM = sheet.comObject(); txtBuffer = new
TextBuffer(); while
select ct { linenum++; newLines++; txtBuffer.appendText( strfmt( "%1\t%2\t%3\n" , ct.AccountNum ,ct.Name, ct.Email)); if ( newLines == maxLines) { txtBuffer.toClipboard(); txtBuffer.setText( "" ); beginLines = linenum+titleLines+1- newlines; range = sheet.range(strfmt( "A%1"
, beginLines)).comObject(); range.Select(); ExcelCOM.paste(); newLines=0; } } if ( newLines!=0) { txtBuffer.toClipboard(); txtBuffer.setText( "" ); beginLines = linenum+titleLines+1- newlines; range = sheet.range(strfmt( "A%1"
, beginLines)).comObject(); range.Select(); ExcelCOM.paste(); } book.saveAs( "C:\\1abc.xls" ); excel.visible( true ); } |
考虑到textBuffer能存储的文本长度有限,所以需要分批次将数据从textBuffer粘贴到Window粘贴板。
AX 利用windows粘贴板功能实现批量数据快速导出EXCEL,布布扣,bubuko.com
AX 利用windows粘贴板功能实现批量数据快速导出EXCEL
原文:http://www.cnblogs.com/sxypeace/p/3568625.html