If I do this then I only get the first value of the float array in every row in the excel column A:
float[] ftmp // my float array
Excel.Range rng = ws.Range[ws.Cells[1, 1], ws.Cells[ftmp.Count(), 1]];
rng.Value = ftmp;
I understand that it has something to do with transposing based on similar questions.
Writing an array to a range. Only getting first value of array
but I can't find the transpose function in neither interop library or the worksheet function library?
CodePudding user response:
Not sure you can transpose an array as is to cells. But you can loop over.
for(int i = 0; i < ftmp.Length; i ) {
Excel.Range rng = ws.Range[ws.Cells[i 1, 1], ws.Cells[i i, 1]];
rng.Value = ftmp[i];
}
CodePudding user response:
This works for me
float[] fvals = ...
dynamic xvals = ws.Range[ws.Cells[1, 1], ws.Cells[fvals.Length, 1]].Value2;
for (int i = 0; i < fvals.Length; i )
{
xvals[i 1, 1] = fvals[i];
}
ws.Range[ws.Cells[1, 1], ws.Cells[fvals.Length, 1]].Value2 = xvals;