如何在asp.net中将报表输出到excel中(不用客户端代码, 不使用控件传递?
以前我问过,请“浪人“再帮一次忙。
请大家多帮忙
以前我问过,请“浪人“再帮一次忙。
请大家多帮忙
解决方案 »
- asp.net结合aspnetpager使用SQL2005的存储过程分页的问题
- 在本地运行正常。在服务器上运行就报错求解决
- 从数据库生成静态页面
- GetResponseStream()获取部分流问题
- 我想down 微软的技术讲义,没有“卡号”和“姓名”,谁有?
- 提供一个常用类:用QQWry.Dat作数据源实现IP地址检索[C#源码]
- 收集方法:做一个收缩式菜单控件
- asp.net+ajax+access做的web中国象棋
- `×××怎样验证一个文本宽是否输入了汉字×××
- 如何将excel文件资料导入数据库
- C#代码中如何写防SQL注入的方法?用parameter也无法过滤"<",">",这种脚本语言的符号,还是会出错
- 关于斑竹webdiyer的分页控件的问题
Dim missing As Object = System.Reflection.Missing.Value
Dim strCurrentDir As String = Server.MapPath(".") + "\"
Dim strFile As String = "割当エラー" + System.DateTime.Now.Ticks.ToString() + ".xls"
Dim AppFoldPath As String = strCurrentDir & "割当エラー"
Dim oXL As Excel.Application
Dim oWB As Excel._Workbook
Dim oSheet As Excel._Worksheet
Dim oRng As Excel.Range
Dim Rows As Integer
Dim Cols As Integer
Dim i As Integer
Try
'//////'ExcelApplicationを形成する(必要だサーバー最高の権限Web.Config--->
'//////<identity impersonate="true" userName="adminuser" password="adminpass"/>
System.GC.Collect()
oXL = New Excel.Application
oXL.Visible = False
oWB = CType((oXL.Workbooks.Add(missing.Value)), Excel._Workbook)
oSheet = CType(oWB.ActiveSheet, Excel._Worksheet)
oSheet.Activate()
oSheet.Range("A1").Value = "記入日"
oSheet.Range("B1").Value = "郵便番号"
oSheet.Range("C1").Value = "県名"
oSheet.Range("D1").Value = "地区名"
oSheet.Range("E1").Value = "媒体名"
oSheet.Range("F1").Value = "受付番号"
oSheet.Range("G1").Value = "サービス"
For Rows = 0 To Cart.Rows.Count - 1
oSheet.Range("A" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(0))
oSheet.Range("B" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(1))
oSheet.Range("C" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(2))
oSheet.Range("D" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(3))
oSheet.Range("E" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(4))
oSheet.Range("F" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(5))
oSheet.Range("E" & (i + 2)).Value = NulltoStr(Cart.Rows(Rows).Item(6))
i = i + 1
Next
MakeAngelDir(AppFoldPath)
oWB.SaveAs(strCurrentDir + "割当エラー\" & strFile, Excel.XlFileFormat.xlWorkbookNormal, Nothing, Nothing, False, False, Excel.XlSaveAsAccessMode.xlShared, False, False, Nothing, Nothing)
Dim AppPath As String = strCurrentDir + "割当エラー\" & strFile
oXL.UserControl = False
oXL.Visible = False
oWB.Close()
oXL.Workbooks.Close()
oXL.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRng)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL)
oSheet = Nothing
oWB = Nothing
oXL = Nothing
System.GC.Collect()
Catch theException As Exception
Response.Write(theException.Message)
Response.End()
Dim errorMessage As String
errorMessage = "Error: "
errorMessage = String.Concat(errorMessage, theException.Message)
errorMessage = String.Concat(errorMessage, " Line: ")
errorMessage = String.Concat(errorMessage, theException.Source)
Page.RegisterStartupScript("focus", "<script language=javascript>alert(""" & errorMessage & """)</script>")
End Try
End Sub
提示“ ASP.NET访问未授权的资源。
请问如何解决。
该方法在服务端是否需要安装office