Opening the formated output in browser
Hi
I am working on ASP.NET.As per my client requirment i need to generate some .csv reports.Right now i am storing entire formated report into stringbuilder then writing this stringbuilder into.csv file and storing the .csv in serverside.Finally opening the stored .csv using javascript.Is there any way opening the report directly from excel without storing in server?
My reports format is complex i can get the data from single table or single data source.So i cant use Response.ContentType = "application/vnd.ms-excel" ect.
My code is like below
Assume Entire my report format in resstr variable.
Dim resstr As New System.Text.StringBuilder(4096)
Dim filename As String
Dim filepath As String = Request.PhysicalApplicationPath()
Dim objDir As New DirectoryInfo(filepath)
Try
If objDir.Exists Then
Else
objDir.Create()
End If
filename = filepath + & "test.csv"
Dim objStreamWriter As StreamWriter
File.Delete(filename)
objStreamWriter = File.AppendText(filename)
objStreamWriter.WriteLine(resstr)
objStreamWriter.Close()
Response.Write("<script language='javascript'> window.open ('http://" + svrname + "/" + webdir + "/test.csv','','') <" & "/" & "script>")
|