以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 如何给导出的表格画上边框线 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=63011)
|
-- 作者:lihe60
-- 发布时间:2015/1/12 9:51:00
-- 如何给导出的表格画上边框线
请帖出代码,高版本的我打不开。
|
-- 作者:有点甜
-- 发布时间:2015/1/12 9:58:00
--
参考
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\Report.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4) App.Visible = True
http://www.foxtable.com/help/topics/2121.htm
|
-- 作者:lihe60
-- 发布时间:2015/1/12 9:59:00
--
以下是引用有点甜在2015-1-12 9:58:00的发言:
参考
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\Report.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4) App.Visible = True
http://www.foxtable.com/help/topics/2121.htm
这个代码放进去,老是提示有错误。
|
-- 作者:lihe60
-- 发布时间:2015/1/12 9:59:00
--
这个代码放在什么位置?
|
-- 作者:Bin
-- 发布时间:2015/1/12 10:02:00
--
测试无错误,路径是否有改对? 放到生成文件代码的后面.
|
-- 作者:有点甜
-- 发布时间:2015/1/12 10:03:00
--
以下是引用lihe60在2015-1-12 9:59:00的发言: 这个代码放在什么位置?
路径你要改一下啊
|
-- 作者:lihe60
-- 发布时间:2015/1/12 10:06:00
--
Dim tbl As Table = Tables("表A") Dim hdr As Integer = tbl.HeaderRows \'获得表头的层数 Dim cnt As Integer Dim Book As New XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
tbl.CreateSheetHeader(Sheet) \'生成表头 For c As Integer = 0 To tbl.Cols.Count - 1 If tbl.Cols(c).Visible Then For r As Integer = 0 To tbl.Rows.Count - 1 sheet(r + hdr,cnt).value = tbl(r,c) Next cnt = cnt + 1 End If Next Book.Save("c:\\reports\\test.xls")
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("c:\\reports\\test.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4) App.Visible = True
Dim Proc As New Process Proc.File = "c:\\reports\\test.xls" Proc.Start()
放在这里,提示有错误
|
-- 作者:有点甜
-- 发布时间:2015/1/12 10:08:00
--
画什么线,去看帮助文档
Dim tbl As Table = Tables("表A") Dim hdr As Integer = tbl.HeaderRows \'获得表头的层数 Dim cnt As Integer Dim Book As New XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表
tbl.CreateSheetHeader(Sheet) \'生成表头 For c As Integer = 0 To tbl.Cols.Count - 1 If tbl.Cols(c).Visible Then For r As Integer = 0 To tbl.Rows.Count - 1 sheet(r + hdr,cnt).value = tbl(r,c) Next cnt = cnt + 1 End If Next Book.Save("c:\\reports\\test.xls")
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("c:\\reports\\test.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4) App.Visible = True
|
-- 作者:lihe60
-- 发布时间:2015/1/12 10:31:00
--
碰到新问题
Dim St2 As XLS.Style = Book.NewStyle St2.Format = "yyyy-MM-dd" Sheet.Cols(tbl.Cols("日期").Index).Style = st2
这段代码无效了。
|
-- 作者:有点甜
-- 发布时间:2015/1/12 10:40:00
--
Dim tbl As Table = Tables("表A") Dim hdr As Integer = tbl.HeaderRows \'获得表头的层数 Dim cnt As Integer Dim Book As New XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 Dim St2 As XLS.Style = Book.NewStyle St2.Format = "yyyy-MM-dd"
tbl.CreateSheetHeader(Sheet) \'生成表头 For c As Integer = 0 To tbl.Cols.Count - 1 If tbl.Cols(c).Visible Then For r As Integer = 0 To tbl.Rows.Count - 1 sheet(r + hdr,cnt).value = tbl(r,c) If tbl.Cols(c).Name = "日期" Then sheet(r + hdr,cnt).style = st2 End If Next cnt = cnt + 1 End If Next Book.Save("c:\\reports\\test.xls")
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("c:\\reports\\test.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4) Rg.Borders.ColorIndex = 1 \'边框颜色 App.Visible = True
|