March 7th, 2012, 5:14 pm
I had to do this a while back, my solution is either elegant or a candidate for the scariest piece of Excel crap in the history of the world, depending on how you see it.A workbook is just a file...So save it there.A thing you need to know is the default standard file header style user in most Microsoft file formats....It basically saysstruct OCli {uint magic_cookie;uint something, otherhing...;unsigned int uloff;unsigned int ulItemCt;size_t ulThingSize;data_type things[1];} Header;ulOff is where the data actually begins and things is not usually an array with one element, ulItemCt determines how many of these items are actually present (oh the fun you can have changing it)ulThingSize is how big each element is. You might think this is superfluous, but if you come to the Random Walkers this Thursday, for the price of a beer I will tell you a tail of pain, loathing, greed and why my team called it the Bug Of Death.What is not there is a size of the file, actually there often it is, but in the last 34 years of my programming using MS products I've never seen it enforced, so you can shove any old shit at the end of most MS files.In the generating program open the XLS fileSeek to the end of the file, capturing the offset from the start.Write the data to the the workbook fileclose itRename the file from Filename.xlsx to Filename.XXXX.xls where XXXX is the offset from the start of the file.VBA and C++ code in Excel can access the filename and the file itself may be read whilst open, so it's a simple matter or parsing the filename to know where to start reading the fileThere's a slightly whackier solution that involves a C++ .EXE that thinks it's a spreadsheet, but you probably don't need to go there.
Last edited by
DominicConnor on March 6th, 2012, 11:00 pm, edited 1 time in total.