LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

write to excel file

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!

0 Kudos
Message 1 of 4
(4,056 Views)

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]);
}

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(4,046 Views)

thank you! it's been very helpful!

0 Kudos
Message 3 of 4
(4,031 Views)

You're welcome!



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 4
(4,027 Views)