救命啊!! 一个困扰偶的问题

wlhtake 2004-07-15 09:36:34
各位大哥大姐好~ 想问一个问题,在web form中如何才能根据datagrid生成Excel文件? 这个文件是生成在服务器还是客户端?如果在服务器怎么给用户弹出下载窗口?? 谢谢了!!拜托了~~
...全文
129 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wlhtake 2004-07-15
  • 打赏
  • 举报
回复
谢谢 liyiding23(代码人生) !!
能不能给一个Crystal reports的具体在VB.NET web form的使用例子呢?我创建了报表却不知道怎么在web form里面显示,谢谢阿
liyiding23 2004-07-15
  • 打赏
  • 举报
回复
注册号:6707437608 密码:AAP5GKS0000GDE100DS

http://www.chinabyte.net/20030327/1659638.shtml
wlhtake 2004-07-15
  • 打赏
  • 举报
回复
我想问一下VS.NET 2003自带的Crystal reports第一次用的时候提示要输入注册码和密匙?怎么办??哪有啊???
liyiding23 2004-07-15
  • 打赏
  • 举报
回复
很多控件自动能生成EXCEL文件,PDF,HTML很多种类你只要把DATAGRID的东东写入一个DATASET就行了
ACTIVEREPORT
水晶等等
Bob 2004-07-15
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/ForumList_Search.asp?searchtype=2&bigclassid=52&smallclassid=5202&searchKeys=excel&author=&tabletype=now&Submit2=%B6%D4%D1%A1%D4%F1%B5%C4%D0%A1%C0%E0%BD%F8%D0%D0%CB%D1%CB%F7
SeeSunSet 2004-07-15
  • 打赏
  • 举报
回复
先生成EXCEL文件,然后将数据存入,再将该文件 URL给用户不就可以下载了嘛.
miaojx 2004-07-15
  • 打赏
  • 举报
回复
Private Function CreaTable() As DataTable
Dim dt As New DataTable()
dt.Columns.Add("列1", GetType(String))
dt.Columns.Add("列2", GetType(Integer))
dt.Columns.Add("列3", GetType(String))
dt.Columns.Add("列4", GetType(String))
Dim row, row1 As DataRow
row = dt.NewRow()
row!列1 = "行1"
row!列2 = 1
row!列3 = "d"
row!列4 = "a"
dt.Rows.Add(row)
row1 = dt.NewRow()
row1!列1 = "行2"
row1!列2 = 12
row1!列3 = "b"
row1!列4 = "c"
dt.Rows.Add(row1)
Return dt
End Function

'2.将表中的内容导出到Excel

Dim xlApp As New Excel.Application()
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim rowIndex As Integer = 1
Dim colIndex As Integer = 0
xlBook = xlApp.Workbooks().Add
xlSheet = xlBook.Worksheets("sheet1")

Dim Table As New DataTable()
Table = CreaTable()

'将所得到的表的列名,赋值给单元格

Dim Col As DataColumn
Dim Row As DataRow
For Each Col In Table.Columns
colIndex = colIndex + 1
xlApp.Cells(1, colIndex) = Col.ColumnName
Next

'得到的表所有行,赋值给单元格

For Each Row In Table.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each Col In Table.Columns
colIndex = colIndex + 1
xlApp.Cells(rowIndex, colIndex) = Row(Col.ColumnName)
Next
Next

With xlSheet
.Range(.Cells(1, 1), .Cells(1, colIndex)).Font.Name = "黑体"
'设标题为黑体字
.Range(.Cells(1, 1), .Cells(1, colIndex)).Font.Bold = True
'标题字体加粗
.Range(.Cells(1, 1), .Cells(rowIndex, colIndex)).Borders.LineStyle = 1
'设表格边框样式
End With

With xlSheet.PageSetup
.LeftHeader = "" & Chr(10) & "&""楷体_GB2312,常规""&10公司名称:" ' & Gsmc
.CenterHeader = "&""楷体_GB2312,常规""公司人员情况表&""宋体,常规""" & Chr(10) &_
"&""楷体_GB2312,常规""&10日 期:"
.RightHeader = "" & Chr(10) & "&""楷体_GB2312,常规""&10单位:"
.LeftFooter = "&""楷体_GB2312,常规""&10制表人:"
.CenterFooter = "&""楷体_GB2312,常规""&10制表日期:"
.RightFooter = "&""楷体_GB2312,常规""&10第&P页 共&N页"
End With
xlApp.Visible = True

liyiding23 2004-07-15
  • 打赏
  • 举报
回复
用active report吧,这个更好,地址不是发给你了

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧