Powerdesigner is imported from Excel to the class diagram

Source: Internet
Author: User
Tags powerdesigner

Recently, when using PD, I encountered a problem, that is, the class field, method, and type in Excel. I want to import it to PD and generate a class diagram directly. There are many ways to generate entity tables on the Internet, so I wrote a class graph generated by myself. The tool in Pd-extension-script, or press SHIFT + Ctrl + X to open the script window and execute the following code.


Option explicit

Dim mdl'
Set MDL = activemodel
If (MDL is nothing) then
Msgbox "there is no active model"
End if

Dim haveexcel
Dim RQ
RQ = vbyes 'msgbox ("is Excel installed on your machine? ", Vbyesno + vbinformation," Confirmation ")
If RQ = vbyes then
Haveexcel = true
'Open & create Excel document
Dim x1'
Set X1 = Createobject ("Excel. application ")
X1.workbooks. Open "C: \ Users \ Lenovo \ Desktop \ new Microsoft Excel worksheet .xlsx" 'specifies the Excel document path
X1.workbooks (1). worksheets ("sheet1"). Activate 'specifies the name of the sheet to be opened.
Else
Haveexcel = false
End if

A X1, MDL

Sub A (x1, MDL)
Dim rwindex
Dim tablename
Dim colname
Dim table
Dim col
Dim count

On Error resume next

Set table = MDL. classes. createnew create a class gallery

 

For rwindex = 1 to 1000
With x1.workbooks (1). worksheets ("sheet1 ")

If rwindex = 1 then
Table. Name =. cells (rwindex, 2) 'specifies the class name
Table. Code =. cells (rwindex, 1) 'specifies the class code name
Else
If. cells (rwindex, 1). value = "" then
Exit
End if

Set Col = table. Attributes. createnew create a column/Field
Col. Name =. cells (rwindex, 2). value' specifies the column name.
Col. Code =. cells (rwindex, 1). value' specifies the column name.
Col. datatype =. cells (rwindex, 3). value' specifies the column data type and other attributes.
End if


End
Next
Count = count + 1
Exit sub
End sub

Powerdesigner is imported from Excel to the class diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.