Glenn BarnasGlenn Barnas KiX Supporter
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
The problem with xlRangeValue is resolved. Seems that neither of us read the header completely. It states quite clearly that when writing it expects an Array Of Arrays - we were providing a simple array. I verified that my old code worked with the current library, then dug into what we were feeding the function.
The solution is to introduce a new array - $xlData - and assign each row we read from the CSV file to a record in that array. The result is an array of arrays, and the xlRangeValue function is then called once after the data from the CSV file is exhausted. The code below works, creating a workbook with a single sheet, populated with data.
Note the key changes -
Addition of a $xlData array
Defining the index pointer to -1; incrementing it before referencing the array; using it to re-dimension the array
Calling xlRangeValue with the $xlData array after closing the input CSV file.
BTW - I get a format warning when opening the .XLS file in Excel 2K7, but it opens fine.
Glenn
_________________________ Actually I am a Rocket Scientist!