如何用powerdesigner 将表结构导出到Excel?

默认分类 未结 1 1456
__yin为有你
__yin为有你 2023-03-21 21:41
1条回答
  • 2023-03-21 22:14

    1. 编写测试excel文件2. 打开pd脚本编辑器PD菜单栏中,依次点击“Tools ->Excute Commands->Edit/Run Script..”3. 编写脚本' Open & Create Excel Document Dim x1 'Set x1 = CreateObject("Excel.Application") x1.Workbooks.Open "D:/荷露叮咚.xlsx" x1.Workbooks(1).Worksheets("Sheet1").Activate ElseHaveExcel = False End Ifa x1, mdlsub a(x1, mdl) dim rwIndex dim tableName dim colname dim table dim col dim count'on error Resume Next For rwIndex = 1 To 4 step 1With x1.Workbooks(1).Worksheets("Sheet1")'MsgBox "生成数据表结构共计1 ="+CStr(.Cells(2,2).Value ), vbOK + vbInformation, "表" If .Cells(rwIndex, 1).Value = "" Then Exit For End IfIf .Cells(rwIndex, 3).Value = "" Then set table = mdl.Tables.CreateNew table.Name = .Cells(rwIndex , 1).Value table.Code = .Cells(rwIndex , 2).Value count = count + 1 ElsecolName = .Cells(rwIndex, 1).Value set col = table.Columns.CreateNew'MsgBox .Cells(rwIndex, 1).Value, vbOK + vbInformation, "列" col.Name = .Cells(rwIndex, 1).Value'MsgBox col.Name, vbOK + vbInformation, "列" col.Code = .Cells(rwIndex, 2).Valuecol.Comment = .Cells(rwIndex,1).Value col.DataType = .Cells(rwIndex, 3).Value4. 测试第一步:把excel模板文件(例如荷露叮咚.xlsx)拷贝到 D盘根目录下(这里的路径需与脚本中标红的地方匹配。) 第二步:运行脚本第三步:检查导入效果

    Response.Buffer = true; Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.AppendHeader("content-disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(DateTime.Now.ToString("yyyy-MM-dd"), System.Text.Encoding.UTF8) + ".xls\""); Response.ContentType = "application/ms-excel"; this.EnableViewState = false; StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); GridView1.AllowPaging = false; BindData(); GridView1.RenderControl(hw); Response.Write(tw.ToString()); Response.End(); GridView1.AllowPaging = true; BindData();

    0 讨论(0)
提交回复