Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Using DOORS with Excel.
Topic Summary: I am able to insert values in excel sheet but has anyone used calling chart through DXL code?
Created On: 8-Jun-2006 07:40
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 8-Jun-2006 07:40
User is offline View Users Profile Print this message


Amit Jagtap

Posts: 7
Joined: 25-Aug-2005

Hi,
 I have been successful in writing in Excel using DXL. I am not able to create a chart with DXL. How to use the Excel Function SetSourceData(). I am attaching the source code along this message in zipped format. Can someone help me please?
Thanks in Advance,
Amit
Report this to a Moderator Report this to a Moderator
 8-Jun-2006 07:44
User is offline View Users Profile Print this message


Amit Jagtap

Posts: 7
Joined: 25-Aug-2005

Sorry wasnt able to attach the source code before so am attaching it in this message.
Report this to a Moderator Report this to a Moderator
 8-Jun-2006 11:32
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Amit,

you can use it like the example in attached code ....

hope that helps you

Greetings
Reik Schröder

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany

Edited: 8-Jun-2006 at 11:32 by Reik Schroeder
Report this to a Moderator Report this to a Moderator
 13-Jun-2006 10:46
User is offline View Users Profile Print this message


Amit Jagtap

Posts: 7
Joined: 25-Aug-2005

I tried that Reik, it is not working.

Here is the problem explained better:


I have 2 pieces of code one in Dot net and other in DXL. fficeffice" />>

The line marked in Red is the problem area in DXL code>

The Part 3 gives the signature of the excel function which needs to be called.>

Part 4 gives the error message I am getting
>

My problem is I am not able to pass correct parameter to the setSourceData function..>

PART 1:>>

Here is a part of dot net code which created Excel chart>>

>

Dim objXL As Object>>

        Dim objBook As Object>>

        Dim objSheet As Object>>

        Dim objChart As Object>>

>

        Dim iRow As Integer>>

        Dim iCol As Integer>>

>

        ' Number of points in each Series>>

        Const cNumCols = 10>>

        'Number of Series>>

        Const cNumRows = 2>>

        'Declare the required size of the dynamic array>>

        Dim aTemp(cNumRows, cNumCols)>>

>

        'Start Excel and create a new workbook>>

        objXL = CreateObject("Excel.application")>>

        objBook = objXL.Workbooks.Add>>

        'Set a reference to Sheet1>>

        objSheet = objBook.Worksheets.Item(1)>>

>

        ' Insert Random data into Cells for the two Series:>>

        Randomize(Now().ToOADate())>>

        For iRow = 1 To cNumRows>>

            For iCol = 1 To cNumCols>>

                aTemp(iRow, iCol) = Int(Rnd() * 50) + 1>>

            Next iCol>>

        Next iRow>>

        objSheet.Range("A1").Resize(cNumRows, cNumCols).Value = aTemp>>

>

        ' Add a chart object to the first worksheet>>

        objChart = objSheet.ChartObjects.Add(50, 40, 300, 200).Chart>>

        objChart.SetSourceData(Source:=objSheet.Range("A1:J2")) '//.Resize(cNumRows, cNumCols))>>

        ' Make Excel Visible:>>

        objXL.Visible = True>>

>

        objXL.UserControl = True>>

>

PART 2>>

 When I try to do the equivalent in DXL,>>

                The code below has a few functions which are written by me and I haven't put it here as it would be too lengthy.>>

OleAutoObj objChartObject>>

OleAutoObj objChart>>

                OleAutoObj objNewChart=null>>

                OleAutoObj objRangeObj  >>

                oleResult( oleGet( objExcelDataExportSheet, "ChartObjects", objChartObject),cExcelChartObject)  // here objExcelDataExportSheet is the excel sheet.>>

                if ( null objChartObject) {    ack "Error while getting the chart object."  }>>

                clear( objArgBlock )>>

put( objArgBlock, 150)>>

put( objArgBlock, 15)>>

put( objArgBlock, 300)>>

put( objArgBlock, 200) >>

oleResult( oleGet( objChartObject, "Add", objArgBlock,objChart),cExcelMethodAdd)>>

  if ( null objChart) {              >>

                                ack "Error while Setting Add Method.">>

  }>>

                string range = "A2:" getExcelColumnAlphaAddressFromInt( 2) ( iRowsCount ) "">>

                objRangeObj = excelGetCellOLE(objExcelDataExportSheet,range)>>

                if(null objRangeObj )>>

                                ack "Excel Chart - Range NULL ">>

 oleMethod (objRangeObj, "Select") >>

 clear( objArgBlock )>>

 put( objArgBlock,objRangeObj)  >>

 oleMethod temp =   oleResult( oleMethod( objChart, "SetSourceData", objArgBlock),cExcelSetSource)>>

                 if ( null objChart) {               >>

                                                ack "Error while Setting Add Method.">>

                 }>>

  >>

PART 3>>

>

  MSDN Home >  MSDN Library >  Office Solutions Development >  Office 2003 >  VBA Language Reference >  >>

>

Report this to a Moderator Report this to a Moderator
 13-Jun-2006 10:50
User is offline View Users Profile Print this message


Amit Jagtap

Posts: 7
Joined: 25-Aug-2005

Sorry I wasnt able to represent Part 3 properly hence i have done it here in this message.

PART 3: From MSDN

SetSourceData Method [Excel 2003 VBA Language Reference]


Sets the source data range for the chart.

expression.SetSourceData(Source, PlotBy)

expression Required. An expression that returns a Chart object.

Source   Required Range. The range that contains the source data.

PlotBy   Optional Variant. Specifies the way the data is to be plotted. Can be either of the following XlRowCol constants: xlColumns or xlRows.

Example
This example sets the source data range for chart one.

Charts(1).SetSourceData Source:=Sheets(1).Range("a1:a10"), _
    PlotBy:=xlColumns
                
 

PART 4:

The error message I get is as follows:

Problem with OLE Argument names.

 

Report this to a Moderator Report this to a Moderator
 13-Jun-2006 11:06
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Amit,

The Source parameter is a named parameter, so you need to use the otehr version of the 'put'. Where you have:

put( objArgBlock, objRangeObj)

I think you need:

put( objArgBlock, "Source", objRangeObj)

That might just do the trick...

Paul.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 14-Jun-2006 11:30
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Amit,

Paul might be right with his idea.
I've used named parameters too

Sorry that my code did not work properly for you. It seems, that have made a mistake on copy and paste it from my Excel include file ... It seems that OleAutoArgs args is declared to late ...

Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.