We will introduce you to XLSGate Programming with Metatrader4. This instruction is basic and designed to get started rapidly.
Step 1 : Import DLL Functions
We have provided xlsgate.mqh file in Resources\Metatrader4\ folder. Copy this file into \MQL4\includes\ folder and import it with #import directive from MQL
Theoretically you could also import functions manually without including provided .mqh file, but this way is not very convenient. We keep updating xlsgate.mqh file during time. Make sure to copy it into your Includes folder whenever you update your XLSGate package.
Step 2 : Initialisation
To initialize we need to call ExcelInit and ExcelStart functions. Both must return TRUE. This is very important to capture. ExcelInit requires a name of client. This name should be unique. Initialisation should be places inside OnInit() function because these two functions needs to be called only once.
Print("Excel has been initialized properly");
Logics like adding new Sheet would also go inside OnInit after ExcelStart
Step 3 : Publish Data
Publishing data usually happens inside OnTick() function but also other scenarios are possible. To Publish data you would use one of ExcelSetValue, ExcelSetString, ExcelSetFromArray, ExcelSetFromArrayV, ExcelSetFromArrayH etc. Here is very basic code to export current Bid, Ask, Spread to Chart: