Load XML File into MS OWC spreadsheet?

Gruff
02-11-2008, 06:49 PM
I've been playing around with the MS OWC Spreadsheet control.

1) If I am creating a desktop program that uses the control Do I need Excel on the client workstation for it to work?

2) I see I can export the spreadsheet as XML data however I do not see a method to load the same XML file. What's the process? :)

~T

Flyguy
02-12-2008, 06:33 AM
1. According to the docs you don't need Excel, but only if you have Excel installed the spreadsheet can be interactive.

2. The sample on the MS website uses a ADO recordset to populate all cells one by one: http://support.microsoft.com/kb/235883/
Are you sure about saving to XML?
I only see the .Export method of the Activesheet object, but don't see anything about XML

Gruff
02-12-2008, 12:20 PM
1)I was looking for a way to make an 'Excel Lite' to a install as a substitue for Excel on our server. I would not expect to open or save anything other than xml. Not sure if OWC would open any security holes.

2) Call ctl_XL.Export(.FileName, ssExportActionNone, ssExportXMLSpreadsheet)

I assume the last parameter does what it says and that it saves more than just raw data. The ssExportActionNone relates to exporting to Excel or not.

Basically I just wanted to be able to create grids of data that relate to server maintainance, backup cartridges, Etc... and be able to open and edit them from the server room. :)

~T

Flyguy
02-12-2008, 02:30 PM
2. Now I see, at the office I have a reference to OWC 9 and at home I have OWC 11. Seems that the export got some extra parameters.

I understand the needs and I really would I had some more time to investigate the possibilities of OWC for desktop applications.

Gruff
02-12-2008, 05:54 PM
Found it. The XLMURL property loads the XML file. This makes a nice little Spreadsheet app. I'll look into printing.


'Grid := OWC Spreadsheet control
'CD1 := Common Dialog control

Option Explicit

Private Sub FileMenu_Click(Index As Integer)
Dim sURL As String

'Skip to file SaveAs if a file has not been loaded yet.
If ((Index = 3) And (CD1.FileName = "")) Then Index = 4

Select Case FileMenu(Index).Caption
Case "New"
sURL = VB.App.Path & "\New_WorkBook.xml"
sURL = "file://" & sURL
Grid.XMLURL = sURL
Grid.Refresh
Case "Open"
With CD1
.FileName = ""
.Filter = "*.xml|*.xml"
.FilterIndex = 1
.ShowOpen
If .FileName = "" Then Exit Sub
sURL = "file://" & .FileName
Grid.XMLURL = sURL
Grid.Refresh
Me.Caption = GetFileName(.FileName)
End With
Case "Separator1"
Case "Save"
Call Grid.Export(CD1.FileName, ssExportActionNone, ssExportXMLSpreadsheet)
Case "SaveAs"
With CD1
.Filter = "*.xml|*.xml"
.FilterIndex = 1
.ShowSave
If .FileName = "" Then Exit Sub
Call Grid.Export(.FileName, ssExportActionNone, ssExportXMLSpreadsheet)
End With
Case "Separator2"
Case "Print"
Case "Print Preview"
Case "Separator3"
Case "Exit"
Unload Me
End Select
End Sub

Private Sub Form_Load()
Dim sURL As String
With Grid
''Disallow user resizing of the control
.ActiveWindow.EnableResize = False
' Hide button to export to Excel (On systems where Excel is not installed)
.Toolbar.Buttons("owc1004").Visible = False
sURL = VB.App.Path & "\New_WorkBook.xml"
sURL = "file://" & sURL
.XMLURL = sURL
.Refresh
end with
End Sub

Private Sub Form_Resize()
With Grid
.Left = 0
.Top = 0
.Width = Me.ScaleWidth
.Height = Me.ScaleHeight
End With
End Sub

Private Function GetFileName(ByVal sPath As String) As String
Dim nPos As Integer
nPos = InStrRev(sPath, "\")
If nPos > 0 Then
sPath = Mid$(sPath, nPos + 1)
End If
GetFileName = sPath
End Function

Flyguy
02-13-2008, 01:10 AM
Thanks for sharing Tom.

I have to say to documentation for the controls are OK.
But the names of some of the methods are strange, certainly in case of loading (XMLURL) and saving (Export).

Gruff
02-13-2008, 08:51 AM
Well, Tis a Web control. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum