Asp.net 下载Excel文件ASP VB.Net
我的目标是下载我创建的excel 到目前为止,该代码运行正常:Asp.net 下载Excel文件ASP VB.Net,asp.net,vb.net,excel,Asp.net,Vb.net,Excel,我的目标是下载我创建的excel 到目前为止,该代码运行正常: Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Dim misValue As Object = System.Reflection.Missing.Value xlApp = New Excel.Application
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)
xlWorkSheet.Cells(1, 1) = "RECORD_STATUS"
xlWorkSheet.Cells(1, 2) = "VENDOR_NO"
xlWorkSheet.Cells(1, 3) = "PARTS_NO"
xlWorkSheet.Cells(1, 4) = "EFECTIVE_DATE"
xlWorkSheet.Cells(1, 5) = "CURRENCY_CODE"
xlWorkSheet.Cells(1, 6) = "PRICE"
xlWorkSheet.Cells(2, 1) = "A"
xlWorkSheet.Cells(2, 2) = "NSEA"
xlWorkSheet.Cells(2, 3) = "13231JX02A"
xlWorkSheet.Cells(2, 4) = "2013/03/03"
xlWorkSheet.Cells(2, 5) = "IDR"
xlWorkSheet.Cells(2, 6) = "10"
xlWorkSheet.SaveAs("D:\TemplateVendor.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
如果将此文件保存在驱动器D中,我如何将其保存在桌面路径中并自动下载该文件,谢谢
path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
xlWorkSheet.SaveAs(path & "TemplateVendor.xlsx")
关于自动下载,您可以阅读我一定有点困惑,因为您的最终目标是什么?您创建了一个excel文件,然后将其保存到驱动器:D。但是您想将其保存到桌面并自动下载该文件吗?在我看来,只要在你的服务器上为任何人提供文件,让他们从你那里下载,然后他们就会选择它去哪里…?你能提供excel的示例,这样它就可以弹出吗?