Results 1 to 4 of 4

Thread: VB.NET & MS SPREADSHEET 10.0 / 11.0 COM COMPONENTS (OWC10.DLL OWC11.DLL)

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    2

    VB.NET & MS SPREADSHEET 10.0 / 11.0 COM COMPONENTS (OWC10.DLL OWC11.DLL)

    Hiya all,

    I'm a very new to VB.Net + need some help.

    I'm writing a program that has a form and an MS Spreadsheet 11.0 activeX component on it (default name is axMicrosoft.Office.Interop.Owx11.AXSpreadsheet).

    I want to be able to import + export data into this sheet.

    So far: -

    1) I can type data into the sheet in RUNTIME.

    2) I can export the data to an Excel file using .Export in RUNTIME.

    3) I can import data from a .CSV file, but only at DESIGN TIME using the "Commands and Options"-->Import-->DATATYPE=CSV URL=FILENAME.


    Can someone please tell me how to: -

    A) Import either a CSV or an Excel file into this component in RUNTIME

    B) Export the sheet to a CSV file rather than an Excel file in RUNTIME


    Cheers all,
    Max

    (vb.net 2003 on XP-Home with Office Pro 2000 & 2003)

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: VB.NET & MS SPREADSHEET 10.0 / 11.0 COM COMPONENTS (OWC10.DLL OWC11.DLL)

    Welcome to the forum.

    It would much easier to use Excel Automation do to what you need.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    2

    Re: VB.NET & MS SPREADSHEET 10.0 / 11.0 COM COMPONENTS (OWC10.DLL OWC11.DLL)

    Quote Originally Posted by Asgorath
    Welcome to the forum.

    It would much easier to use Excel Automation do to what you need.

    Regards
    Jorge
    Hi, can you please explain how!

    I originally wanted to embed an Excel Spread Sheet into my VB.NET app. but could only seem to place the Web objects spread sheet with it's limited capability.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB.NET & MS SPREADSHEET 10.0 / 11.0 COM COMPONENTS (OWC10.DLL OWC11.DLL)

    You can use a DataGrid control to display data and save to a Excel workbook. Here is a simple example of how to automate Excel (Write to workbook).
    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3. 'Add a reference to MS Excel xx.0 Object Library
    4. Imports Microsoft.Office.Interop
    5.  
    6. Public Class Form1
    7.  
    8.     Inherits System.Windows.Forms.Form
    9.  
    10. #Region " Windows Form Designer generated code "
    11.  
    12.     Public Sub New()
    13.         MyBase.New()
    14.  
    15.         'This call is required by the Windows Form Designer.
    16.         InitializeComponent()
    17.  
    18.         'Add any initialization after the InitializeComponent() call
    19.  
    20.     End Sub
    21.  
    22.     'Form overrides dispose to clean up the component list.
    23.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    24.         If disposing Then
    25.             If Not (components Is Nothing) Then
    26.                 components.Dispose()
    27.             End If
    28.         End If
    29.         MyBase.Dispose(disposing)
    30.     End Sub
    31.  
    32.     'Required by the Windows Form Designer
    33.     Private components As System.ComponentModel.IContainer
    34.  
    35.     'NOTE: The following procedure is required by the Windows Form Designer
    36.     'It can be modified using the Windows Form Designer.  
    37.     'Do not modify it using the code editor.
    38.     Friend WithEvents Button1 As System.Windows.Forms.Button
    39.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    40.         Me.Button1 = New System.Windows.Forms.Button
    41.         Me.SuspendLayout()
    42.         '
    43.         'Button1
    44.         '
    45.         Me.Button1.Location = New System.Drawing.Point(192, 88)
    46.         Me.Button1.Name = "Button1"
    47.         Me.Button1.TabIndex = 0
    48.         Me.Button1.Text = "Button1"
    49.         '
    50.         'Form1
    51.         '
    52.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    53.         Me.ClientSize = New System.Drawing.Size(284, 122)
    54.         Me.Controls.Add(Me.Button1)
    55.         Me.Name = "Form1"
    56.         Me.Text = "Form1"
    57.         Me.ResumeLayout(False)
    58.  
    59.     End Sub
    60.  
    61. #End Region
    62.  
    63.     Private moApp As Excel.Application
    64.  
    65.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    66.         moApp = DirectCast(CreateObject("Excel.Application"), Excel.Application)
    67.         moApp.Visible = False
    68.     End Sub
    69.  
    70.     Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    71.         moApp.Quit()
    72.         moApp = Nothing
    73.     End Sub
    74.  
    75.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    76.         Dim oWB As Excel.Workbook = moApp.Workbooks.Add
    77.         Dim oSht As Excel.Worksheet = DirectCast(oWB.Sheets("Sheet1"), Excel.Worksheet)
    78.         oSht.Cells(1, 1) = "RobDog888"
    79.         oWB.Close(True, "C:\Test.xls")
    80.         oSht = Nothing
    81.         oWB = Nothing
    82.     End Sub
    83.  
    84. End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width