以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- excel的单元格设置成 ”自动换行“为什么报表输出时还显示不全? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=153749) |
||||
-- 作者:guosheng -- 发布时间:2020/8/21 14:06:00 -- excel的单元格设置成 ”自动换行“为什么报表输出时还显示不全? excel的单元格设置成 “自动换行” 为什么报表输出时还显示不全?
命令窗口运行: Dim fl As String Dim Book As New XLS.Book(ProjectPath & "Attachments\\周报样式.xlsx") \'打开模板 fl= ProjectPath & "Reports\\周报样式.pdf" If FileSys.DirectoryExists(ProjectPath & "Reports\\") = False Then FileSys.CreateDirectory(ProjectPath & "Reports\\") End If Book.Build() \'生成报表 Book.SaveToPDF(fl) \'保存为PDF文件 Dim Proc As New Process \'打开PDF文件 Proc.File = fl Proc.Start() [此贴子已经被作者于2020/8/21 14:17:31编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2020/8/21 14:23:00 -- 需要生成报表后再设置换行,如:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=141267&skin=0 |
||||
-- 作者:guosheng -- 发布时间:2020/8/24 8:56:00 -- 命令窗口加了阴影的代码,自动换行还是没有实现啊。看看怎么回事啊。多谢了 Dim fl As String Dim Book As New XLS.Book(ProjectPath & "Attachments\\周报样式.xlsx") \'打开模板 Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim Style As XLS.Style = Book.NewStyle() \'定义新样式 Style.WordWrap = True For n As Integer = 3 To Sheet.Rows.Count -1 Sheet(n,4).Style =Style \'5改为人员列的索引即可 Next fl= ProjectPath & "Reports\\周报样式.pdf" If FileSys.DirectoryExists(ProjectPath & "Reports\\") = False Then FileSys.CreateDirectory(ProjectPath & "Reports\\") End If Book.Build() \'生成报表 Book.SaveToPDF(fl) \'保存为PDF文件 Dim Proc As New Process \'打开PDF文件 Proc.File = fl Proc.Start()
|
||||
-- 作者:有点蓝 -- 发布时间:2020/8/24 9:07:00 -- 生成报表后在设置 …… Book.Build() \'生成报表 Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim Style As XLS.Style = Book.NewStyle() \'定义新样式 Style.WordWrap = True For n As Integer = 3 To Sheet.Rows.Count -1 Sheet(n,4).Style =Style \'5改为人员列的索引即可 Next Book.SaveToPDF(fl) \'保存为PDF文件 ……
[此贴子已经被作者于2020/8/24 9:07:02编辑过]
|
||||
-- 作者:guosheng -- 发布时间:2020/8/24 9:33:00 -- 把样式放到Book.Build() 之后,还是没有实现多行显示啊。看看怎么回事吧 Dim fl As String Dim Book As New XLS.Book(ProjectPath & "Attachments\\周报样式.xlsx") \'打开模板 fl= ProjectPath & "Reports\\周报样式.pdf" If FileSys.DirectoryExists(ProjectPath & "Reports\\") = False Then FileSys.CreateDirectory(ProjectPath & "Reports\\") End If Book.Build() \'生成报表 Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim Style As XLS.Style = Book.NewStyle() \'定义新样式 Style.WordWrap = True For n As Integer = 3 To Sheet.Rows.Count -1 Sheet(n,4).Style =Style \'5改为人员列的索引即可 Next Book.SaveToPDF(fl) \'保存为PDF文件 Dim Proc As New Process \'打开PDF文件 Proc.File = fl Proc.Start()
|
||||
-- 作者:有点蓝 -- 发布时间:2020/8/24 10:15:00 -- 换种方式 Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls") Dim fl As String = ProjectPath & "Reports\\出库单.xls" Dim fl2 As String = ProjectPath & "Reports\\出库单.pdf" Book.Build() \'生成细节区 Book.Save(fl) Dim App As New MSExcel.Application try Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.Columns("F") Rg.WrapText = True Rg.EntireRow.AutoFit \'自动调整行高 wb.Saved = True wb.ExportAsFixedFormat(MSExcel.XlFixedFormatType.xlTypePDF, fl2, MsExcel.XlFixedFormatQuality.xlQualityStandard, True, False, System.Reflection.Missing.Value, System.Reflection.Missing.Value, True, System.Reflection.Missing.Value) app.quit catch app.quit End try |
||||
-- 作者:guosheng -- 发布时间:2020/8/24 11:07:00 -- 改了之后第一次调用,确实单元格多行显示了。但是Book.Save(fl)执行后更改了excel模板的内容(可以到附件文件夹打开看一下该excel模板的内容),下次再调用以下代码就会有问题了。该怎么解决啊? 如果能让打开excel模板后,不保存excel模板内容应该就可以了。 Dim fl As String=ProjectPath & "Attachments\\周报样式.xlsx" Dim fl2 As String=ProjectPath & "Reports\\周报样式.pdf" Dim Book As New XLS.Book(ProjectPath & "Attachments\\周报样式.xlsx") \'打开模板 If FileSys.DirectoryExists(ProjectPath & "Reports\\") = False Then FileSys.CreateDirectory(ProjectPath & "Reports\\") End If Book.Build() \'生成报表 Book.Save(fl) Dim App As New MSExcel.Application try Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.Columns("F") Rg.WrapText = True Rg.EntireRow.AutoFit \'自动调整行高 wb.Saved = True wb.ExportAsFixedFormat(MSExcel.XlFixedFormatType.xlTypePDF, fl2, MsExcel.XlFixedFormatQuality.xlQualityStandard, True, False, System.Reflection.Missing.Value, System.Reflection.Missing.Value, True, System.Reflection.Missing.Value) app.quit catch app.quit End try
[此贴子已经被作者于2020/8/24 11:19:01编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2020/8/24 11:19:00 -- Dim fl As String=ProjectPath & "Reports\\周报样式.xlsx" |