LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I need to select the Excel file through file select popup and read the data and convert it.

Solved!
Go to solution

I should write a program for selecting a excel file through fileselectpopup and read the data present in excel file and convert it to binary file and store it in some location.

I've written program till selecting excel file through file select popup but I'm not able to open excel file and converting it. I read excepreport, excel2000 examples, but I didn't understand it. Please some one help and guide me step by step. Thanks in advance.

-Vinay

0 Kudos
Message 1 of 9
(2,847 Views)

Anyone??

0 Kudos
Message 2 of 9
(2,804 Views)

In what does this discussion differs from this other one of yours? And have you already tried to approach part of the question by yourself?



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?
Message 3 of 9
(2,797 Views)

 Here, Its with Excel file. Txt file operation is almost done. Now I am not able to understand to get data from Excel sheet.

0 Kudos
Message 4 of 9
(2,786 Views)

So if you need help with Excel you can search for examples installed in CVI related to that product: use the example finder (Help >> Find Examples... menu function) searching for "Excel". Among all the examples listed you can find excel2000dem, which shows the basis of reading/writing to spreadsheets, and excelreportdemo which demonstrates the use of excelreport instrument. There you find working examples to study in order to develop your application.

 

Please note that all these are examples of interaction between CVI and Excel via ActiveX technology. This means that you need Excel to be installed on the PC where your application is to be developed / run, Additionally, some reduced versions of Excel lack the ActiveX interface, so you need to be sure it is present in the version you are using (I remember what was called Excel Starter a few years ago, which was missing such functionality)



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?
Message 5 of 9
(2,781 Views)
Spoiler
 

HI,

now here I am having problem in reading the data one by one.

i want to read data from a single column of some above 200 rows, i have ranging problem in the code so please help with this problem.

the code is,

 


////////////////////////////////////read data///////////////////////



error = CA_VariantSetCString (&MyCellRangeV, "A2:C241");
error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);
CA_VariantClear(&MyCellRangeV);
if (error<0)
printf("new problem1");


error = Excel_RangeActivate (ExcelRangeHandle, &ErrorInfo, NULL);
if (error<0)
printf("new problem2");

SetStdioWindowVisibility (1);
printf("Get one cell value at a time:\n");
for (i=0;i<ROWS;i++)
{
printf(" ");
j=2;
// Ask for the ith by jth value of the range which returns a dispatch to a new single cell range
error = Excel_RangeGetItem (ExcelRangeHandle, &ErrorInfo, CA_VariantInt (i+1), CA_VariantInt (j+1), &MyVariant);


// Get the DISPATCH pointer
error = CA_VariantGetDispatch (&MyVariant, &MyDispatch);


// Create a new Range Object from DISPATCH pointer
error = CA_CreateObjHandleFromIDispatch (MyDispatch, 0, &ExcelSingleCellRangeHandle);


// Get the value of the Single Cell Range
error = Excel_GetProperty (ExcelSingleCellRangeHandle, &ErrorInfo, Excel_RangeValue2, CAVT_VARIANT, &MyVariant);




error = CA_VariantGetDouble (&MyVariant, &d);


// Free Variant element
CA_VariantClear(&MyVariant);

//Free Range Handle


printf("%f ", d);
printf("\n");
}
printf("\n");

 

 

 

the sample excel file is 

Download All
0 Kudos
Message 6 of 9
(2,742 Views)

Helppppp??

0 Kudos
Message 7 of 9
(2,720 Views)
Solution
Accepted by topic author vinaypooja

As you may know, Excel ranges are 1-based. This is quite clear in the excel2000dem source which you took your code from, since it iterates on rows i-from-0-to-something, columns j-from-0-to-something and then gets the cell (CA_VariantInt (i+1), CA_VariantInt (j+1))

Now you have forced j = 2 but you have not changed the code, which results in getting values from the 3rd column, which is empty... Smiley Frustrated

 



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?
Message 8 of 9
(2,717 Views)

thank you so much.

0 Kudos
Message 9 of 9
(2,674 Views)