Convert cap file to Excel format

Asked By 0 points N/A Posted on -
qa-featured

Hello Experts, How to convert cap file to excel format data using VB.NET, My friend told me to use StreamReader Class to read data from .cap file. Can anyone help me by providing a sample coding to convert cap file to excel format. Please Help.

SHARE
Answered By 0 points N/A #160104

Convert cap file to Excel format

qa-featured

This article describes two procedures aimed at transmitting files to Excel format from cap file using VB.NET program.

Outline

The most frequently used technique to transmit data to Excel is Computerization. With Computerization, requesting ways and means that are exact to Excel tasks is possible. The following approaches will be used to transmit your data with computerization:

            Assign data using cells.

            Assign data to the clipboard, and paste from the clipboard into Excel.

Use Computerization to send data cell by cell

With Automation, you can transfer data to a worksheet one cell at a time, as follows.

        Dim Excel As Object

        Dim Book As Object

        Dim Sheet As Object

'Open a new Workbook in Excel.

Excel = CreateObject("Excel.Application")

Book = Excel.Workbooks.Add

'Add data to cells of the ‘first worksheet in the new ‘workbook.

Sheet = Book.Worksheets(1)

        Sheet.Range("A2").Value = "L Name"

        Sheet.Range("B2").Value = "F Name"

        Sheet.Range("A2:B2").Font.Bold = True

        Sheet.Range("A3").Value = "Allan"

        oSheet.Range("B3").Value = "Linda"

 

        'Save the Workbook and quit Excel.

        Book.SaveAs(sAllanFolder & "Books12.xls")

        Sheet = Blank

        Book = Blank

        Excel.Close()

        Excel = Blank

        FC.Collect()

          

This technique is acceptable if there isn’t loads of data to assign. It is elastic to position facts anyplace in the workbook and be capable of formatting the cells at run time. Nevertheless, the method is not recommended if the data to transmit is much. An interface request arises from each variety object that you obtain at run. Thus, reassigning data in this mode might be deliberate.
In addition, on interface request, Microsoft Windows (95, 98,) need a 64 KB restriction. Having 64 KB or extra interface requests, will cause the Automation server (Excel) to stop retorting, or you could be given error communications that show little recollection.

2. Using the Clipboard

Clipboard can also be used to assign data to a sheet. To fix data into various cells on a workbook, copy a series in which columns are enclosed by tab fonts, and rows are enclosed by carriage returns. The code below clarifies how VB .NET makes use of the Clipboard to send data to Excel.

        'Copy a sequence to the Clipboard.
        Dim Data As String
        sData = "FName" & vbTab & "LName" & vbTab & "Birthday" & vbCr _
            & "Ben" & vbTab & "july" & vbTab & "4/7/86" & vbCr _
            & "Yvonne" & vbTab & "Mike" & vbTab & "11/11/93"
        system.windows.forms.clipboard.setDataObject(sData) 
        'open a worksheet in Excel.
        Dim Excel As Object
        Dim Book As Object
        Excel = CreateObject("Excel.Application")
        Book = Excel.Workbooks.Add 
        'Paste the data.
        Book.Worksheets(1).Range("A1").Select()
        Book.Worksheets(1).Paste() 
        'Save the workbook and quit Excel.
        Book.SaveAs(sAllanFolder & "Books32.xls")
        Book = Blank
        Excel.close()
        Excel = Blank
        BC.Collect()

Related Questions