String to 2d array to excel sheet

Greetings,
I am a beginner at labview, tring to explore it. I am stuck in a task as follows
I have a txt file which i want to convert it into array then display it into excel file.
Below is the string data in the txt file
x=1.0,y=4.0,z=2.5,x=1.1,y=4.1,z=2.6,x=1.2,y=4.2,z=2.7,x=1.3,y=4.3,z=2.8,x=1.4,y=4.4,z=2.9,
I want to convert the above data to an array/excel sheet like below
x=1.0  y=4.0  z=2.5  
x=1.1  y=4.1  z=2.6
x=1.2  y=4.2  z=2.7 
x=1.3  y=4.3  z=2.8
x=1.4  y=4.4  z=2.9
Now i know that match mattern would be used to seperate the delimiter ',' but what after then, i m confused in how to progress further.
Please guide me how to solve this task
Regards
Attachments:
test11.vi ‏8 KB

Hi,
    Going by your original requirements, you want the spreadsheet to display "x=1.0", etc... in the cells. Just to confirm, you don't want values which could be plotted, you want a table with text that has the axis and an equals sign? If that is the case, then you just write the folded string into a text file with the .csv extension and Excel opens it no problems. See attached. If you what you really want is a table of numbers/values, then we have to modify the program a little...
Attachments:
StringParse.vi ‏37 KB
Parsed.png ‏548 KB
Parsed.csv ‏1 KB

Similar Messages

  • Problem in reading data from Excel sheet to 2D string array (ActiveX & LabView).

    I am trying to read data from Excel sheet to 2D string array (ActiveX & LabView). Error -2147352571 is generated (type mismatch) if cell value is "#NULL!", "#N/A" etc. What should I do?

    Hello �
    Is the error happening when the cell value is #NULL or #NA only?
    Sometimes these errors occur because of an ActiveX object mismatch. The version of the ActiveX object might have changed or been updated since the VI was created. The VI tries to use an earlier, incompatible version of the ActiveX object.
    To solve the problem, you need to link automation refnum terminal to the correct ActiveX object. To do so, right-click an automation refnum terminal and choose Select ActiveX Class»Browse from the shortcut menu. From the Type Library pull-down menu, select the latest version of the library you want to use, such as Microsoft Excel Object Library. In the Objects list, select an ActiveX object, and click the OK button. Link ea
    ch automation refnum terminal in the VI and its subVIs until the run arrow is not broken. Also, you might have to replace some or all of the Invoke Nodes and Property Nodes for the ActiveX objects.
    Also, I came across this Knowledgebase. The error number is slightly different but it is always good to check it out and make sure it is not your case.
    Hope this helps.
    S Vences
    Applications Engineer
    National Instruments

  • How to insert 2-D array of elements in excel sheet

    I have a 2-D array of elements. I want to insert this array into an excel sheet and display the data in a graph. I used the example "excel insert table" but the problem with that VI is, it is inserting the elements cell by cell which is taking long time. I am wondering whether there is way to insert a complete column or row into excel sheet at a time.
    Thank you,
    Mudda.

    Hi,
    Try this vi which inserts the table in one operation. You can modify it to suit your purposes.
    Hope this helps.
    Edit: Should note that it works for both string and numeric array inputs.Message Edited by DavidT on 06-29-2005 10:09 AM
    Attachments:
    Excel Insert Table (LV7.1).vi ‏100 KB

  • Non-English string access from excel sheet through JDBC

    My excel sheet data is
    Test ������������
    I am using JDBC connectivity for accessing the Excel sheet.
    Code looks like,
    List Output = new List();
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    for(int i=1; i <= numberOfColumns; i++){
    Output.add(rsmd.getColumnLabel(i));
    catch( Exception e )
    System.err.println( e );
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    Now. I am showing those data into the table(JTable) Applet programming.
    For, English string it is showing properly but, for non-English string are showing �???????????????????�
    I would like to know what could be the reason.
    Addional info:
    ava version "1.6.0_01"
    Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
    Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
    If possible please send some reference code .

    I have one excel sheet which having differenct countries specific meaining of common words.
    I am using JDBC connectivity for accessing that Excel sheet.
    Code looks like,
    List Output = new List();
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    for(int i=1; i <= numberOfColumns; i++){
    Output.add(rsmd.getColumnLabel(i));
    catch( Exception e ){
    System.err.println( e );
    finally{
    try{
    stmnt.close();
    c.close();
    catch( Exception e ){
    System.err.println( e );
    Now. I am showing those output data into the table(JTable) in my Applet programming.
    For, English string it is showing properly but, for non-English strings are showing question marks like, �?????�
    I would like to know what could be the reason.
    Please help me, i am stuck in my project.

  • Identifying text file names and importing on single Excel sheet

    Hey!
    Does anybody can help me with Excel VBA macro code in order to import data from text files into single Excel spread sheet? I want to create User Form where user can select start and end date of interest and macro code will import
    bunch of text files depending on user demands...
    My text files are named: 20130619004948DataLog.txt (meaning: yyyy mm dd hh mm ss). Text file contains recordings for each 15 seconds... It would be great to omit time tail (meaning that user can only specify date). Text files for one day of interest (I have
    text files covering whole year):
    20130619004948DataLog.txt
    20130619014948DataLog.txt
    20130619024948DataLog.txt
    20130619034948DataLog.txt
    20130619044948DataLog.txt
    20130619054948DataLog.txt
    20130619064948DataLog.txt
    20130619074948DataLog.txt
    20130619084948DataLog.txt
    20130619094948DataLog.txt
    20130619104948DataLog.txt
    20130619114948DataLog.txt
    20130619124948DataLog.txt
    20130619134948DataLog.txt
    20130619144948DataLog.txt
    20130619154948DataLog.txt
    20130619164948DataLog.txt
    20130619174948DataLog.txt
    20130619184948DataLog.txt
    20130619194948DataLog.txt
    20130619204948DataLog.txt
    20130619214948DataLog.txt
    20130619224948DataLog.txt
    20130619234948DataLog.txt
    Option Explicit
    Sub SearchFiles()
    Dim file As Variant
    Dim x As Integer
    Dim myWB As Workbook
    Dim WB As Workbook
    Dim newWS As Worksheet
    Dim L As Long, t As Long, i As Long
    Dim StartDateL As String
    Dim EndDateL As String
    Dim bool As Boolean
    bool = False ' to check if other versions are present
    StartDateL = Format(Calendar1, "yyyymmdd")
    EndDateL = Format(Calendar2, "yyyymmdd")
    ' I am using Userform asking user to select the date and time range of interet,
    ' However, I want to use only the date to filter the files having the name with that particular date
    file = Dir("c:\myfolder\") ' folder with all text files
    ' I need assistance with the following part:
    '1) How to filter and select the files between StartDateL and EndDateL_
    '(including files with that dates as well)?
    While (file <> "")
    If InStr(file, StartDateL) > 0 Then 'Not sure if the statements inside parenthesis is correct
    bool = True
    GoTo Line1:
    End If
    file = Dir
    Wend
    Line1:
    If Not bool Then
    file = "c:\myfolder\20130115033100DataLog.txt" 'Just for a test that the code works as intended
    End If
    'This part for the selected text files to be loaded on a single Excel Sheet.
    Set myWB = ThisWorkbook
    Set newWS = Sheets(1)
    L = myWB.Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
    t = 1
    For x = 1 To UBound(file)
    Workbooks.OpenText Filename:=file(x), DataType:=xlDelimited, Tab:=True, Semicolon:=True, Space:=False, Comma:=False
    Set WB = ActiveWorkbook
    WB.Sheets(1).UsedRange.Copy newWS.Cells(t, 2)
    t = myWB.Sheets(1).Cells(Rows.Count, "B").End(xlUp).Row + 1
    WB.Close False
    Next
    myWB.Sheets(1).Columns(1).Delete
    Application.ScreenUpdating = False
    Rows("1:1").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End Sub

    - Make a new Excel file
    - Open the VBA editor
    - Add a Userform
    - Place 2 text boxes and 1 command button on that form
    - Paste all code below into the code module of the form
    - Download this file:
    https://dl.dropboxusercontent.com/u/35239054/FileSearch.cls
    - In the VBA editor press CTRL-M and import that file
    - Save the Excel file in the directory that contain your text files
    - Run the form
    You can format the columns of the sheet as you like, e.g. column E:H should be a number with 5 decimal places. The top row can contain some headings. My code did not affect the formatting or the headings.
    Andreas.
    Option Explicit
    Private Sub UserForm_Initialize()
    'Just a sample
    Me.TextBox1.Value = FormatDateTime(Now, vbGeneralDate)
    Me.TextBox2.Value = FormatDateTime(Now, vbShortDate)
    End Sub
    Private Sub CommandButton1_Click()
    Dim StartDate As Date, EndDate As Date
    Dim FS As New FileSearch
    Dim R As Range
    Dim ThisFile As Variant
    Dim ThisDate As Date
    Dim Data As Variant
    Dim Count As Long
    'Be sure we have 2 dates
    If Not IsDate(Me.TextBox1.Value) Then
    Me.TextBox1.SetFocus
    MsgBox "No start date"
    Exit Sub
    End If
    If Not IsDate(Me.TextBox2.Value) Then
    Me.TextBox2.SetFocus
    MsgBox "No end date"
    Exit Sub
    End If
    'Convert to real dates
    StartDate = CDate(Me.TextBox1.Value)
    EndDate = CDate(Me.TextBox2.Value)
    'Time part given?
    If Fix(EndDate) = EndDate Then
    'No include all files for this day
    EndDate = EndDate + TimeSerial(23, 59, 59)
    End If
    'Correct order?
    If StartDate > EndDate Then
    ThisDate = EndDate
    EndDate = StartDate
    StartDate = ThisDate
    End If
    With FS
    'Same path as our file
    .LookIn = ThisWorkbook.Path
    .FileName = "*DataLog.txt"
    'Search all files sort by file name
    If .Execute(msoSortByFileName, msoSortOrderAscending) = 0 Then
    MsgBox "No data files found in " & .LookIn
    Exit Sub
    End If
    'Clear previous data
    Set R = Range("A2").CurrentRegion
    If R.Row < 2 Then Set R = R.Offset(1)
    R.ClearContents
    'Show the user that we are working
    Application.Cursor = xlWait
    DoEvents
    For Each ThisFile In .FoundFiles
    'Get the date from the file name
    ThisDate = Filename2Date(ThisFile)
    'Between our dates?
    If (ThisDate >= StartDate) And (ThisDate <= EndDate) Then
    'Import at the end of the data
    Set R = Range("A" & Rows.Count).End(xlUp).Offset(1)
    Data = ReadCSV(ThisFile)
    R.Resize(UBound(Data) + 1, UBound(Data, 2) + 1) = Data
    Count = Count + 1
    End If
    Next
    End With
    'Done
    Application.Cursor = xlDefault
    If Count = 0 Then
    MsgBox "No files match your dates"
    Else
    MsgBox Count & " files imported"
    'Hide the form
    Me.Hide
    End If
    End Sub
    Private Function Filename2Date(ByVal Fullname As String) As Date
    'Convert e.g "C:\20130601142648DataLog.txt" to the date "01.06.2013 14:26:48"
    Dim i As Long, j As Long
    i = InStrRev(Fullname, "\")
    If i > 0 Then Fullname = Mid(Fullname, i + 1)
    Fullname = JustNumbers(Fullname)
    If Len(Fullname) <> 14 Then Exit Function
    Filename2Date = _
    DateSerial(Mid(Fullname, 1, 4), Mid(Fullname, 5, 2), Mid(Fullname, 7, 2)) + _
    TimeSerial(Mid(Fullname, 9, 2), Mid(Fullname, 11, 2), Mid(Fullname, 13, 2))
    End Function
    Private Function JustNumbers(ByVal What As String) As String
    'Return only numbers from What (by Rick Rothstein)
    Dim i As Long, j As Long, Digit As String
    For i = 1 To Len(What)
    Digit = Mid$(What, i, 1)
    If Digit Like "#" Then
    j = j + 1
    Mid$(What, j, 1) = Digit
    End If
    Next
    JustNumbers = Left$(What, j)
    End Function
    Private Function ReadCSV(ByVal Fullname As String) As Variant
    'Read a CSV file into an array
    Const LDelim = vbCrLf 'Line delimiter
    Const FDelim = ";" 'Field delimiter
    Dim hFile As Integer
    Dim Buffer As String
    Dim Lines, Line, Data
    Dim i As Long, j As Long
    'Be sure the file exists
    If Dir(Fullname) = "" Then Exit Function
    'Open and read all data
    hFile = FreeFile
    Open Fullname For Binary Access Read As #hFile
    Buffer = Space(LOF(hFile))
    Get #hFile, , Buffer
    Close #hFile
    'Split into lines
    Lines = Split(Buffer, LDelim)
    'Split the first line and prepare the output
    'Note: I assume that all lines have the same number of fields
    Line = Split(Lines(0), FDelim)
    ReDim Data(0 To UBound(Lines), 0 To UBound(Line))
    For i = 0 To UBound(Lines)
    Line = Split(Lines(i), FDelim)
    For j = 0 To UBound(Line)
    'Parse the fields
    If IsDate(Line(j)) Then
    Data(i, j) = CDate(Line(j))
    ElseIf IsNumeric(Line(j)) Then
    Data(i, j) = CDbl(Line(j))
    Else
    Data(i, j) = Line(j)
    End If
    Next
    Next
    ReadCSV = Data
    End Function

  • Chart in excel sheet

    Hiii,
    I want draw the chart in the excel sheet without using report generation tool kit . i have the sensor data w.r.t. time in the excel sheeet as shown below
    Time
    Temperature
    4/12/2007 1:55 PM
    153
    4/12/2007 1:55 PM
    152
    4/12/2007 1:55 PM
    151
    4/12/2007 1:55 PM
    150
    4/12/2007 1:55 PM
    149
    4/12/2007 1:55 PM
    148
    4/12/2007 1:55 PM
    147
    4/12/2007 1:55 PM
    126
    4/12/2007 1:55 PM
    127
    4/12/2007 1:55 PM
    128
    4/12/2007 1:55 PM
    129
    4/12/2007 1:55 PM
    130
    i have tried some of the example given in the discussion forum but its not giving the right range
    Rgrds
    HKT

    thks to all for the valueable comments
    let me explain my application more, to clear the concept of using excel in this particular application
    I am storing the data(time/temp) in the binary format on the hard disk.
    the excel part comes when user want to have the excel report for its analysis .
    that is user can use the data but soring it in the excel (format i have shown) as well as chart ( for better visualization)
    the first part(insert data into excel sheet)  i have made using activex control but in the scond part( insert chart into excelsheet) when i give the range specifed in the excelsheet it give me the error 3008
    it is better to make chart by using 2D array of string but i am unable to find the result for the same
    VI is attached with this reply
    Attachments:
    Test Vi Chart.vi ‏52 KB

  • Unknown column in the excel sheet created using Export to Excel

    Hi,
    I created an excelsheet for the table data using the below link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/exporting%20context%20data%20into%20excel%20using%20the%20web%20dynpro%
    20Binary%20Cache.pdf
    but problem here is when i open the excel sheet it is having some unknown columns apart from the expected like amount/#agg next to the actual column amount and it is happening only for the cloumns which have some numbers.
    I dont know where these columns are coming from.
    Send me the solution and points will be rewarded for the helpful answers.
    I want to put some name to the excel file instead of using system created file name.for this requirement where do i need to change the code

    Hi,
    You can export to excel even not relating with any libraries
    Follow this way..
    Take one singleDimensional array, arrColNames[], and one Two dimensional array, arrValues[][].
    File f=new File("Sample.xls);
    FileOutputStream fos=new FileOutputStream(f);
    for(int i=0;i<arrColNames.length;i++)
    fos.write(arrLabels<i>.getBytes());
    fos.write("\t".getBytes());
    fos.write("\n".getBytes());
    for(int j=0;j<noOfRows;j++)
    String arr[]=arrValues[j];
    for(int a=0;a<arr.length;a++)
    if(arr[a]!=null)
         fos.write(arr[a].getBytes());
        fos.write("\t".getBytes());
    fos.write("\n".getBytes());
    fos.flush();
    fos.close();
    The exported excelFile will be stored in your server. If you want to open it using FileDownLoad UI Element,
    Create value attributes resource of type Resource, behaviour of type FileDownLoadBehaviour, reso of type String, fileName of type String , Then then append this code
    FileInputStream fis=new FileInputStream(f);
    FileChannel fc=fis.getChannel();
    byte data[]=new byte[(int)fc.size()];
    ByteBuffer bb=ByteBuffer.wrap(data);
    fc.read(bb);
    fis.close();
    IWDCachedWebResource objCachedWebresource=null;
    if(data!=null)
    objCachedWebresource=WDWebResource.getWebResource
    (data,WDWebResourceType.XLS);
    objCachedWebresource.setResourceName(f.getName());
    wdContext.currentContextElement().setFileName(f.getName());
    wdContext.currentContextElement().setResource(objCachedWebresource);
    wdContext.currentContextElement().setReso(objCachedWebresource.getAbsoluteURL());
    wdContext.currentContextElement().setBehaviour(WDFileDownloadBehaviour.ALLOW_SAVE);
    Regards
    LN

  • Simulate "excel sheet" in a BLOCK FORM

    Do you Know if it is possible to simulate an "EXCEL SHeet" in a block form ???
    Thank You !

    I have to ask, since I am looking at grid beans. Does anyone know of a bean implementing a grid that would work with Forms 9i? I had successfully implemented this type of functionality with ocx's in prior version.
    I see how to call methods and set properties of beans in the UI, but what do you do when the methods use objects like a table row (an array of strings) or more complex objects as parameters?
    I located a couple of beans like this implemented in swing, and get them into a bean area on a form canvas. However, in both cases, the bean area cannot be dragged around or resized in forms developer, say, like the progressbar example or indeed other beans I have used. Is there a document describing how a bean has to be designed to be fully operable within the developer environment ?
    Help on any of these questions appreciated.

  • Working with Big Excel Sheet

    Hello All,
    I have a large excel sheet having 50K rows and I am constrained to not use more than 250 MB of Heap space.
    Using Apache poi API the creating new WorkBook Object itself gives MemoryOutOfSpace Error
    Workbook source = WorkbookFactory.create(new FileInputStream(Path));
    Please suggest some solution/work around. I am open to use some other API as well but preference lies for Apache poi.
    Thanks In Anticipation
    Shivam

    This is the sample code that I am running, I am only creating an Workbook object and then traversing the excel. I am getting the java.lang.OutOfMemoryError: Java heap space error
    package excel;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.Row;
    import org.apache.poi.ss.usermodel.Sheet;
    import org.apache.poi.ss.usermodel.Workbook;
    import org.apache.poi.ss.usermodel.WorkbookFactory;
    public class BigFile {
         private static String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
         public static String calcTimeStamp()
              Date date = new Date();
              SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
              return format.format(date.getTime());
         public static void main(String args[])
              String Path = "C:\\EXCEL\\Large.xls";
              long t = System.currentTimeMillis();
              try {
                   Workbook source = WorkbookFactory.create(new FileInputStream(Path));
                   Sheet sheet = source.getSheetAt(0);
                   for (Row row : sheet)
                        for (Cell cell : row)
              }catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              }catch (Exception e)
                   e.printStackTrace();
              }finally {
                   System.out.println("Total Time Taken "
                             + (System.currentTimeMillis() - t)/1000 + " seconds");
                   System.out.println("End Time :" + calcTimeStamp()+" in "+System.getProperty("user.timezone")+" timezone");
    Here is the Stack Trace
    Total Time Taken 10 seconds
    End Time :2011_03_31_09_40_26 in Asia/Calcutta timezone
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
         at java.util.Arrays.copyOf(Unknown Source)
         at java.util.Arrays.copyOf(Unknown Source)
         at java.util.ArrayList.ensureCapacity(Unknown Source)
         at java.util.ArrayList.add(Unknown Source)
         at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:443)
         at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:263)
         at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:188)
         at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:305)
         at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:286)
         at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:60)
         at excel.BigFile.main(BigFile.java:33)

  • On excel sheet upload read the workbook and populate data to sharepoint list

    Requirement in my current project:
    In a document library when I upload an excel sheet, a specific workbook has to be read and the contents have to be uploaded to a sharepoint custom list.
    The approach followed was create an event receiver and register as a feature. Following is the code for event receiver.
    public override void ItemAdded(SPItemEventProperties properties)
                base.ItemAdded(properties);
                var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");          
                SPListItem doc = properties.ListItem;
                doc["Msg"] = "items deleted from req list";
                doc.Update();
                string excelname=doc.File.Name;
                System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "calling read excel");
                string filepath = doc.File.Url.ToString();
                doc["Msg"] = "excel name" + excelname + filepath;
                doc.Update();
                readExcel(excelname,filepath);
            private static SPList getSPList(String SPListGuid)
               // SPSite Site = SPContext.Current.Site;
                SPSite Site = new SPSite("http://omistestsrv:32252/sites/OMD");
                SPWeb web = Site.OpenWeb();
                Guid listid = new Guid(SPListGuid);
                web.AllowUnsafeUpdates = true;
                SPList List = web.Lists[listid];
                return List;
            private void readExcel(string excelname,string filepath)
                try
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                        using (SPSite Site = new SPSite("http://omistestsrv:32252/sites/OMD"))
                            SPWeb web = Site.OpenWeb();
                            string workbookpath = web.Url + "/" + filepath;
                            web.AllowUnsafeUpdates = true;
                            var _excelApp = new Microsoft.Office.Interop.Excel.Application();
                            System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "iside read excel");
        //my code breaks or fails when cursor reaches this statement. I am not able to open the excel sheet, there is no    //problem related to the permission. same code snippet works in a console application. but when tried as an
    event    //handler in sharepoint it breaks. can anyone help me to resolve the problem
                            workBook = _excelApp.Workbooks.Open(workbookpath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing,
    Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing);
                            System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "after excel open");
                                int numSheets = workBook.Sheets.Count;
                                // Iterate through the sheets. They are indexed starting at 1.
                                System.Diagnostics.EventLog.WriteEntry("ExcelUpload", numSheets.ToString());
                                for (int sheetNum = 12; sheetNum < 13; sheetNum++)
                                    System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "inside first for
    loop");
                                    Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Sheets[sheetNum];
                                    Microsoft.Office.Interop.Excel.Range excelRange = sheet.get_Range("A13",
    "P89") as Microsoft.Office.Interop.Excel.Range;
                                    object[,] valueArray = (object[,])excelRange.get_Value(
                                        Microsoft.Office.Interop.Excel.XlRangeValueDataType.xlRangeValueDefault);
                                    var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");
                                    for (int L = 1; L <= excelRange.Rows.Count; L++)
                                        string stringVal = valueArray[L, 1] as string;
                                        if ((valueArray[L, 1] != null) && (!string.IsNullOrEmpty(stringVal)))
                                            System.Diagnostics.EventLog.WriteEntry("ExcelUpload",
    "inside second for loop");
                                            SPListItemCollection
    listItems = list.Items;
                                            SPListItem item = listItems.Add();
                                            item["Product"] = valueArray[L,
    1];
                                            item["App"] = valueArray[L,
    2];
                                            web.AllowUnsafeUpdates
    = true;
                                            item.Update();
                                web.AllowUnsafeUpdates = false;
                                //Or Another Method with valueArray Object like "ProcessObjects(valueArray);"
                                _excelApp.Workbooks.Close();
                    //workBook.Close(false, excelname, null);
                    //Marshal.ReleaseComObject(workBook);
                catch (Exception e)
                    System.Diagnostics.EventLog.WriteEntry("ExcelUpload", e.Message.ToString());
                finally
                    System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "finally block");
    Is this the only approach to meet this requirement or is there any other way to crack it. sharepoint techies please help me.

    as you described the scenario of the event that it should happen when user upload excel to a document library. Event Receiver is your best bet. However if you would have a requirement that users can send excel files any time to a network file location and
    you want to pick it, read it and create list items etc. You would write a sharepoint timer job that would run every 10 minute to check for file and if available on the network drive, perform the operation etc. so that users who send excel file does not need
    to come to the sharepoint etc. You can see that you have Event Receivcer option or Timer job option OR you would write a console application to trigger the code at a scheduled time on sharepoint server etc. so you are using the event receiver in the correct
    scenario.
    Moonis Tahir MVP, MCPD, MCSD.net, MCTS BizTalk 2006/SQL 2005/SharePoint Server 2007 (Dev & Config)

  • Unable to display double values in Excel sheet using JExcel API

    Hi
    I am writing code to generate report in the form of Excel Sheet using JExcel API.
    Everything is going fine but whenever I want to put some double values in a cell it is only showing 2 decimal places. My problem is "I want to show upto five decimal places".
    Any kind of reply might help me lot.
    Thank U.

    If you enable the submit zero option, it still happens? This is a new feature on the display tabl
    #NumericZero Enhancements
    To display a numeric zero in place of an error message, you can enter #NumericZero in any of the three Replacement text fields. When you use the #NumericZero option:
    · Excel formatting for the cell is retained.
    · All calculations with dependency on the cell will compute correctly and will take the value of this cell as zero.
    · This numeric zero is for display only. When you submit, the zero value is NOT submitted back to the data source.
    You cannot set display strings for cells that contain an invalid member or dimension name (metadata error). Metadata errors produce standard descriptive error messages.
    Errors are prioritized in the following order from highest to lowest. The error message for a higher-priority error takes precedence over that for a lower-priority error.
    1. (Highest) Metadata errors
    2. #No access
    3. #Invalid/Meaningless
    4. #No data\Missing

  • How to read the data in excel sheet

    Dear sir,
    How to read the data in excel sheet when i recieve a data serial communication... ie i have store a data in excel such that
    Cell A       Cell B
       A           Apple 
       B           Ball
       C           Cat
       D           Doll
    when i recieve A from serial communication i have to display Apple, and when i recieve B i have to display Ball and so on.. 

    Hi, 
    I would recommend you to have a look at the VI attached. It makes use of a VI named 'Read from Spreadsheet' to read the row and column data from the tab delimited excel file. The read data is then searched for the Alphabet specified and finally returns you the corresponding string. The test file used to validate the operation of the VI is also attached. 
    Trust this would help you solve the issue. 
    Regards, 
    Sagar G Yadav | Application Engineer | National Instruments
    Attachments:
    read_from_excel.vi ‏10 KB
    Book1.txt ‏1 KB

  • In excel sheet tab name is not coming-urgent

    hi all,
    one small rewquirement. if u run this test program it opens a excel sheet which contains signle tab. here tab name is not coming. i dont no hot to display tabname here.anybody can  make the changes and send me the code.
    i am sending my code below.
    thanks,
    maheedhar.t
    REPORT  ytestvij MESSAGE-ID zv.
    TABLES sscrfields.
    TYPE-POOLS: icon.
    TYPES : BEGIN OF zfnames_ds,
            reptext TYPE reptext,
            END OF zfnames_ds.
    TYPE-POOLS ole2 .
    DATA: wa_fntxt TYPE smp_dyntxt.
    DATA : wa_t75_booking TYPE zvt75_booking_h,
            t_t75_booking TYPE STANDARD TABLE OF zvt75_booking_h.
    DATA : wa_fields TYPE dfies,
            t_fields TYPE STANDARD TABLE OF dfies.
    DATA : wa_fnames TYPE zfnames_ds,
            t_fnames TYPE STANDARD TABLE OF zfnames_ds.
    handles for OLE objects
    DATA: h_excel TYPE ole2_object,        " Excel object
          h_mapl TYPE ole2_object,         " list of workbooks
          h_map TYPE ole2_object,          " workbook
          h_zl TYPE ole2_object,           " cell
          h_f TYPE ole2_object.            " font
    DATA  h TYPE i.
    DATA : lin TYPE i.
    data: excel       type ole2_object,
          application type ole2_object,
          books       type ole2_object,
          book        type ole2_object,
          sheet       type ole2_object,
          cell        type ole2_object,
          column      type ole2_object.
    PARAMETERS : p_input TYPE localfile.
    Add button to application toolbar
    SELECTION-SCREEN FUNCTION KEY 1.  "Will have a function code of 'FC01'
    INITIALIZATION.
    Add displayed text string to buttons
      wa_fntxt-icon_id = icon_xls.
      wa_fntxt-icon_text = 'Input File template'.
      wa_fntxt-quickinfo = 'T75 Header Data'.
      sscrfields-functxt_01 = wa_fntxt.
    AT SELECTION-SCREEN.
      IF sscrfields-ucomm = 'FC01'.
    do nothing
        PERFORM open_excel.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_input.
      PERFORM get_filename USING p_input.
    START-OF-SELECTION.
    *set pf-status 'ONE'.
    END-OF-SELECTION.
      WRITE : lin.
    *&      Form  GET_FILENAME
          text
    -->  p1        text
    <--  p2        text
    FORM get_filename USING p_file TYPE rlgrap-filename . "localfile.
      DATA : w_rc TYPE i.
      DATA : wa_file_table TYPE file_table ,
              t_file_table TYPE STANDARD TABLE OF file_table.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
       EXPORTING
         WINDOW_TITLE            =
         DEFAULT_EXTENSION       =
         DEFAULT_FILENAME        =
         FILE_FILTER             =
         INITIAL_DIRECTORY       =
         MULTISELECTION          =
        CHANGING
          file_table              = t_file_table[]
          rc                      = w_rc
         USER_ACTION             =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          OTHERS                  = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      LOOP AT t_file_table INTO wa_file_table.
        p_file = wa_file_table-filename.
      ENDLOOP.
    ENDFORM.                    " GET_FILENAME
    *&      Form  open_excel
          text
    -->  p1        text
    <--  p2        text
    FORM open_excel.
    SELECT * FROM ZVT75_BOOKING_H
              INTO TABLE t_t75_booking
              UP TO 10 ROWS.
    start Excel
      CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
      PERFORM err_hdl.
      SET PROPERTY OF h_excel  'Visible' = 1.
      PERFORM err_hdl.
    get list of workbooks, initially empty
      CALL METHOD OF h_excel 'Workbooks' = h_mapl.
      PERFORM err_hdl.
    add a new workbook
      CALL METHOD OF h_mapl 'Add' = h_map.
      PERFORM err_hdl.
    output column headings to active Excel sheet
      PERFORM fill_cell USING 1 1 1 'Financial year'.
      PERFORM fill_cell USING 1 2 1 'Financial quarter'.
      PERFORM fill_cell USING 1 3 1 'Customer number'.
      PERFORM fill_cell USING 1 4 1 'Booking Year'.
      PERFORM fill_cell USING 1 5 1 'Financial quarter'.
      PERFORM fill_cell USING 1 6 1 'Contract type'.
      PERFORM fill_cell USING 1 7 1 'Sub Contract type'.
      PERFORM fill_cell USING 1 8 1 'Customer purchase order number'.
      PERFORM fill_cell USING 1 9 1 'Booking Amount'.
      PERFORM fill_cell USING 1 10 1 'Currency Key'.
    LOOP AT t_t75_booking into wa_t75_booking.
    copy items to active EXCEL sheet
       H = SY-TABIX + 1.
       PERFORM FILL_CELL USING H 1 0 wa_t75_booking-BOOKYEAR.
       PERFORM FILL_CELL USING H 2 0 wa_t75_booking-BOOKQTR.
       PERFORM FILL_CELL USING H 3 0 wa_t75_booking-.
       PERFORM FILL_CELL USING H 4 0 wa_t75_booking-BOOKYEAR.
       PERFORM FILL_CELL USING H 5 0 wa_t75_booking-BOOKQTR.
    ENDLOOP.
    disconnect from Excel
      FREE OBJECT h_excel.
      PERFORM err_hdl.
    ENDFORM.                    " open_excel
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM err_hdl.
    data test type sy-subrc.
    test = sy-subrc.
      IF test <> 0.
         Message e000(ZV) with 'Error in OLE-Automation:'.
        STOP.
      ENDIF.
    ENDFORM.                    " ERR_HDL
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM fill_cell USING i j bold val.
      CALL METHOD OF h_excel 'Cells' = h_zl EXPORTING #1 = i #2 = j.
      set property of sheet 'Name'  = 'T75'.
      PERFORM err_hdl.
      SET PROPERTY OF h_zl 'Value' = val .
      PERFORM err_hdl.
      GET PROPERTY OF h_zl 'Font' = h_f.
      PERFORM err_hdl.
      SET PROPERTY OF h_f 'Bold' = bold .
      PERFORM err_hdl.
    ENDFORM.

    Hi,
    Look at the below thread, i posted complete code in this one, just copy that Program and past in your SAP and run the Program, it will create 3 sheets with the names also, then look at the Sheet name in the code, you will understand where to add the code
    Re: format an excel
    Regards
    Sudheer

  • Report using excel sheet as data source not working when deployed to production.

    I have a set of SSRS reports that use an excel sheet as a datasource.
    Now when I preview the reports or run them in the Visual Studio IDE on my local machine i.e
    the development machine, the reports run fine & display all correct results.
    However, when we deploy the reports to the Production machine which is on a separate server,
    the following error message is displayed :
    "The current action cannot be completed. The user data source credentials do not meet the requirements to run this report. Either the user data source credentials are not stored in the report server database, or the user data source is configured not to
    require credentials but the unattended execution account is not specified. (rsInvalidDataSourceCredentialSetting)"
    I've copy pasted the connection string used for connecting to the excel file as reference :
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MyFolder\CurrentFile.xlsx;Extended Properties="Excel 12.0;HDR=Yes;";
    The excel file has also been uploaded to the machine housing the reporting server (i.e to C:\MyFolder location)

    Hi Aaakar,
    From the error message, please try to change the setting of Credential type for the data source on report manager as follows:
    Go to the Data Sources properties page.
    For the Connect Using option, select Credentials stored securely in the report server.
    In User Name and Password, type credentials that can be used to access the database. If you are using SQL Server as the data source, the user name must be valid for both logging on to the server and for accessing the database that contains the data for
    the report.
    If the user name and password are credentials for a Windows account, select Use as Windows Credentials.
    If you want the report server to pass the credentials of the user accessing the report to the server hosting the external data source, click Windows Integrated Security. In this case, the user is not prompted to type a user name or password.
    For more details about Configure Data Source Properties, please see:
    http://technet.microsoft.com/en-us/library/ms155882.aspx
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How do I search for a value in an Excel sheet using ActixeX

    I am already accessing my excel sheets however I need to be able to search the sheet for a certain value and return the row/cell location. Is there an activeX control that can do this?

    You will need a reference to the range to search. This can be the entire sheet if you wish. Just wire that to the method node Find. Here you can specify all of the typical search options. Wire your string or number into the What input. For the what to LOOKAT value, use -4163 for Value and -4123 for formulas.
    The reference returned is the range of the found value. You can wire it into the property node Row and Column to get the location.
    Michael Munroe
    www.abcdef.biz
    Michael Munroe, ABCDEF
    Certified LabVIEW Developer, MCP
    Find and fix bad VI Properties with Property Inspector

Maybe you are looking for