以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]excel报表无法自动换行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=101137)

--  作者:ajie5211
--  发布时间:2017/5/25 16:45:00
--  [求助]excel报表无法自动换行

Dim Book As New XLS.Book(ProjectPath & "Attachments\\订单计划一览表.xls")
Dim fl As String = ProjectPath & "Reports\\订单计划一览表.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
Dim Style As XLS.Style = Book.NewStyle() \'定义新样式
Style.WordWrap = False
Book.Build() \'生成细节区
For i As Integer = 1 To 20
    sheet.Cols(i).Style = style
Next

Book.Save(fl) \'保存工作簿
Dim Proc As New Process \'打开工作簿
Proc.File = fl
Proc.Start()

 

用上面代码,excel报表无法自动换行。在做excel报表时,如果直接设置自动换行,有时又显示不全,怎么整?


--  作者:有点色
--  发布时间:2017/5/25 17:56:00
--  

Dim Book As New XLS.Book(ProjectPath & "Attachments\\订单计划一览表.xls")
Dim fl As String = ProjectPath & "Reports\\订单计划一览表.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
Book.Build() \'生成细节区

Book.Save(fl) \'保存工作簿


Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.Cells
Rg.WrapText = True
\'Rg.EntireColumn.AutoFit   \'自动调整列宽
Rg.EntireRow.AutoFit  \'自动调整行高
App.Visible = True

[此贴子已经被作者于2017/5/25 18:02:57编辑过]

--  作者:ajie5211
--  发布时间:2017/5/25 18:01:00
--  

Dim Book As New XLS.Book(ProjectPath & "Attachments\\订单计划一览表.xls")
Dim fl As String = ProjectPath & "Reports\\订单计划一览表.xls"
Book.Build() \'生成细节区
Book.Save(fl) \'保存工作簿
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.Cells
Rg.WrapText = True
\'Rg.EntireColumn.AutoFit   \'自动调整列宽
Rg.EntireRow.AutoFit  \'自动调整行高
App.Visible = True

 

刚试出来,版主就回复了,谢谢!