OWC (office Web Components)

OWC (office Web Components)

Post by Angel » Fri, 12 Apr 2002 07:02:03



I decided to post this because lots of people mailed me
for it ..
For use owc (xp) in .net environment you have to import
the OWC10.DLL with the
tlbimp.exe, so you'll get the dll
to put in the bin directory (of your application).
Done this the namespace and declarations are (for ex.):



...
Dim chAxisPositionCategory As OWC10.ChartDimensionsEnum
Dim chDimValues As OWC10.ChartDimensionsEnum
Dim chDimCategories As OWC10.ChartDimensionsEnum
Dim chAxisPositionLeft As OWC10.ChartDimensionsEnum
Dim chDataLiteral As OWC10.ChartDimensionsEnum
Dim owc As new OWC10.ChartSpace
Dim owcChart As OWC10.ChChart
Dim owcSeries As OWC10.ChSeries
Dim owcConst
...
owc.clear
owcChart = owc.charts.add
owcConst = owc.constants
owcSeries = owcChart.seriesCollection.add
owc.Border.Color = owcConst.chColorNone
...

 owcSeries.SetData
(OWC10.ChartDimensionsEnum.chDimCategories ,owcConst.chDat
aLiteral, GetChartSafeArray(xValues))
 owcSeries.SetData
(OWC10.ChartDimensionsEnum.chDimValues,
owcConst.chDataLiteral, GetChartSafeArray(yValues))
...

where xValues and yValues are array with datas from what
you want (db, ...) and GetChartSafeArray is a function
called from StimGraph.Helper namespace (done by Brian C
Freeman)
to pass a "safe" array to the object!
compil and put in bin dir with
vbc /target:library helper.vb  /out:helper.dll
the source is:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.IO
Imports System.Text

 Namespace StimGraph

    Public Class Helper  

        Public Shared Function GetChartSafeArray(ByVal a
As Array) As Object

            'an Object containing an Array of Objects
            'VB Array over allocation
            Dim oReplacement As Object
            Dim nLastValue As Double = 0
            Dim nNextValue As Double = 0  

            'Use Zero until the first real value is seen,
then Nothing
            oReplacement = 0

            Dim aChartSafe(a.Length - 1) As Object
            Dim i As Integer
            For i = 0 To aChartSafe.Length - 1
                If i < aChartSafe.Length - 2 Then
                    If i = 0 Then
                        nNextValue = 0
                    Else
                        nNextValue = getSafeNumber(a(i +
1), 0)
                    End If
                End If
                aChartSafe(i) = getSafeNumber(a(i),
(nLastValue + nNextValue) / 2)
                If IsNumeric(a(i)) Then
                    nLastValue = CDbl(a(i))
                End If
            Next
            Return aChartSafe
        End Function

        Private Shared Function getSafeNumber(ByVal a,
ByVal oReplace) As Double
            If a Is Nothing Then
                Return oReplace
            ElseIf IsDBNull(a) Then
                Return oReplace
            ElseIf Not IsNumeric(a) Then
                Return oReplace
            Else
                Return CDbl(a)
            End If
        End Function

        Public Shared Function GetChartSafeArray(ByVal a
As String()) As Object

            'an Object containing an Array of Objects
            'VB Array over allocation
            Dim aChartSafe(a.Length - 1) As Object
            Dim i As Integer
            For i = 0 To aChartSafe.Length - 1
                aChartSafe(i) = a(i)
            Next
            Return aChartSafe
        End Function

    End Class

End Namespace

Hope this helps /// Angelo

 
 
 

1. Office Web Components (OWC) and DefWndProc ?

Hello,

Im trying to embed a Office Web Component 9 spread sheet in my form.  it all
works fine untill i press F2 on a cell to try to edit. as soon as i press F2
i get a "Value null was found where an instance of an object was required".

any clues?

thanks,
JB

and here is the code:
    this.axSpreadsheet1 = new AxOWC.AxSpreadsheet();

((System.ComponentModel.ISupportInitialize)(this.axSpreadsheet1)).BeginInit(
);
    this.axSpreadsheet1.Dock = System.Windows.Forms.DockStyle.Fill;
    this.axSpreadsheet1.Enabled = true;
    this.axSpreadsheet1.Location = new System.Drawing.Point(347, 0);
    this.axSpreadsheet1.Name = "axSpreadsheet1";
    //this.axSpreadsheet1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axSpreadsheet1.Ocx
State")));
    this.axSpreadsheet1.Size = new System.Drawing.Size(501, 776);
    this.axSpreadsheet1.TabIndex = 2;
    this.axSpreadsheet1.Parent = this;// I've tried without this line
without any luck

((System.ComponentModel.ISupportInitialize)(this.axSpreadsheet1)).EndInit();

this is the call stack i get:

system.windows.forms.dll!System.Windows.Forms.NativeWindow::DefWndProc(Syste
m.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0xad bytes

system.windows.forms.dll!System.Windows.Forms.Control::DefWndProc(System.Win
dows.Forms.Message m = {System.Windows.Forms.Message}) + 0x19 bytes

system.windows.forms.dll!System.Windows.Forms.AxHost::WndProc(System.Windows
.Forms.Message m = {System.Windows.Forms.Message}) + 0x113 bytes

system.windows.forms.dll!ControlNativeWindow::OnMessage(System.Windows.Forms
.Message m = {System.Windows.Forms.Message}) + 0x19 bytes

system.windows.forms.dll!ControlNativeWindow::WndProc(System.Windows.Forms.M
essage m = {System.Windows.Forms.Message}) + 0xd2 bytes

system.windows.forms.dll!System.Windows.Forms.NativeWindow::DebuggableCallba
ck(__int32 hWnd = 68052, __int32 msg = 515, __int32 wparam = 1, __int32
lparam = 9306605) + 0x39 bytes

system.windows.forms.dll!System.Windows.Forms.Application::ComponentManagerS
ystem.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoo
p(__int32 dwComponentID = 1, __int32 reason = -1, __int32 pvLoopData = 0) +
0x28a bytes

system.windows.forms.dll!System.Windows.Forms.Application::ThreadContextRunM
essageLoop(__int32 reason = -1, System.Windows.Forms.ApplicationContext
context = {System.Windows.Forms.ApplicationContext}) + 0x1b6 bytes

system.windows.forms.dll!System.Windows.Forms.Application::Run(System.Window
s.Forms.Form mainForm = {PhoenixApp.Form1}) + 0x36 bytes

2. including selected files

3. Office Web Components (OWC) in .net

4. Ameritech DSL questions

5. Office Web Components on a C# web form

6. SelectedIndexChanged

7. URGENT Help : Office XP OWC 10 Chart - Events Not Working

8. "miniBNC to BNC cable for Extreme Graphics bd to Sync on Galileo Breakout

9. URGENT : Office XP OWC 10 Chart - Events Not Working

10. URGENT Help : Office XP OWC 10 Chart - Events Not Working

11. Graphs with Office Web COmponent

12. Office Web Components w/ Windows Forms on Citrix

13. Office XP web components and VB.NET