473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dynamically creating .xls file.


Greetings,

I’ve query some data from the table, how can I push it into an excel file and allow user to save it? anyone done this sort of thing before?

Nov 18 '05 #1
2 4491
Select Case (svlType.ToLower)
Case "txt" : svlType = "text/plain"
Case "htm" : svlType = "text/HTML"
Case "html" : svlType = "text/HTML"
Case "pdf" : svlType = "Application/pdf"
Case "gif" : svlType = "image/GIF"
Case "jpg" : svlType = "image/JPEG"
Case "jpeg" : svlType = "image/JPEG"
Case "png" : svlType = "image/png"
Case "doc" : svlType = "Application/msword" ' (for Microsoft Word files)
Case "xls" : svlType = "Application/x-msexcel" '(for Microsoft Excel files)
End Select

HttpContext.Current.Response.ContentType =svlType
HttpContext.Current.Response.write(YourVariable)

YourVariable is the variable which holds data.

In case while saving if you expect the file to be saved in a filename you specify You can use

HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & myFileName)
In the case with FileName, use it as follows:
HttpContext.Current.Response.ContentType =svlType
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & myFileName)
HttpContext.Current.Response.write(YourVariable)

"Asha" wrote:

Greetings,

I’ve query some data from the table, how can I push it into an excel file and allow user to save it? anyone done this sort of thing before?

Nov 18 '05 #2
if do like this, can the client application open the file correctly. PDF,
gif, jpeg etc. are all not plain text files, word, excel needless to say.

In my opinion, we should try to use COM+ or some other ways to generate xls
file, and send back to client. in this newsgroup, there are a lot of
threads on this topic.
Select Case (svlType.ToLower)
Case "txt" : svlType = "text/plain"
Case "htm" : svlType = "text/HTML"
Case "html" : svlType = "text/HTML"
Case "pdf" : svlType = "Application/pdf"
Case "gif" : svlType = "image/GIF"
Case "jpg" : svlType = "image/JPEG"
Case "jpeg" : svlType = "image/JPEG"
Case "png" : svlType = "image/png"
Case "doc" : svlType = "Application/msword" ' (for Microsoft Word files) Case "xls" : svlType = "Application/x-msexcel" '(for Microsoft Excel files) End Select

HttpContext.Current.Response.ContentType =svlType
HttpContext.Current.Response.write(YourVariable)

YourVariable is the variable which holds data.

In case while saving if you expect the file to be saved in a filename you specify You can use
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & myFileName)

In the case with FileName, use it as follows:
HttpContext.Current.Response.ContentType =svlType
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & myFileName) HttpContext.Current.Response.write(YourVariable)

"Asha" wrote:

Greetings,

I¡¯ve query some data from the table, how can I push it into an excel file and allow user to save it? anyone done this sort of thing before?

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Billy Cormic | last post by:
Hello, I am interested in dynamically creating temp tables using a variable in MS SQL Server 2000. For example: DECLARE @l_personsUID int select @l_personsUID = 9842
0
by: purespam | last post by:
How can I dynamically add file links to a html document? I need to be able to click an image icon and the "Open file" box should pop up where I can select a document from my harddisk. The...
10
by: Ron Vecchi | last post by:
I am creating a custom web control that uses an enum for a property {Remote,InLine}. If the property is set to inline then text is read from the embedded resource and sent to the browser in the...
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
7
by: Selden McCabe | last post by:
I'm using the following code to write some text to a file: objWriter = New StreamWriter(FullPath, True, System.Text.Encoding.ASCII) For nRow = 1 To sData.Length - 1...
2
by: epigram | last post by:
I'm dynamically creating a number of radio buttons on my aspx page based upon data read from a db. Each radio button has autopostback turned on. I'm experiencing two problems. 1) I am reading...
1
by: jonpfl | last post by:
All, I am new to javascript and I am having problems dynamically creating rows and setting attributes. The following works on IE7.x but not IE6.x. Is there another way of creating a checkbox...
0
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes...
8
by: BillE | last post by:
When I create a control dynamically and it grows according to the content, the control Height property still returns the original default control height instead of the height after expanding. ...
2
by: jennise | last post by:
Hello I am using the DoCmd.TransferText to write a macro to import dynamically named file from a filepath. My macro written as follows: Sub TestTransferText() DoCmd.TransferText...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.