NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
David_Lee
Posts: 159
0 Kudos

Re: Read Write Data from Excel sheet.

Hi,

 

Why cannot read out the string type data from the worksheet? I have one row and 5 columns in a excel sheet, my code is like follows:

 

func()

{

    char cellStr[1][500];

    ...

 

 

    Excel_ActiveApp(NULL, 1, LOCALE_NEUTRAL, 0, &excelAppHandle);

    Excel_GetProperty(excelAppHandle, NULL, Excel_AppWorkbooks, CAVT_OBJHANDLE, &excelWorkbooksHandle);

    Excel_SetProperty (excelAppHandle, NULL, Excel_AppVisible, CAVT_BOOL, VFALSE);

    Excel_WorkbooksOpen(excelWorkbooksHandle, NULL, filePath, CA_DEFAULT_VAL,
                                             CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                             CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                             CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                             CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                             CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                             CA_DEFAULT_VAL, &excelWorkbookHandle);   

  Excel_GetProperty(excelAppHandle, NULL, Excel_AppSheets, CAVT_OBJHANDLE, &excelSheetsHandle);

  Excel_SheetsItem(excelSheetsHandle, NULL, CA_VariantInt(sheetNum), &excelWorksheetHandle); /* sheetNum equals 1, the first worksheet*/

  Excel_WorksheetActivate(excelWorksheetHandle, NULL);

 ExcelRpt_ReadData(excelWorksheetHandle, "A2:E2", ExRConst_dataString, cellStr[0]);

...

}

 

After excuating the code, cellStr has a  irrecognizable info. please advise how to get the right string value from the excel's cell.

 

thanks.

 

David

 

Trusted Enthusiast
RobertoBozzolo
Posts: 4,572
0 Kudos

Re: Read Write Data from Excel sheet.

Hi David,

you can find very useful informations into this post from Mert.

 

 

As an additional suggestion, please consider that this thread is not intended for normal question/answer.

You should create a new thread for new questions like this one: you gain better visibility (besides the fact that you are forced to pass by a search in the forum, which in this case would have indeed returned the thread I am pointing you to :smileywink: )




Using LW/CVI from 3.1 on.

My contributions to the Developer Zone Community
________________________________________
If I have helped you, why not giving a kudos?
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page