Excel read in CVI

I just open the excel file as 'string' in CVI.
I already read http://forums.ni.com/t5/LabWindows-CVI/How-do-I-allocate-memory-for-excel-strings/m-p/754813#M37082
However, I cannot understand it  T-T because I am poor at programming.
Does any guys teach how to open the excel file and appear at table in CVI UI.
Solved!
Go to Solution.

Hi! Babemin,
You need to study the example CVI project "excel2000dem.prj" that comes with your LabWindows/CVI.  Closely investigate the function "ReadDataFromExcel(....)" in the C program "excel2000dem.c".  The first method in this function read each individual cell in the opened Excel file and print out the value of that cell directly on screen.  This example shows you how to read multiple double values from an Excel file "exceldem.xls".  If you don't study this project, you will not be able to complete your task.
Assuming you understand the example program already, open this "exceldem.xls" file manually and add a text "myText1" to cell B35.  Close and save the excel file.
You can then add the following code into the function "ReadDataFromExcel(....)" in the C program "excel2000dem.c" before the label "Error:".  Be sure to add a new declaraction "char *str;" in the function. 
// Open and activate one cell only
    error = CA_VariantSetCString (&MyCellRangeV, "B35");
    error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelSingleCellRangeHandle);
    if (error<0) goto Error;
    // Make range Active
    error = Excel_RangeActivate (ExcelSingleCellRangeHandle, &ErrorInfo, NULL);
    if (error<0) goto Error;
            // Get the value of the Single Cell Range
            error = Excel_GetProperty (ExcelSingleCellRangeHandle, &ErrorInfo, Excel_RangeValue2, CAVT_VARIANT, &MyVariant);
            if (error<0) goto Error;
            if (!CA_VariantHasCString(&MyVariant))
                MessagePopup(APP_WARNING, "Values returned were not of type character string.");
                goto Error;
            error = CA_VariantGetCString(&MyVariant, &str);
            if (error<0) goto Error;
            // Free Variant element
            CA_VariantClear(&MyVariant);
            printf("%s\n ", str);
Now run the project again.  Click "Read Data" in the front panel and you'll see it reads and prints "myText1" on the screen.
This is the method to read a text string from a known cell position in an Excel file. 

Similar Messages

  • NEW Excel Read/Write Lib for JAVA

    FastExcel is a pure java excel read/write component.It's FAST and TINY. provide:
    * Reading and Writing support for Excel '97(-2003) (BIFF8) file format.
    * Low level structures for BIFF(Binary Interchange File Format).
    * Low level structures for compound document file format (also known as "OLE2 storage file format" or "Microsoft Office compatible storage file format").
    * API for creating, reading excel file.
    website http://fastexcel.sourceforge.net/
    Edited by: guooscar on Jun 18, 2009 7:44 PM

    guooscar wrote:
    cotton.m wrote:
    guooscar wrote:
    I read almost all of jxl source code and i try to use it to export/import data the result is slow&#65292;OOM&#65292;that&#146;s allOkay, fair enough.= _ =|||?
    At best this is a pretty specialized tool right? I mean 300,000,000 rows of data imported or exported (and I'm not sure which) daily from/to Excel is a bit of a wtf.
    But without formula support... it's sort of like the difference between a SAX and DOM parser.

  • Excel read multiple cells

    Hi all,
    I want to read multiple cells from excel C1:C2 but I get the variant result:
    Value -> Array(Non Displayable) 
    When I removed string C2 to read cell C1 the result is OK.
    Does anybody know the solution?  
    Thanks in advance. 
    NacNud
    Using LabVIEW 8.5
    Sorry for the duplicate image. Don't know how to remove this.
    Attachments:
    Movie strip path.vi ‏13 KB
    Movie excel edit.vi ‏53 KB
    Movie date.xls ‏16 KB

    Hmmm...
    Solved it myself. The variant is not represented with a probe.
    The solution was to convert the variant data to an 2D array and then probe it.
    See attachement for the solution.
    NaNud
    Message Edited by excel read multiple cells on 05-18-2010 11:44 AM
    Attachments:
    Movie excel edit.vi ‏54 KB

  • Why won't excel read my csv file created with the powersell out-file automatically.

    I wrote a PowerShell script that creates a CSV formatted file.  The script simply creates a comma delimited string for each entry and adds it to a collection.  Then the out-file command write it to a file.
    When you open it with Excel each line is put into one cell.  If you import the file and specify the "," as the delimiter, it imports just fine.  If the data is saved out again as a csv file,  the file is about half the size and opens
    just fine with excel.
    If you open the original file and the file created by Excel with notepad, they look the same.
    So the files are different in size, contents look the same, but Excel won't automatically open the original file.
    Any ideas of why this happens?  Also PowerShell and Excel are both running on Server 2012 R2.  Excel is a remote app.
    If I do an export-CSV, I get some kind of information about the object.
    Here is the script:
    foreach ($group in $groups)
       $header += '"' + $group.name + '",'
       $CSVdata = @()
       $CSVdata += $header
       # Create a user entry
       $users = Get-ADUser -filter * |select SamAccountname, Name | sort SamAccountName
       foreach ($user in $users)
          $Groupmembership = Get-ADPrincipalGroupMembership -Identity $user.SamAccountName
          $userentry = '"' + $user.SamAccountName + '",'
          $user
          foreach ($group in $groups)
              if ($Groupmembership.SamAccountName -contains $group.SamAccountName) { $userentry += '"X",'}
              else { $userentry += '"",' }
           $CSVdata += $userentry
          $CSVdata
          Out-File -inputobject $CSVdata -FilePath c:\batch\GroupMembership.csv

    Ok the script works exactly like I want it.  Thank you very much.
    I am trying to understand the script but I am unable to figure out what the line "$keys=$t.Keys|%{$_}"
    does.  I figured ".keys" was a method but my search for it comes up blank.  Do you have a reference you can point me to?  

  • PDF Viewer/Word&Excel Reader

    I'm trying to find a free pdf viewer, and also to view and read Word/Excel documents - any suggestions ???

    Yes indeed, I can read PDF files, but Word & Excel seem to not want to work, I get the message - ' This document can't be viewed. An error occurred while reading the document'...any ideas...
    before you say download from App Store, they all charge a fee - is there a free of charge version to solve this issue ?

  • ActiveX Excel Reading only problem

    Hi all,
    I have a problem with my program when i write data in excel.
    In a while loop, i write data in a worksheet and i close reference only at the end of acquisition. 
    If the user, for example, scroll with his mouse exatly at the moment the data is writing, the data is not writing !
    How i can solve my problem, put the worksheet in "reading only"? but there is always the scroll problem...
    If you have idea.
    Thanks
    Message Edité par kriss00 le 06-29-2009 04:28 AM

    If it is not necessary to have Excel visible during the data writing process, set the Visible option of the application to FALSE.
    You can always set it to FALSE initially and then set it to TRUE when the data writing process is complete.
    Otherwise, it would seem as though the application is losing focus to the sheet that you are writing to when the user interacts with it.
    CLD | CTD
    LabVIEW 2011 SP1 | TestStand 4.5

  • Open Excel read and write problem

    I am trying to deterimine what is causing excel files to open up as "Read Only" using Labview, when I excplicitly state to open as "ReadWrite"
    It seems to work well in the development environment, but not so well on some PCs in the application environment. 
    Attachments:
    lv_excel.jpg ‏122 KB

    Are you using a template file? Is the file marked as "read only"?
    Do you or the application has proper admin rights in the PC where it used?
    Guru
    Regards
    Guru (CLA)

  • EMail attachment - Excel - Read only

    Hi Guys,
    I am send a email with an attachment using the F.M. - SO_NEW_DOCUMENT_ATT_SEND_API1,
    I am attaching a excel file also and everything works perfect but I wamt to make the attached excel file as READ-ONLY file Now it is modifiable, Please let me know is there any possible way to do it.
    Regards,
    Prabhu

    Hi Prabhu,
    As you want to make the file READ ONLY, i do not think it is possible with this function module. But there is another option which will make your file non transferable.
    Pass RECEIVERS-NO_FORWARD = 'X' in SO_NEW_DOCUMENT_ATT_SEND_API1 function module.
    Hope this will help you out.
    Regards,
    Sourabh

  • Excel reader error in email attachment

    I received 3 Email attachments of the same data in xls, word, and html formats. The xls file had all the correct data except the date fields. The dates were off by a month or so. The word and html formats had the correct dates. I forwarded the email to another address and checked in on my pc. The date fields were correct in the xls file. Same file different reader. The iphone displays the wrong data.
    Any explanation?

    do not post duplicate threads. i have deleted the other one. and
    points will be rewarded if successful
    the SDN angels dont answer just for points. if you find a answer userful, its your duty to award points to say thanks. dont use that as a mean to woo users.
    Regards
    Raja

  • How to read data from many excel files

    I'm aquiring data continusly from several sensors, and every days file name are changed. Data are saved on xls files.
    Now, I'd like to read every data from this files and put them in a waveform. How can I concatenate all files and read the values?

    You probably do not want to use a traditional waveform. LabVIEW has a Waveform Chart which inputs one point at a time. Waveform Graph inputs an array.
    I suspect that the data is stored in an array. You need to read the arrays in and build them into larger arrays. If your right click on the build array vi, you can select concantenate which will append one array to the end of the other. When you have built your giant array, just feed it to a waveform graph.
    If you need to see some example code, go to the advanced search page. It is at www.ni.com >> support >> advanced search (it is at the botton--click on the words). Enter excel read in the all the words field and search just the example programs. There were for hits.
    Jeremy Braden
    National Ins
    truments

  • Excel File read using WebUtil does not work. Gives java.lang.NoSuchMethodEr

    We have a form which reads from an Excel File. The form works in development env., but in the live env when we deployed the form it does not work. Form fails @ the 1st call to Client_OLE2 where we set the Excel file to read.
    For both the envs. the values are given here:
    (1.) Client Forms Version : Forms [32 Bit] Version 10.1.2.0.2 (Production)
    (2.) Application Server Version : 10.1.2.0.2
    (3.) AS Linux Version : (Live) RHEL 5.7 Tikanga / (Dev) Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
    (4.) Client Sun JRE Version :Version 1.5.0 (build 1.5.0_10)
    (5.) Client Web Browser & Version: I.E 8.0.6001 or Mozilla  3.0.15
    (6.) WebUtil Version: 1.0.6Both envs. are the same except the Linux version.
    Works fine in Dev but does not work in Live. Other Webutil functions like file open dialog box works fine in live, only this Excel read is not working.
    Full Error message
    Java Plug-in 1.5.0_10
    Using JRE version 1.5.0_10 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\dinesha.IIL
    c:   clear console window
    f:   finalize objects on finalization queue
    g:   garbage collect
    h:   display this help message
    l:   dump classloader list
    m:   print memory usage
    o:   trigger logging
    p:   reload proxy configuration
    q:   hide console
    r:   reload policy configuration
    s:   dump system and deployment properties
    t:   dump thread list
    v:   dump thread stack
    x:   clear classloader cache
    0-5: set trace level to <n>
    RegisterWebUtil - Loading WebUtil Version 1.0.6
    proxyHost=null
    proxyPort=0
    connectMode=HTTP, native.
    Forms Applet version is : 10.1.2.0
    Exception in thread "AWT-EventQueue-3" java.lang.NoSuchMethodError:
    com.jacob.com.Dispatch.put(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V
         at
    oracle.forms.webutil.ole.OleFunctions.set_obj_property(OleFunctions.java:1216)
         at
    oracle.forms.webutil.ole.OleFunctions.setProperty(OleFunctions.java:333)
         at oracle.forms.handler.ComponentItem.setCustomProperty(Unknown Source)
         at oracle.forms.handler.ComponentItem.onUpdate(Unknown Source)
         at oracle.forms.handler.JavaContainer.onUpdate(Unknown Source)
         at oracle.forms.handler.UICommon.onUpdate(Unknown Source)
         at oracle.forms.engine.Runform.onUpdateHandler(Unknown Source)
         at oracle.forms.engine.Runform.processMessage(Unknown Source)
         at oracle.forms.engine.Runform.processSet(Unknown Source)
         at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
         at oracle.forms.engine.Runform.onMessage(Unknown Source)
         at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
    Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)We connected to Live AS server via VPN and ran the Form in a client machine (where the Dev. is working) but same problem.
    Any help would be greatly appreciated.

    Channa,
    I sounds like you might have missed a configuration step on your Linux application server (AS). I recommend you go back through the configuration of your AS and verify each step of the WebUtil Runtime Setup Checklist was completed correctly. Seach the Forms Help system on "Runtime Setup Checklist" for a copy of the checklist.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Reading Microsoft Excel spreadsheets in Java

    Is it possible to read a Microsoft Excel spreadsheet in Java? If so, how does one do it?

    There exist the JDBC-ODBC bridge driver which enables interaction with Excel files using JDBC, but you're restricted to only one platform (Microsoft Windows), only one (free) driver which is full of bugs and inefficiency (the JDBC-ODBC bridge driver), only one worksheet (the first of the spreadsheet) and only the retrieval of the pure data (no functions, formats, graphs, images, etc).
    Bad idea after all.
    If the sole purpose is to have an embedded database, rather consider JavaDB, Derby or Hypersonic instead of Excel.

  • Read a excel file using swings

    Does anyone know about reading an excel file using swings?
    Right now, I am using com.f1j.ss.*. But looking for more examples like reading and writing a excel file.
    Please suggest me with some good examples?

    1- Swing allows you to design a graphical user interface (to display data from a db or excel file for example)
    2- [Here |http://www.rgagnon.com/javadetails/java-0516.html] several ways to read/write excel.

  • Please read - CATT SCAT excel to SAP

    how do u transfer excel spreed sheet info to SAP

    You can load variants from excel files:
    <a href="http://help.sap.com/saphelp_nw70/helpdata/en/cc/9e139414ae11d2bd11080009b4534c/frameset.htm">http://help.sap.com/saphelp_nw70/helpdata/en/cc/9e139414ae11d2bd11080009b4534c/frameset.htm</a>
    -> External variant editing allows you to create variants for the test case import parameters in a table calculation program such as Microsoft EXCEL.

  • How to move to the next cell in excel sheet

    hi,
    i am working with excel sheet using cvi. i need to put data in cells for that i have function ExcelRpt_WriteData();
    but with this i can give fixed cell range , instead of that is there any function in cvi to point next cell automatically instead of giving cell range we will give intially starting cell range then it has to point to next cell in the sheet. is there any function to do that what i amn expecting.
    Thanks & Regards

    Hello,
    Excel Report Generation instrument is built on top of excel2000.fp, the complete ActiveX interface to Excel. excel2000.fp is loaded together with ExcelReport.fp when you run your project, and you should be able to use functions from both instruments in your app (I have not tested it but since ExcelReport is a wrapper of calls to excel2000 instrument, I'm confident it is true).
    Given this, you can look at excel2000dem example project that you can find on your disk in samples\activex\excel folder together with excelreportdemo which you may have already studied. In this example there are functions to write to a range of cells addressed by row and col indexes, specifically Excel_RangeSetItem (). This can be a good starting point: there is not the automatic cell advance, but you can address cells individually so you can develop your function according to your needs. Excel2000.fp is a low level interface to Excel: in this respect it is a bit more obscure and requires more effort in use but includes more functions than ExcelReport.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

Maybe you are looking for