i use closedxml in asp.net project to generate file excel, and now i want to save my excel file to my local pc but it now work. [i already tried from my local browser and it saved to my server folder]. i really need your guide. thanks.
and here is my code :
Dim wb As XLWorkbook = New XLWorkbook
wb.Worksheets.Add(datatable01, "sheetdata")
wb.SaveAs("d:\myfolder\filereport.xlsx")
it's saved in "d:\myfolder\filereport.xlsx" in server side. i need it to my local pc, and if it possible i can choose file folder to save my file in my local pc folder (as file save dialog).
i already changed my code and it work, strPath using Server.MapPath also
' save ke server
Dim wb As XLWorkbook = New XLWorkbook
wb.Worksheets.Add(datatable01, "sheetdata")
wb.SaveAs(strPath)
' save ke local folder
Dim response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
response.ClearContent()
response.Clear()
response.ContentType = "text/plain"
response.AddHeader("Content-Disposition", "attachment; filename=" & rptName & ".xlsx" + ";")
response.TransmitFile(strPath)
response.Flush()
response.End()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With