Excel(xls) to MQL4 - page 2

 
fxdj:
if you need complate code i can send
Yeah, show me the complete code so I can better understand what you're trying to do.
 
fxdj:

i wonder even if its works is there way to read data from xls file

thanks

Sure, the xls file is a binary file, just read this first : http://www.openoffice.org/sc/excelfileformat.pdf
 
ubzen:
Yeah, show me the complete code so I can better understand what you're trying to do.
int start()
{
int handle;
string str;
handle = FileOpen("info.txt",FILE_READ);
str=FileReadString(handle);
string hebe = str;

int cur = 12;
int cor = 1;
ObjectCreate("inf", OBJ_LABEL, 0, 0, 0);
ObjectSetText("inf", hebe, 10, "Times New Roman", Red);
        ObjectSet("inf", OBJPROP_CORNER, cor);
        ObjectSet("inf", OBJPROP_XDISTANCE, 10);
        ObjectSet("inf", OBJPROP_YDISTANCE, cur);
return;
}

i have this code works well as info.txt i mean it can read inside of the text and show on the screen. but when i changed info.cvs, or xls, FILE_CSV|FILE_READ or FILE_BIN instead of txt damn thing doesnt work and i could find how to do on internet

am i want an impossible thing :)

thanks

 
Which version of windows are you using?
 
fxdj:

i have this code works well as info.txt i mean it can read inside of the text and show on the screen. but when i changed info.cvs, or xls, FILE_CSV|FILE_READ or FILE_BIN instead of txt damn thing doesnt work and i could find how to do on internet am i want an impossible thing :)

thanks

This is what I have in mind.

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define Alpha 26    //Number_Of_Letters_In_The_Alphabet
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void start(){
    string Golf=Anyxls_Data(1,6);
    Alert("Im_Going_To_Play_Some_"+Golf);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string Anyxls_Data(int Row, int Column){
    string Temporary_Ray[Alpha][Alpha];
    int Handle=Anyxls_Handle(); if(Handle<0){return;}
    FileSeek(Handle,0,SEEK_SET);
    for(int i=0; i<Alpha; i++){
        for(int j=0; j<Alpha; j++){
            if(FileIsEnding(Handle)){break;}
            Temporary_Ray[i][j]=FileReadString(Handle);
        }
    }
    string Data=Temporary_Ray[Row][Column];
    return(Data);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int Anyxls_Handle(){
    static int Handle; static bool Opened; string Name="any.xls";
    if(Opened && Handle>-1){return(Handle);}
    if(!Opened){
        Handle=FileOpen(Name,FILE_CSV|FILE_READ,';');
        if(Handle>-1){Opened=true;}else{
            Print("Error_Make_Sure_File_Is_Created");}
    }
    return(Handle);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When testing in the Strategy Tester, you want to place the Data-File in the "\tester\files" folder. The File looks something like below. Also Attached. ( Rename the file any.xls ).

A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z
Alpha;Bravo;Charlie;Delta;Echo;Foxtrot;Golf;Hotel;
India;Juliett;Kilo;Lima;Mike;November;Oscar;Papa;
Quebec;Romeo;Sierra;Tango;Uniform;Victor;Whiskey;
X-ray;Yankee;Zulu
You do-not want to use Microsoft Excel to Create the File. You could Edit the file using a Spread-Sheet program like Excel but be careful not to save the extra stuff these programs tend to add to the files. Anyways, you might be better off using .txt with Tab separated for simple stuff.
Files:
any.txt  1 kb
 
Ickyrus:
Which version of windows are you using?

win 7 ulti 32bit last sp
 
ubzen:

This is what I have in mind.

When testing in the Strategy Tester, you want to place the Data-File in the "\tester\files" folder. The File looks something like below. Also Attached. ( Rename the file any.xls ).

You do-not want to use Microsoft Excel to Create the File. You could Edit the file using a Spread-Sheet program like Excel but be careful not to save the extra stuff these programs tend to add to the files. Anyways, you might be better off using .txt with Tab separated for simple stuff.


sorry for late response i was bussy wiht my other jobs thanks a lot its seem works ive tired it with expert and i think i can modify it for my project. see ya later if ill have any question about modify i hope will not

thanks again best regards

Reason: