简体   繁体   中英

Writing c++ output into xlsx file

I have a certain function in my c++ code which compares 2 .bmp files( a reference file is compared with almost 100 files in another directory one at a time), bit by bit and reports the bit errors properly when run a in terminal window. The function that does that is as follows :

 void getBitErrors(char *filename, char *dirName, int height, int width){

DIR *dir;
struct dirent *ent;
//char *f = "";
    dir = opendir (dirName);
if (dir != NULL) {
    /* print all the files and directories within directory */
    while ((ent = readdir (dir)) != NULL) {
        if(strcmp(ent->d_name,".") && strcmp(ent->d_name,".."))
        {
              char f[255]="";
          strcat(f,dirName);
          strcat(f,ent->d_name);    
              printf ("reading image file %s\n", f);
          cout<<"Bit Error "<<getBitError(filename,f,height,width)<<endl;
        }
       }
       closedir (dir);
 } 
else {
perror ("");
    }
}

I wish to have a function in my code that writes the 100 respective comparison values into an xlsx/obs file .(As opposed to having the output displayed by std::cout in a terminal window.) I have looked into 2 different options . 1) Self explanatory libXL which is a paid library and I dont really have a $199 to pay for this library. 2) SimpleXlsx which is slightly hazy. I would be awfully obliged if someone were to explain to me how i could go about achieving my result. OS : Linux Ubuntu 10.10 Maverick.

I suggest you look at the .csv (comma Separated Values) format. You can get a spreadsheet like result with that with much less complexity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM