Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 下载Excel文件ASP VB.Net_Asp.net_Vb.net_Excel - Fatal编程技术网

Asp.net 下载Excel文件ASP VB.Net

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

我的目标是下载我创建的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.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的示例,这样它就可以弹出吗?