根据EXCEL文件各数据表结构定义中创建ER图实体对象
2009-06-17 14:33
861 查看
原创: 牛超
2008-06-17
OSAKA
又要整理EXCEL文档了。。。
如题,遍历EXCEL各SHEET(表定义),创建实体对象(框图),设置字体与间距。
脚本如下:
Option Explicit
Private Sub CommandButton1_Click()
createRects
End Sub
Private Sub createRects()
Dim stitle As String
Dim slayout As String
Dim scontent As String
Dim scur As String
Dim sdesc As String
Dim slabel As String
Dim myshape As Shape
Dim ws As Worksheet
Dim irow As Integer
Dim trgws As Excel.Worksheet
Dim cx, cy, rwh, rht, wthlmt, maxht As Single
cx = 10
cy = 50
rwh = 200
rht = 200
wthlmt = 1500
maxht = 0
Set trgws = ThisWorkbook.Worksheets(1)
For Each myshape In trgws.Shapes
If myshape.AutoShapeType = msoShapeRectangle Then
myshape.Delete
End If
Next
For Each ws In ThisWorkbook.Worksheets
If ws.Index > 1 Then
scontent = ""
slabel = ""
slayout = ws.Name
stitle = ws.Cells(1, 1)
For irow = 3 To 200
scur = ws.Cells(irow, 1)
If Len(Trim(scur)) = 0 Then
Exit For
End If
sdesc = ws.Cells(irow, 6)
If InStr(LCase(sdesc), LCase("index:idx01")) Then
scontent = scontent & "・" & scur & Chr(10)
End If
Next
slabel = "【" & stitle & "】" & slayout & Chr(10) & scontent
Set myshape = trgws.Shapes.AddShape(msoShapeRectangle, cx, cy, rwh, rht)
myshape.Select
'With myshape.TextFrame
' .Characters.Text = slabel
' .HorizontalAlignment = xlHAlignLeft
' .VerticalAlignment = xlVAlignCenter
'End With
Selection.Characters.Text = slabel
Selection.Characters.Font.Name = "MS 明朝"
Selection.Characters.Font.Size = 9
Selection.AutoSize = True
If Selection.Height > maxht Then
maxht = Selection.Height
End If
cx = cx + Selection.Width + 20
If cx > wthlmt Then
cx = 10
cy = cy + maxht + 20
End If
End If
Next
End Sub
2008-06-17
OSAKA
又要整理EXCEL文档了。。。
如题,遍历EXCEL各SHEET(表定义),创建实体对象(框图),设置字体与间距。
脚本如下:
Option Explicit
Private Sub CommandButton1_Click()
createRects
End Sub
Private Sub createRects()
Dim stitle As String
Dim slayout As String
Dim scontent As String
Dim scur As String
Dim sdesc As String
Dim slabel As String
Dim myshape As Shape
Dim ws As Worksheet
Dim irow As Integer
Dim trgws As Excel.Worksheet
Dim cx, cy, rwh, rht, wthlmt, maxht As Single
cx = 10
cy = 50
rwh = 200
rht = 200
wthlmt = 1500
maxht = 0
Set trgws = ThisWorkbook.Worksheets(1)
For Each myshape In trgws.Shapes
If myshape.AutoShapeType = msoShapeRectangle Then
myshape.Delete
End If
Next
For Each ws In ThisWorkbook.Worksheets
If ws.Index > 1 Then
scontent = ""
slabel = ""
slayout = ws.Name
stitle = ws.Cells(1, 1)
For irow = 3 To 200
scur = ws.Cells(irow, 1)
If Len(Trim(scur)) = 0 Then
Exit For
End If
sdesc = ws.Cells(irow, 6)
If InStr(LCase(sdesc), LCase("index:idx01")) Then
scontent = scontent & "・" & scur & Chr(10)
End If
Next
slabel = "【" & stitle & "】" & slayout & Chr(10) & scontent
Set myshape = trgws.Shapes.AddShape(msoShapeRectangle, cx, cy, rwh, rht)
myshape.Select
'With myshape.TextFrame
' .Characters.Text = slabel
' .HorizontalAlignment = xlHAlignLeft
' .VerticalAlignment = xlVAlignCenter
'End With
Selection.Characters.Text = slabel
Selection.Characters.Font.Name = "MS 明朝"
Selection.Characters.Font.Size = 9
Selection.AutoSize = True
If Selection.Height > maxht Then
maxht = Selection.Height
End If
cx = cx + Selection.Width + 20
If cx > wthlmt Then
cx = 10
cy = cy + maxht + 20
End If
End If
Next
End Sub
相关文章推荐
- 根据XML配置规则导入Excel数据(二)定义XML规则对象
- 根据数据字典表定义的表结构,生成创建表的SQL语句
- (转载)根据数据字典表定义的表结构,生成创建表的SQL语句
- Oracle数据库创建实体对象,在自命名包中定义函数以及返回实体对象数据
- 【POI】导出excel文件,不生成中间文件,直接将内存中的数据创建对象下载到浏览器
- 根据数据中的表生成实体和mapper接口及映射文件
- C# WPF 进度条,根据读取数据显示进度条进度,根据Excel文件读取数据,进度条样式
- Navicat工具导出Mysql数据表结构到Excel文件中
- 根据类Student的定义,创建五个该类的对象,输出每个学生的信息, 计算并输出这五个学生Java语言成绩的平均值,以及计算并输出他们Java语言成绩的最大值和最小值。
- 创建表空间以及用户,授予权限,查看表空间名称及大小,物理文件的名称及大小,数据库的创建日期和归档方式,数据库的版本,数据库库对象,表空间的使用情况,表空间读写
- 使用Apache POI创建Excel,并从数据库中读取数据写入到Excel文件中
- MySQL innodb引擎下根据.frm和.ibd文件恢复表结构和数据
- 将指定excel文件中的数据转换成datatable对象,供应用程序进一步处理
- 把数据从DataTable导入到Excel文件里并创建表
- poi根据导入的excel数据自动封装成bean对象集合
- JS导出table数据到excel问题-Automation 服务器不能创建对象
- vs212创建mvc3项目,添加ADO.NET实体数据模型时产生 XXXX.Desiger.cs 文件为空
- 数据结构在C语言中头文件与主文件的创建案例
- 定义员工类employee ,员工有姓名,年龄,工号属性, 员工有工作的方法, 键盘录入三组数据, 数据格式(姓名,年龄,工号) 例如:张三,23,9527; 通过数据,创建员工对象, 然后通过对
- 用groovy简化java反射编写一个基于行数据对象的自动生成excel文件对象的工具