Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:Excel 报表的日期格式化代码问题

1楼
mr725 发表于:2009/8/29 23:21:00

当报表模板中的日期列没有设置日期格式的时候:这段格式化日期的代码怎么不起作用???

Dim Book1 As New XLS.Book(ProjectPath & "Attachments\订单.xls")
Dim Sheet As XLS.Sheet = Book1.Sheets(0)

Dim St2 As XLS.Style = Book1.NewStyle()      ‘这段格式化日期的代码怎么不起作用???
St2.Format = "yyyy-MM-dd"
Sheet.Cols(tables("订单").Cols("日期").index).Style = st2


Book1.Build() '生成细节区
Book1.Save(ProjectPath & "reports\订单.xls")
Dim Proc As New Process '打开工作簿
Proc.File = ProjectPath & "reports\订单.xls" 
Proc.Start()

2楼
yangming 发表于:2009/8/30 9:14:00
Dim Book1 As New XLS.Book(ProjectPath & "Attachments\订单.xls")
Dim Sheet As XLS.Sheet = Book1.Sheets(0)
Dim St2 As XLS.Style = Book1.NewStyle()
St2.BorderTop = XLS.LineStyleEnum.Thin
St2.BorderBottom = XLS.LineStyleEnum.Thin
St2.BorderLeft = XLS.LineStyleEnum.Thin
St2.BorderRight = XLS.LineStyleEnum.Thin
St2.Format = "yyyy-MM-dd"
For r As Integer = 2 to 3
    Sheet(r,tables("订单").cols.Count).Style = St2
 Next
Book1.Build() '生成细节区
Book1.Save(ProjectPath & "reports\订单.xls")
Dim Proc As New Process '打开工作簿
Proc.File = ProjectPath & "reports\订单.xls" 
Proc.Start()
3楼
yangming 发表于:2009/8/30 9:28:00

这样也行

Dim Book1 As New XLS.Book(ProjectPath & "Attachments\订单.xls")
Dim Sheet As XLS.Sheet = Book1.Sheets(0)

Dim St2 As XLS.Style = Book1.NewStyle()      '这段格式化日期的代码怎么不起作用???
St2.BorderTop = XLS.LineStyleEnum.Thin
St2.BorderBottom = XLS.LineStyleEnum.Thin
St2.BorderLeft = XLS.LineStyleEnum.Thin
St2.BorderRight = XLS.LineStyleEnum.Thin
St2.Format = "yyyy-MM-dd"
Sheet(3,tables("订单").cols.Count).Style = St2
Book1.Build() '生成细节区
Book1.Save(ProjectPath & "reports\订单.xls")
Dim Proc As New Process '打开工作簿
Proc.File = ProjectPath & "reports\订单.xls" 
Proc.Start()

4楼
mr725 发表于:2009/8/30 10:51:00
谢谢yang版~~~

原来
Sheet.Cols(tables("订单").Cols("日期").index).Style = st2      改为:
Sheet(3,tables("订单").cols.Count).Style = St2                    就可以了。   呵呵~
5楼
yangming 发表于:2009/8/30 11:40:00
以下是引用mr725在2009-8-30 10:51:00的发言:
谢谢yang版~~~

原来
Sheet.Cols(tables("订单").Cols("日期").index).Style = st2      改为:
Sheet(3,tables("订单").cols.Count).Style = St2                    就可以了。   呵呵~

光这样改还不够,新的样式会删除原有的样式,所以还得重新设置边框

共5 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03906 s, 2 queries.