Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
报告Office2010下导出Excel出错,Office2007下正常
If FileSys.DirectoryExists( "D:\My Documents\Reports") Then '是否存在目录
Else
FileSys.CreateDirectory("D:\My Documents\Reports") '创建目录
End If
Tables("交叉统计").SaveExcel("D:\My Documents\Reports\数据分析.xls","交叉统计")
Dim flg As New SaveExcelFlags
flg.MergedRanges = True
CurrentTable.SaveExcel("D:\My Documents\Reports\数据分析.xls","交叉统计",flg)
Dim Result As DialogResult
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\My Documents\Reports\数据分析.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
此主题相关图片如下:2011-3-5 9-25-05.png
另发现返回系统菜单( CTRL + SHIFT + F12 ): ” SHIFT + 退格键 +F12 ” 也可以。
根据错误提示,是打开出错,不是导出出错的,错误应该在这一段代码:
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\My Documents\Reports\数据分析.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
整段代码我测试了没有问题,看看是不是哪个文件被写保护了
整段代码我测试了没有问题,看看是不是哪个文件被写保护了
Office2010下出错,大概是保护级别太高造成的。Office2007下正常