以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 逐行添加 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=170255) |
||||
-- 作者:BG小白 -- 发布时间:2021/7/19 3:09:00 -- 逐行添加 wb.AppendHTML("<style>#table2 td{width:100px;word-break: break-all;} #table2 thead{display:none}</style>",True) With wb.AddTable("","Table1") .ColWidth = "100px,100px,100px,100px,100px,100px,100px,100px" \'设置列宽 Dim nms() As String = {"商品代码","颜色","尺码","助记符","大类","售价","横调数","图片"} .Head.AddRow(nms) End With wb.InsertHTML("","<div id=\'div\' style=\'overflow-y:auto;height:500px\'>") With wb.AddTable("","Table2") .Alternate = 2 For Each r As DataRow In dt.DataRows With .Body.AddRow(r("商品代码"),r("颜色"),r("尺码"),r("助记符"),r("大类")) .AddCell(Format(r("售价"),"#0")) .AddCell(Format(r("补货数"),"#0")) Dim s As String = r("图片") .AddCell("<img src = " & s & " style=\'width:100px;height:100px\'></img>") End With Next End With wb.InsertHTML("","</div>") e.WriteString(wb.Build) 因为加入了图片,列就对不上了,列宽都是100px也没有用,该怎么调整呢 [此贴子已经被作者于2021/7/19 3:28:14编辑过]
|
||||
-- 作者:BG小白 -- 发布时间:2021/7/19 4:44:00 -- wb.AppendHTML("<style>.td1 .td1{width: 70px;}</style>",True) With wb.AddTable("","Table1") .ColWidth = "100px,100px,100px,100px,100px,100px,100px,100px" \'设置列宽 Dim nms() As String = {"商品代码","颜色","尺码","助记符","大类","售价","横调数","图片"} .Head.AddRow(nms) End With wb.InsertHTML("","<div id=\'div1\' style=\'overflow-y:auto;height:500px\'>")\'这里为内容表格尺寸 With wb.AddTable("","Table2") .Alternate = 2 For Each r As DataRow In dt.DataRows Dim s1 As String = r("商品代码") Dim s2 As String = r("颜色") Dim s3 As String = r("尺码") Dim s4 As String = r("助记符") Dim s5 As String = r("大类") Dim s6 As String = r("售价") Dim s7 As String = r("补货数") With .Body.AddRow() .AddCell("" & s1 & "","class=""td1""") .AddCell("" & s2 & "","class=""td1""") .AddCell("" & s3 & "","class=""td1""") .AddCell("" & s4 & "","class=""td1""") .AddCell("" & s5 & "","class=""td1""") .AddCell("" & s6 & "","class=""td1""") .AddCell("" & s7 & "","class=""td1""") Dim s As String = r("图片") .AddCell("<img src = " & s & " style=\'width:100px;height:100px\'></img>") End With Next End With wb.InsertHTML("","</div>") 这样也是不对,也是大小不一
[此贴子已经被作者于2021/7/19 4:59:00编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2021/7/19 9:15:00 -- 1楼代码我测试没有问题,请上传实例说明。 另外学会使用浏览器的开发者工具,查看哪里的样式有问题
|
||||
-- 作者:BG小白 -- 发布时间:2021/7/19 14:58:00 -- 此主题相关图片如下:5142.png
会错位 |
||||
-- 作者:有点蓝 -- 发布时间:2021/7/19 15:06:00 -- 指定列宽
|
||||
-- 作者:BG小白 -- 发布时间:2021/7/19 17:19:00 -- wb.AppendHTML("<style>#table2 td{width:100px;word-break: break-all;} #table2 thead{display:none}</style>",True) With wb.AddTable("","Table1") .ColWidth = "100px,100px,100px,100px,100px,100px,100px,100px" \'设置列宽 Dim nms() As String = {"商品代码","颜色","尺码","助记符","大类","售价","横调数","图片"} .Head.AddRow(nms) End With wb.InsertHTML("","<div id=\'div\' style=\'overflow-y:auto;height:500px\'>") With wb.AddTable("","Table2") .Alternate = 2 For Each r As DataRow In dt.DataRows With .Body.AddRow(r("商品代码"),r("颜色"),r("尺码"),r("助记符"),r("大类")) .AddCell(Format(r("售价"),"#0")) .AddCell(Format(r("补货数"),"#0")) Dim s As String = r("图片") .AddCell("<img src = " & s & " style=\'width:100px;height:100px\'></img>") End With Next End With wb.InsertHTML("","</div>") e.WriteString(wb.Build) 这里不是已经限定了吗?
|
||||
-- 作者:BG小白 -- 发布时间:2021/7/19 17:20:00 -- 而且我加上了设置列宽也是没有用 |
||||
-- 作者:有点蓝 -- 发布时间:2021/7/19 17:21:00 -- 按5楼的方式使用 |
||||
-- 作者:BG小白 -- 发布时间:2021/7/19 17:29:00 -- 此主题相关图片如下:2736.png 是的,按照5楼的来,手机上也是显示不对称
|
||||
-- 作者:有点蓝 -- 发布时间:2021/7/20 8:57:00 -- 换种方式做固定标题,把飞机css文件复制到web根目录:
代码改改 …… Dim dt As DataTable = cmd1.ExecuteReader wb.AppendHTML("<link rel=\'stylesheet\' href=\'./css.css\'/>",True) wb.InsertHTML("","<div id=\'divcontainer\'>") With wb.AddTable("","Table2") Dim nms() As String = {"商品代码","颜色","尺码","助记符","大类","售价","横调数","图片"} .Head.AddRow(nms) .Alternate = 2 For Each r As DataRow In dt.DataRows With .Body.AddRow(r("商品代码"),r("颜色"),r("尺码"),r("助记符"),r("大类")) .AddCell(Format(r("售价"),"#0")) .AddCell(Format(r("补货数"),"#0")) Dim s As String = r("图片") .AddCell("<img src = " & s & " style=\'width:100px;height:100px\'></img>") End With Next End With wb.InsertHTML("","</div>") e.WriteString(wb.Build) …… |