Library updated to work on the most recent MT4.
=============
I use DDE library provided by Windows. No custom / proprietary dll.
The process are as follow:
1. Initialize DDE
2. Create string handle for Excel Application (in DDE term, it is known as SERVICE)
3. Create string handle for Sheet name (TOPIC)
4. Connect to Sheet
5. Free the above handles, they won't be used anymore
6. Create string handle for cell (ITEM) using cell address in R1C1 style
7. Send the data
8. To export data to another cell, repeat 6-7
9. You can reuse the already created items' handle (in case you want to update the cells regularly)
10. Before program return, free all items' string handle
11. Disconnect Excel and sheet
12. Uninitialize DDE
Make sure to enable "Allow DLL imports" in Expert Advisor settings.
You may need to disable MT4 DDE Server before running this script.
There are 2 files attached in this post:
- ExcelExportLib.mq4, put this file in experts\libraries folder. This is just a simple mq4 library that wrap a few DDE functions.
- ExcelExportTest.mq4, put this file in experts\scripts folder. This is a test script that will write text on Excel Sheet 1, cell R2C2
Cheers,
sangmane
=============
I use DDE library provided by Windows. No custom / proprietary dll.
The process are as follow:
1. Initialize DDE
2. Create string handle for Excel Application (in DDE term, it is known as SERVICE)
3. Create string handle for Sheet name (TOPIC)
4. Connect to Sheet
5. Free the above handles, they won't be used anymore
6. Create string handle for cell (ITEM) using cell address in R1C1 style
7. Send the data
8. To export data to another cell, repeat 6-7
9. You can reuse the already created items' handle (in case you want to update the cells regularly)
10. Before program return, free all items' string handle
11. Disconnect Excel and sheet
12. Uninitialize DDE
Make sure to enable "Allow DLL imports" in Expert Advisor settings.
You may need to disable MT4 DDE Server before running this script.
There are 2 files attached in this post:
- ExcelExportLib.mq4, put this file in experts\libraries folder. This is just a simple mq4 library that wrap a few DDE functions.
- ExcelExportTest.mq4, put this file in experts\scripts folder. This is a test script that will write text on Excel Sheet 1, cell R2C2
Cheers,
sangmane
Attached File(s)
ExcelExportLib_2021.ex4
7 KB
|
623 downloads
|
Uploaded Feb 25, 2021 7:51am
ExcelExportTest.mq4
1 KB
|
642 downloads
|
Uploaded Feb 25, 2021 7:51am