Foxtable(狐表)用户栏目专家坐堂 → Foxtable内容显示及Excel报表导出的内容显示问题


  共有3533人关注过本帖树形打印复制链接

主题:Foxtable内容显示及Excel报表导出的内容显示问题

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 9:51:00 [显示全部帖子]

 测试了一下,对于合并单元格的列,无效。

 

 如果要处理,需要用下面代码(你的模板有问题,请把右边多余的列删除)

 


Dim App As New MSExcel.Application
try
    Dim Wb As MSExcel.WorkBook = app.WorkBooks.open("C:\Users\dv rrxaI600 007\Downloads\excel工艺书.xls")
    Dim rg As MSExcel.Range
    Dim Ws = wb.WorkSheets(1)
    Dim tempWs = wb.WorkSheets.Add
    msgbox(ws.UsedRange.columns.count)
    For Each rg In ws.UsedRange
        output.show(Date.now)
        If rg.MergeCells Then
            Dim tempCell As MSExcel.Range
            Dim width As Double = 0
            Dim tempCol
            For Each tempcol In rg.MergeArea.Columns
                width = width + tempcol.ColumnWidth
            Next
            tempWs.Columns(1).WrapText = True
            tempWs.Columns(1).ColumnWidth = width
            tempWs.Columns(1).Font.Size = rg.Font.Size
            tempWs.Cells(1, 1).Value = rg.Value
            tempWs.Cells(1, 1).RowHeight = 0
            tempWs.Cells(1, 1).EntireRow.Activate
            tempWs.Cells(1, 1).EntireRow.AutoFit
            If (rg.RowHeight < tempWs.Cells(1, 1).RowHeight) Then
                Dim tempHeight As Double
                Dim tempCount As Integer
                tempHeight = tempWs.Cells(1, 1).RowHeight
                tempCount = rg.MergeArea.Rows.Count
                For Each addHeightRow As object In rg.MergeArea.Rows
                   
                    If (addHeightRow.RowHeight < tempHeight / tempCount) Then
                        addHeightRow.RowHeight = tempHeight / tempCount
                    End If
                    tempHeight = tempHeight - addHeightRow.RowHeight
                    tempCount = tempCount - 1
                Next
                rg.WrapText = True
            End If
        End If
    Next
    app.DisplayAlerts = False
    tempWs.Delete
    app.visible = True
catch ex As exception
    msgbox(ex.message)
    app.quit
End try


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 10:29:00 [显示全部帖子]

1、模板那里,请把你右边空白的列删除一次;

 

2、该一句代码

 

            tempWs.Columns(1).ColumnWidth = iif(width>10, width-10, width)


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 11:06:00 [显示全部帖子]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:工艺书(配料中心).xls

Dim App As New MSExcel.Application
try
    Dim Wb As MSExcel.WorkBook = app.WorkBooks.open("C:\Users\dv rrxaI600 007\Downloads\excel工艺书3.xls")
    Dim Ws = wb.WorkSheets(1)
    Dim rg As MSExcel.Range = ws.UsedRange
    Dim tempWs = wb.WorkSheets.Add
    Rg.WrapText = True
    Rg.EntireRow.AutoFit  '自动调整行高
    msgbox(ws.UsedRange.columns.count)
    For Each rg In ws.UsedRange
        If rg.MergeCells Then
            Dim tempCell As MSExcel.Range
            Dim width As Double = 0
            Dim tempCol
            For Each tempcol In rg.MergeArea.Columns
                width = width + tempcol.ColumnWidth
            Next
            tempWs.Columns(1).WrapText = True
            tempWs.Columns(1).ColumnWidth = iif(width>10, width-10, width)
            tempWs.Columns(1).Font.Size = rg.Font.Size
            tempWs.Cells(1, 1).Value = rg.Value
            tempWs.Cells(1, 1).RowHeight = 0
            tempWs.Cells(1, 1).EntireRow.Activate
            tempWs.Cells(1, 1).EntireRow.AutoFit
            If (rg.RowHeight < tempWs.Cells(1, 1).RowHeight) Then
                Dim tempHeight As Double
                Dim tempCount As Integer
                tempHeight = tempWs.Cells(1, 1).RowHeight
                tempCount = rg.MergeArea.Rows.Count
                For Each addHeightRow As object In rg.MergeArea.Rows
                   
                    If (addHeightRow.RowHeight < tempHeight / tempCount) Then
                        addHeightRow.RowHeight = tempHeight / tempCount
                    End If
                    tempHeight = tempHeight - addHeightRow.RowHeight
                    tempCount = tempCount - 1
                Next
                rg.WrapText = True
            End If
        End If
    Next
    app.DisplayAlerts = False
    tempWs.Delete
    app.visible = True
catch ex As exception
    msgbox(ex.message)
    app.quit
End try


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 12:01:00 [显示全部帖子]

 自己看11楼,还不能解决上传具体实例。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 14:16:00 [显示全部帖子]

以下是引用xvkewen在2017/7/10 12:28:00的发言:

谢谢老师,换行的问题已经解决了;现在就是导出的速度特别的慢;虽然模版里已经有<end>标识符,可为什么还是慢呢?

 

1、现在弹出的列是多少?255?还是多少?弹出18才是正常的。

 

2、把tempWs.Cells(1, 1)改成 Dim cell = tempWs.Cells(1, 1)

 

Dim App As New MSExcel.Application
try
    Dim Wb As MSExcel.WorkBook = app.WorkBooks.open("C:\Users\dv rrxaI600 007\Downloads\excel工艺书3.xls")
    Dim Ws = wb.WorkSheets(1)
    Dim rg As MSExcel.Range = ws.UsedRange
    Dim tempWs = wb.WorkSheets.Add
    Rg.WrapText = True
    Rg.EntireRow.AutoFit  '自动调整行高
    msgbox(ws.UsedRange.columns.count)
    Dim tempCell As MSExcel.Range = tempWs.Cells(1, 1)
    For Each rg In ws.UsedRange
        If rg.MergeCells Then
           
            Dim width As Double = 0
            Dim tempCol
            For Each tempcol In rg.MergeArea.Columns
                width = width + tempcol.ColumnWidth
            Next
            tempWs.Columns(1).WrapText = True
            tempWs.Columns(1).ColumnWidth = iif(width>10, width-10, width)
            tempWs.Columns(1).Font.Size = rg.Font.Size
            tempcell.Value = rg.Value
            tempcell.RowHeight = 0
            tempcell.EntireRow.Activate
            tempcell.EntireRow.AutoFit
            If (rg.RowHeight < tempcell.RowHeight) Then
                Dim tempHeight As Double
                Dim tempCount As Integer
                tempHeight = tempcell.RowHeight
                tempCount = rg.MergeArea.Rows.Count
                For Each addHeightRow As object In rg.MergeArea.Rows
                   
                    If (addHeightRow.RowHeight < tempHeight / tempCount) Then
                        addHeightRow.RowHeight = tempHeight / tempCount
                    End If
                    tempHeight = tempHeight - addHeightRow.RowHeight
                    tempCount = tempCount - 1
                Next
                rg.WrapText = True
            End If
        End If
    Next
    app.DisplayAlerts = False
    tempWs.Delete
    app.visible = True
catch ex As exception
    msgbox(ex.message)
    app.quit
End try

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 14:55:00 [显示全部帖子]

以下是引用xvkewen在2017/7/10 14:43:00的发言:
弹出的列数还是255

 

你模板设置有问题。替换为11楼的模板。

 

如果还是不行,做个具体的例子发上来测试和优化。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 16:49:00 [显示全部帖子]

 你重新弄模板吧,无法找到你怎么设置的模板出的问题。

 

 我直接拷贝模板粘贴生成一个新的sheet测试没问题。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/10 17:57:00 [显示全部帖子]

这个和你的打印机设置有关。

 

http://jingyan.baidu.com/article/c910274bc7940acd361d2d8f.html

 


 回到顶部