模板中明细区设置了自动换行。
Dim dyj As String = GetConfigValue("_zlddyj",DefaultPrinter)
Dim Book As New XLS.Book(ProjectPath & "Attachments\订单计划一览表.xls")
Dim Sheet As XLS.Sheet
Dim fl As String = ProjectPath & "Reports\订单计划一览表.xls"
Book.Build() '生成细节区
Sheet = Book.Sheets(0)
Sheet(2,0).Value = e.Form.Controls("日期周对应").text
Sheet(2,4).Value = e.Form.Controls("组别").text & " 人数:" & e.Form.Controls("人数").text & " 加班日" & _
"产能:" & e.Form.Controls("加班日产能").text & " 不加班日产能:" & e.Form.Controls("不加班日产能").text & " 日" & _
"总线:" & e.Form.Controls("日总线").text
'With Sheet.PrintSetting
'.Footer = "&C第&P页,总&N页 &R制表:黄细兵 审核:"
'.PaperKind = 9 '设为A4纸
'.LandScape = True '横向打印
'.MarginLeft = 10 '左右边距设为20毫米
'.MarginRight = 10
'.MarginTop = 10 '上下边距设为15毫米
'.MarginBottom = 15
'.AutoScale = False
'End With
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 '自动调整行高
With Ws.PageSetup
.PrintTitleRows = Ws.Rows("2:4").Address '打印行标题(在每一页的顶部重复出现)
'设置页面
.PaperSize = MSExcel.XlPaperSize.xlPaperA4 '纸张大小
.LeftMargin = 10 '页面左边距
.RightMargin = 10 '页面右边距
.TopMargin = 20 '页面顶部边距
.BottomMargin = 20 '页面底部边距
.FooterMargin = 5 '页脚到页面底端的距离
.CenterHorizontally = True '页面水平居中
'设置页脚
.CenterFooter = "第 &P 页 共 &N 页" '中页脚为空
.RightFooter = "制表:黄细兵 审核:_______" '右页脚
'打印模式
.Orientation = MSExcel.xlPageOrientation.xlLandscape '横向打印
'缩放打印
.Zoom = 102 '以下设置将缩印在一页内
End With
Dim pntn As String = GetConfigValue("_zlddyj",DefaultPrinter)
'Wb.PrintOut(Copies:=4,ActivePrinter:=pntn)
App.Visible = True
Wb.Save
Wb.PrintPreview
Wb.Close
App.Quit
'Dim Proc As New Process '打开工作簿
'Proc.File = fl
'Proc.Verb = "Print" '指定动作
'Proc.Start()