use data from excel table

234 views
Skip to first unread message

blabla

unread,
Apr 23, 2015, 8:15:09 AM4/23/15
to sparx-enterprise-archite...@googlegroups.com
hello

I'm using EA11. I want to use data from a excel file in a state diagramm.
for example:

time  data
 0      0
 1      2
 2      4
 ..      ..

Can I use this data. For example for a Transistion. [data>=3].

Maybe you can sen a short example. It would be very helpful.
thanks for every help ;)

[original message]

blabla

unread,
Apr 23, 2015, 8:46:19 AM4/23/15
to sparx-enterprise-archite...@googlegroups.com
maybe I can use the excelimporterv3??

[original message]

Bellekens@localhost Geert Bellekens

unread,
Apr 23, 2015, 9:16:07 AM4/23/15
to sparx-enterprise-archite...@googlegroups.com
I'm not sure, I don't really see what the result of the import should be.
If you are importing elements, attributes or glossary items the excel importer can certainly be used.
For any other thing you'll have to write some vba code yourself.

Geert

[original message]

blabla

unread,
Apr 24, 2015, 3:35:21 AM4/24/15
to sparx-enterprise-archite...@googlegroups.com
time and data should be variable.
array would be the best.
I want to import data from a other simulation programm and use the imported data in a state diagramm


[original message]

blabla

unread,
Apr 24, 2015, 4:35:37 AM4/24/15
to sparx-enterprise-archite...@googlegroups.com
I'm trying to use the vba programm to read the inital value, but I don't know  how I can  insert the value.

To read the value of the excel nuts is not  a problem.

only the syntax at the creation and update of the attributs


Code:
'-------------------------------------------------------------
' Author:   Geert Bellekens
' Date:     01/09/2009
' Description: Gets the data from the active excel sheet and
'   creates the classes and attributes defined on there
'-------------------------------------------------------------
Public Sub importFromExcel()
Dim excelConn As New ExcelConnector
Dim eaConn As New EAConnector
Dim excelData As Collection
Dim parentPackage As EA.package
'get the selected package
Set parentPackage = eaConn.getSelectedPackage()
'read the data in the active excel sheet starting from the second row (first row is for the headings
Set excelData = excelConn.getValues(2, 1)
'loop the data
Dim row As Collection
'loop rows
Dim currentClass As EA.element
For Each row In excelData
   Dim elementType As String 'Class or Attribute
   Dim name As String
   Dim stereotype As String
   Dim description As String
   Dim attrType As String
   Dim inital_value As String
   Dim attributeLength As String
   'get the type of element
   elementType = row.Item(1)
   'get the name
   name = row.Item(2)
   'get the stereotype
   If row.Count > 2 Then
       stereotype = row.Item(3)
       If stereotype = "null" Then
           stereotype = ""
       End If
   Else
       stereotype = ""
   End If
   
   
   'get the description
   If row.Count > 3 Then
       description = row.Item(4)
   Else
       description = ""
   End If
   'get the Initial Value
   If row.Count > 6 Then
       inital_value = row.Item(7)
   Else
       inital_value = ""
   End If
   
   
   If eaConn.isValidElementType(elementType) Then
           'create the element
           Set currentClass = eaConn.addOrUpdateElement(parentPackage, elementType, name, stereotype, description)
   ElseIf elementType = "Attribute" Then
       If row.Count > 4 Then
           'get the attribute type
           attrType = row.Item(5)
           If attrType = "null" Then
               attrType = ""
           End If
       Else
           attrType = ""
       End If
       
       Dim currentAttribute As EA.Attribute
       Set currentAttribute = eaConn.addOrUpdateAttribute(currentClass, name, stereotype, inital_value, attrType)
       
       'get the attribute lenght
       If row.Count > 5 Then
           attributeLength = row.Item(6)
           'create or update the length tag
          eaConn.addOrUpdateAttributeTag currentAttribute, "length", attributeLength
       End If
   End If
Next
'refresh the contents of the package so that the changes are seen in EA
eaConn.refreshModelView parentPackage
End Sub

[original message]

Bellekens@localhost Geert Bellekens

unread,
Apr 24, 2015, 5:26:35 AM4/24/15
to sparx-enterprise-archite...@googlegroups.com
I'm sorry, I still have no clue as to what you are trying to achieve :-[

As such I can't really give you any helpful advice.

Geert

[original message]

blabla

unread,
Apr 29, 2015, 9:46:46 AM4/29/15
to sparx-enterprise-archite...@googlegroups.com
http://www11.pic-upload.de/thumb/29.04.15/pldbp7zb7ig.png (http://www.pic-upload.de/view-26870674/erkl--rung.png.html)

I would like to type in the value of the attribute in excel and bring it to Enterprise Architect. You can see this in the picture.
Example:
It is like variable in c of type char with the value 5 and the name variable.
I don'know what I have to write in vba to insert the inital value from excel to EA.

Next challange is to use the attribut in a state diagramm as a transition.

[original message]

Prateek

unread,
May 29, 2015, 4:56:18 AM5/29/15
to sparx-enterprise-archite...@googlegroups.com
Hi All,

I am also facing the same issue. I have about hundreds of attributes in Excel and those attributes have to be added to existing classes in EA.
By CSV import/export I can add tagged values. Is there any way by which I can add/update attributes for existing class.

I do not have an exposure in scripting. Is it possible without scripting? Or if anyone has ever faced the same issue would request to help.

Thanks in advance!!

[original message]

Bellekens@localhost Geert Bellekens

unread,
May 29, 2015, 10:06:30 AM5/29/15
to sparx-enterprise-archite...@googlegroups.com
Hi,

You can use my excel to EA importer (http://bellekens.com/2013/04/30/simple-vba-excel-to-ea-importer-v3/) to import attributes to existing classes.

Geert

[original message]

Prateek

unread,
Jun 3, 2015, 12:16:52 AM6/3/15
to sparx-enterprise-archite...@googlegroups.com
You area saviour Geert!!

Thanks a lot :) :)

[original message]

Prateek

unread,
Jul 3, 2015, 6:35:33 AM7/3/15
to sparx-enterprise-archite...@googlegroups.com
Hi All,

I am using the excel to EA importer. I tried learning VBA for the same and have been able to modify the script to my needs. But I am stuck at one place. I do not know how to modify the Scope for the attribute.
By default the new attributes created by the code are of 'public' scope.
In the function mentioned below I tried to update the scope as highlighted but does not work.

Private Function addOrUpdateAttribute(parentClass As EA.element, name As String, alias As String, description As String, attrType As String) As EA.Attribute
   Dim myAttribute As EA.Attribute
   'try to find existing attribute with the given name
   Set myAttribute = getAttributeByName(parentClass, name)
   If myAttribute Is Nothing Then
       'no existing attribute, create new
       Set myAttribute = parentClass.Attributes.AddNew(name, "Attribute")
   End If
   'set properties
   myAttribute.name = name
   'myAttribute.alias = alias
   myAttribute.Notes = description
   myAttribute.Type = attrType
   myAttribute.Scope= "Private"    'save attribute
   myAttribute.Update
   'refresh attributes collection
   parentClass.Attributes.Refresh
   'return attribute
   Set addOrUpdateAttribute = myAttribute
End Function


Please suggest what code do I write to change the scope of the attribute.

Thank you in advance!!

[original message]

qwerty

unread,
Jul 3, 2015, 10:56:44 AM7/3/15
to sparx-enterprise-archite...@googlegroups.com
Yeah. EA strikes again. Use Visibility instead of Scope.


Quote:
Visibility

Identifies the scope of the attribute - Private, Protected, Public or Package.


Analogously black is white and white is black. And the responsible person got killed on a zebra crossing.

q.

[original message]

Prateek

unread,
Jul 5, 2015, 10:06:27 PM7/5/15
to sparx-enterprise-archite...@googlegroups.com
Thanks a lot!! Its Monday morning and the code is working. Great start for the week. ;D
[original message]

M@localhost Simon M

unread,
Jul 6, 2015, 2:07:08 AM7/6/15
to sparx-enterprise-archite...@googlegroups.com

46405245434E370 wrote:
Yeah. EA strikes again. Use Visibility instead of Scope.

Or you could look beyond EA, to UML itself.


Quote:
visibility : VisibilityKind [0..1] Determines whether and how the NamedElement is visible outside its owning Namespace.


EA's UI does say scope. But from the perspective of most people I know that would be defining attributes/operations of a class, that is a more familiar term.

[original message]

Prateek

unread,
Aug 28, 2015, 7:25:47 AM8/28/15
to sparx-enterprise-archite...@googlegroups.com
Hi All,

I am working on importing attributes and classes from Excel to EA. Geert's EA to Excel importer was pretty helpful. I had modified it a bit to my needs but there is one problem I am facing. The code lets you select only single package. What if I have classes grouped under different packages? I have to run it  multiple times by selecting each package. Is there any function whcih lets you select multiple packages or searches for the class in the entire hierarchy of packages?

Thanks
Prateek

[original message]

qwerty

unread,
Aug 28, 2015, 7:56:59 AM8/28/15
to sparx-enterprise-archite...@googlegroups.com
Searching for a class (by name) is only possible by traversing a package packages and therein the elements. Of course you could SQL search for the name but then you don't know if it's a (grand-) child of your package.

q.

[original message]

Bellekens@localhost Geert Bellekens

unread,
Aug 28, 2015, 8:15:57 AM8/28/15
to sparx-enterprise-archite...@googlegroups.com
If you are sure the class name will be unique within the tree you selected I guess you could change the code to search for classes in the sub-packages as well.

Probably the best approach is to first make a flat list of all packageID's of the selected package and all its subpackages, and then use that list of id's in the where clause of you sql that selects the class.

This way you only have to traverse the model once (traversing the model in code is slow, therefore you must try to avoid it if possible)

Geert

[original message]

Prateek

unread,
Sep 3, 2015, 8:45:29 AM9/3/15
to sparx-enterprise-archite...@googlegroups.com
Thank you Geert and q.

But actually I am not using any dedicated database. I am not very much worried about the run time either. Its just that I do not know how to traverse in the package hierarchy. I have many independent EA models (.EAP files) and I want to use the same code for all these models. I have to sync. all the data in Excel and EA. I want to traverse all the classes and attributes under a root package (which might have varying hierarchy of packages depending on different EAP files)
and check if the class/attribute exists in Excel and then sync the data.
The code works if all the classes are under one package. But When we have a hierarchy of packages existing (and the hierarchy might change with different EAP files) I am finding it difficult to come up with a code.

Any suggestions would be pretty helpful.

Thank you

[original message]

Bellekens@localhost Geert Bellekens

unread,
Sep 3, 2015, 9:25:09 AM9/3/15
to sparx-enterprise-archite...@googlegroups.com
EA always works with a database. If you are using .eap file then you are in fact using Jet databases (MS Access) in disguise.

I still think the approach I mentioned with the packageID's and a query is the easiest and fastest, but I can't write the code for you (unless you pay me to)

Geert

[original message]

qwerty

unread,
Sep 3, 2015, 9:45:47 AM9/3/15
to sparx-enterprise-archite...@googlegroups.com
The fastest/best way I can think of:

- issue a SQLquery with SELECT * FROM t_object WHERE name = '...'
- for each entry get the according element
- traverse the parent packages up to get the path
- element and path can be put into a struct/class forming a result array

q.

[original message]

Prateek

unread,
Sep 3, 2015, 10:17:16 PM9/3/15
to sparx-enterprise-archite...@googlegroups.com
Sure I would use a query.
But could let me know where can I find the commands for connecting with the default jet database(MS Access) so that I can run the query.

Thanks!!

[original message]

KP

unread,
Sep 3, 2015, 10:55:15 PM9/3/15
to sparx-enterprise-archite...@googlegroups.com
Open an .EAP file and you're connected!

Go Edit > Search in Model > Edit Search > SQL Scratch Pad to write SQL queries.

[original message]

Bellekens@localhost Geert Bellekens

unread,
Sep 3, 2015, 11:37:01 PM9/3/15
to sparx-enterprise-archite...@googlegroups.com
And from a programming environment you can use Repository.SQLQuery

Geert

PS. Sometimes looking in the manual will help you faster then asking on the forum.

[original message]

Prateek

unread,
Sep 4, 2015, 4:45:18 AM9/4/15
to sparx-enterprise-archite...@googlegroups.com
But actually I am trying to run the VBA Code (like EAImporter Excel), compare an excel file data with EA. So I guess I will have to establish some connectivity with the EA file database. I am currently using the getSelectedPackage() function as mentioned in your file . But what if I want to search the element in the entire model and then update its attributes. I can do it by searching it in 't_object' table and then firing the 'update' query. The approach Edit > Search in Model > Edit Search > SQL Scratch Pad would only let me search and not update. I want to update element from the backend database. So I thought that similar to what we have like a JDBC connectivity, do we need some conncection string for connecting an VBA (outside Excel file) to the database.?
Maybe a stupid question but I don't know the approach.
Thanks in advance for the help

[original message]

Bellekens@localhost Geert Bellekens

unread,
Sep 4, 2015, 4:56:40 AM9/4/15
to sparx-enterprise-archite...@googlegroups.com

51737364623854737A7A737D737865160 wrote:
And from a programming environment you can use Repository.SQLQuery


I don't know what more to say :-?

Geert

[original message]

qwerty

unread,
Sep 4, 2015, 5:05:56 AM9/4/15
to sparx-enterprise-archite...@googlegroups.com
Sometimes I get the feeling that here are people which want others to write their code.

q.

[original message]
Reply all
Reply to author
Forward
0 new messages