12-20-2015 01:57 PM
hello,
i'm a begginer in Labwindows CVI so excuse me for the poor code.
i've noticed there are a lot of answers for writing to excel file but my problem is not similar.
i read numbers from a sensor into an array and i want to copy them in real time to excel file.
the problem is that i dont know how to extend the range of the rows in the excel automaticly without manually enter the row's number (for example "A1:A10")
here is a part of the program:
double val[]={8.7,9.2,1} ; // example of array of numbers
ExcelRpt_WriteData (rawDataWorkSheetHandle, A1,ExRConst_dataDouble, 1, 1,&val[0]);
ExcelRpt_WriteData (rawDataWorkSheetHandle, A2,ExRConst_dataDouble, 1, 1,&val[1]);
ExcelRpt_WriteData (rawDataWorkSheetHandle, A3,ExRConst_dataDouble, 1, 1,&val[2]);
i've tried to use these type of writing:
A[i]
A[i+1];
A[i+2];
but it didnt work.
i asume there is a more useful way to do it but i dont know how.
i appreciate all the help i can get!
12-20-2015 05:25 PM - edited 12-20-2015 05:26 PM
First of all, it seems you are writing one value at a time. If this is true, I suggest you to use ExcelRpt_SetCellValue instead of ExcelRpt_WriteData; the former is notably simpler in that is accepts a scalar instead of an array of values.
Having said this, whichever is the command you use the range to write to is passed as a string, so you can create it with the appropriate row number and pass it to the function:
int i; double value {} = { 0.0, 1.2, 3.14, 5.25, 1.17, 8.3 }; char range[16]; for (i = 1; i <= 6; i++) { sprintf (range, "A%d", i); ExcelRpt_SetCellValue (worksheetHandle, range, ExRConst_dataDouble, value[i]); }
12-21-2015 06:51 AM
thank you! it's been very helpful!
12-21-2015 07:15 AM
You're welcome!