I've been working on a large array. I think I've finally got the array itself working, but I'm unable to open the file in a readable way. I tried to write it to an Excel file (.xlsx) and it Excel failed to open it, saying something to the effect of "make sure your file's format matches the file extension". The array is also unreadable in Notepad (I've also tried to write it as a .txt file) , so I can't just copy/paste it over. Is c++ able to write/format data to Excel?
c++ can write to any type of file. The file extension tells excel what the contents of you file look like. So what probably happened, is that what you've written into the file doesn't look like what the extension says it should look like, so Excel complains. For example .csv files should have columns separated by commas and rows separated by newlines(i think). If the data in your file didn't look like this, issues will arise when opening it. It's similar with a .xlsx. Might I also suggest you don't use a .xlsx format if you don't have to, as I doubt the data format is the most straight-forward. I would advise you open a .csv file in Notepad(or similar) to see what the format looks like, open it in excel to see how Excel displays it. Then write a program to write data which is similar(or identical to be safe) to what you've seen in Notepad. The file you write to should be a .csv for Excel to recognise it properly)
Ok, thanks guys- makes sense to try writing to a simpler format first. Just ran it again using .csv, no luck.
I'm trying to use
1 2 3 4 5 6 7
ofstream out("test.csv", ios::out | ios::binary);
/*bunch of stuff being calculated/loops etc
where I define what entry goes in [i][j] of my matrix...*/
out.write((char *) &matr[i][j], sizeof matr[i][j]);
out.close();