dde_toolbox

dde_toolbox Git Source Tree

Root/demos/DDE_write_excel.dem.sce

1// ====================================================================
2// Copyright DIGITEO 2008 - 2011
3// Allan CORNET
4// ====================================================================
5
6function demo_write_excel()
7 clc();
8 try
9 winopen('Excel');
10 catch
11 error(999,'Excel not found');
12 end
13
14 // Wait Excel
15 sleep(2000);
16
17 disp('Initialize Connection with Excel');
18 res = ddeopen('Excel','[Classeur1]Feuil1');
19
20 if res then
21 // minimize Excel
22 disp('Minimize Excel');
23 ddeexec('[App.Minimize]')
24
25 STR1 = '[1 2 3]';
26 disp('Put ""' + STR1 + '"" in ' + 'L1C2');
27 ddepoke('L1C2', STR1);
28
29 STR2 = 'Scilab test';
30 disp('Put ""' + STR2 + '"" in ' + 'L2C2');
31 ddepoke('L2C2', STR2);
32
33 disp('Change Font propertie for L2C2');
34 command_line = '[SELECT(""L2C2"")][FONT.PROPERTIES(,""Bold"")]';
35 ddeexec(command_line);
36
37 EXCEL_FILE = TMPDIR + '\DDE_DEMO.xls';
38
39 if fileinfo(EXCEL_FILE) <> [] then
40 mdelete(EXCEL_FILE);
41 end
42
43 command_line = '[SAVE.AS(""' + EXCEL_FILE + '"",1,"""",FALSE,"""",FALSE)]';
44 disp('Save excel file: ' + EXCEL_FILE);
45 ddeexec(command_line);
46
47 // maximize Excel
48 disp('Maximize Excel');
49 ddeexec('[App.Maximize]')
50
51 disp('Quit Excel');
52 ddeexec('[Quit()]');
53
54 disp('Close Connection with Excel');
55 ddeclose();
56
57 if isfile(EXCEL_FILE) then
58 winopen(EXCEL_FILE);
59 end
60
61 end
62endfunction
63// ====================================================================
64demo_write_excel();
65clear demo_write_excel;
66// ====================================================================

Archive Download this file

Branches