LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Write data into excel table

Hi,

 

i have a array of unsigned int (24-elements)  and want to write it into a excel table (3colum-8row)

My code looks like this:                          

                            unsigned int index_cnt = 0;
                            for(int col = 0; col <= 2; col ++)
                            {
                                excel_address = RangeString(1+col,1,1,8);
                                ExcelRpt_WriteData(rawDataWorkSheetHandle,excel_address,ExRConst_dataDouble, 8, 1,
                                                                    RX_buffer_int[index_cnt]);
                                index_cnt = index_cnt+8;
                            }


I thought i just have to "point" at the first element of the column, then the rest of column will be writed.

But there was a problem with the "Pointer to const void".

If i try to cast by using;: (void *) &RX_buffer_int[index_cnt]. there was  NON-FATAL-RUN-TIME-ERROR.

And is there a way to export to unsigned int, because i dont want to cast the values into double.

Many thanks

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

Hi Chocobombo,

 

did you check out the examples that are shipping with CVI? You can find them in CVI:

 

Help-> Find Examples -> Search for excel

 


These examples should be useful for your task. I also got some additional links here which should be useful:

 

Generating Excel Reports

How to write to rows

0 Kudos
Message 2 of 4
(4,586 Views)

Hi LamD,

thanks for ur rely.

apparently in the CVI demo they already had the data displayed in a table GUI, and print the whole table into excel file.

In my case the data is in a uint array.

Maybe with the export function to excel, the "cell range" information has to match the size and dimension of the array to write.

So i had to manually split my big array into few smaller ones before write into excel. (somehow it worked 🙂 )

And since there is no support for uint Data-type in ExcelRpt_WriteData, the uint data have to be cast into string.

My code looks like this: (there must be a better way to do the same job)

 

                            unsigned int index_cnt = 0;
                            for(int col = 0; col <= 2; col ++)
                            {
                                char buff[10];
                                char * excel_data_col[8];

                                // cast to string and copy into smaller array
                                for(int row_cnt = 0; row_cnt < 8; row_cnt++)
                                {
                                    Fmt(buff, "%s<%i", RX_buffer_int[index_cnt+row_cnt]);
                                    excel_data_col[row_cnt] = buff;
                                }
                                excel_address = RangeString(1+col,1,1,8);
                                ExcelRpt_WriteData(rawDataWorkSheetHandle,excel_address,ExRConst_dataString, 8, 1,
                                                                    excel_data_col);
                                index_cnt = index_cnt+8;
                            }

 

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

Hi! Chocobombo,

 

Please look into the sample Excel project "excel2000dem.prj" instead.  The function WriteDataToExcel(...) in "excel2000dem.c" is the one that you should use for writing data array to Excel. 

0 Kudos
Message 4 of 4
(4,545 Views)