My goal is to download the excel that I've created
The code so far and works properly :
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)
This save in drive D, how could I save in the Desktop path and auto download the file, thanks
Try this ..
path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
xlWorkSheet.SaveAs(path & "TemplateVendor.xlsx")
about autodownload you can read here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.