以文本方式查看主题
- 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=71251)
|
-- 作者:易服
-- 发布时间:2015/7/8 9:25:00
-- [求助]导出EXCEL出错
导出EXCEL出错:
此主题相关图片如下:出错.jpg
If FileSys.DirectoryExists(ProjectPath & "Reports\\表8.xls") Then \' 目录存在 Else FileSys.CreateDirectory(ProjectPath & "Reports\\表8.xls") \'创建 目录 End If Dim flg As New SaveExcelFlags flg.MergedRanges = True Tables("近成过").SaveExcel(ProjectPath & "Reports\\表8.xls","近成过 ",flg) Dim Result As DialogResult Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(ProjectPath & "Reports\\表8.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous \'边框线型 Rg.Borders.Weight = MSExcel.XlBorderWeight.xlThin \'边框粗细 Rg.Borders.ColorIndex = 1 \'边框颜色 Dim M As MSExcel.Range = Ws.Cells M.EntireColumn.AutoFit \'自动调整列宽 M.EntireRow.AutoFit \'自动调整行高 App.Visible = True Wb.Save App.Quit
|
-- 作者:大红袍
-- 发布时间:2015/7/8 9:28:00
--
你去看看你的任务管理器->进程,是否有excel.exe,全部结束
|
-- 作者:易服
-- 发布时间:2015/7/8 11:00:00
--
进程中没有excel.exe
此主题相关图片如下:进程.jpg
改成绝对路径就可以了
If FileSys.DirectoryExists("D:\\My Documents\\Reports") Then \' 目录存在 Else FileSys.CreateDirectory("D:\\My Documents\\Reports") \'创建 目录 End If Dim flg As New SaveExcelFlags flg.MergedRanges = True Tables("近成过").SaveExcel("D:\\My Documents\\Reports\\表8.xls","近成过 ",flg) Dim Result As DialogResult Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\My Documents\\Reports\\表8.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous \'边框线型 Rg.Borders.Weight = MSExcel.XlBorderWeight.xlThin \'边框粗细 Rg.Borders.ColorIndex = 1 \'边框颜色 Dim M As MSExcel.Range = Ws.Cells M.EntireColumn.AutoFit \'自动调整列宽 M.EntireRow.AutoFit \'自动调整行高 App.Visible = True Wb.Save App.Quit
|
-- 作者:大红袍
-- 发布时间:2015/7/8 11:17:00
--
呃,你的ProjectPath的值根本就不是D:\\My Documents 吧?
msgbox弹出看一下。
|