以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=145245) |
-- 作者:lxmoffice -- 发布时间:2020/1/13 17:22:00 -- [求助] 老师, 您好! 麻烦你帮忙看下以下代码问题出在哪?点击打印时总是报错: 提示表格已打开, 请先关闭之! Select Case MainTable.name Case "订单要求" Dim Tablename As String Dim Filename As String Tablename= CurrentTable.name Filename=Tablename & "." & "xlsx" Dim Book As New XLS.Book(ProjectPath & "Attachments\\"& Filename &"") Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 Dim fl As String = ProjectPath & "Reports\\"& Filename &"" 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 = Wb.UsedRange rg.Formula = rg.Formula Rg.WrapText = True Rg.EntireColumn.AutoFit \'自动调整列宽 Rg.EntireRow.AutoFit \'自动调整行高 app.visible = True End Select |
-- 作者:有点蓝 -- 发布时间:2020/1/13 17:27:00 -- 提示很明显啦。之前生成的报表文件已经处于打开状态,要先关闭之前的报表文件,不然新生成的就无法覆盖保存 |