http://bugs.winehq.org/show_bug.cgi?id=24759
--- Comment #8 from bill lam cbill.lam@gmail.com 2010-10-16 19:32:33 CDT --- The safearray created in test was in fact incorrect, but the safearraygetubound/safearraygetlbound were also incorrect in the same manner. error cancel error hence the result appeared to be correct. What is needed is a third party program that will use the safearray to validate the safearray created.
It began when someone asked in forum
In studying OLE Automation I found an example of programming via C# that appears to write an array directly to a spreadsheet (see code fragment below): // Create an array to multiple values at once. string[,] saNames = new string[5,2];
saNames[ 0, 0] = "John"; saNames[ 0, 1] = "Smith"; saNames[ 1, 0] = "Tom"; saNames[ 1, 1] = "Brown"; saNames[ 2, 0] = "Sue"; saNames[ 2, 1] = "Thomas"; saNames[ 3, 0] = "Jane"; saNames[ 3, 1] = "Jones"; saNames[ 4, 0] = "Adam"; saNames[ 4, 1] = "Johnson";
//Fill A2:B6 with an array of values (First and Last Names). oSheet.get_Range("A2", "B6").Value2 = saNames;
After some iterations, I got a way to do using safearray with a test of pseudocode like,
NB. base is idispatch interface base=. createstddispatch 'Excel.Application' NB. wb is workbooks property of base wb=. base.workbooks NB. open method to open an excel file wb.open '/path/to/an_existing_excel_file' awb=. base.activeworkbook aws=. awb.worksheets 1 NB. sheet 1-base NB. write number using safearray NB. call method range of aws object for get block of shape of 3,4 range=. aws.range 'C12:F14' NB. create a safearray of integer NB. 0 1 2 3 NB. 4 5 6 7 NB. 8 9 10 11 NB. and wrap it inside a variant for ole automation use. sa=. safearray of shape (3,4) and values 0,1,2,3,4,5,6,7,8,9,10,11 range.value2=. sa free sa NB. read safearray for validation debugprint range.value2 NB. save and cleanup base.DisplayAlerts=. false awb.save awb.close base.quit
open the excel file, you will see a block like this, 0 5 10 #n/a 4 9 3 #n/a 8 2 7 #n/a
the last column was not initialised and the order of number in cells shuffled.