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