473,386 Members | 1,801 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,386 software developers and data experts.

Asp.Net : html to excel problem


Am creating a HTML Report in asp.net. To save this report to excel on
client-side, i write this code:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

But once the report is saved in excel, on click of hyperlink for second html
report, i dont get the second report. the same old first html report is
displayed.

Please can anyone help me. Am frustrated with this! Is it a problem of data
being cached? PLease help. Its very urgent!!!

Regards,
Spacy


Jul 21 '05 #1
3 3814
Hi Spacy!

You should check the execution path of your program to find out what happens
at the second postback. All the data you write to the response stream after
the;

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

....lines are streamed to that excel file. That is the key to get the correct
output.

Please step through the code to really find out what is happeneing, and
verify that you are writng the correct info from the datasource during ALL
of the postbacks, not only the first one.

And remeber

Response.Flush();
Response.Close();

when you are done writing the excel file!!

kind regards
Henrik

"Spacy" wrote:

Am creating a HTML Report in asp.net. To save this report to excel on
client-side, i write this code:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

But once the report is saved in excel, on click of hyperlink for second html
report, i dont get the second report. the same old first html report is
displayed.

Please can anyone help me. Am frustrated with this! Is it a problem of data
being cached? PLease help. Its very urgent!!!

Regards,
Spacy

Jul 21 '05 #2

Hi Henrik!

Thanks for the prompt reply! I tried using response.flush() and
response.close(), but the same problem persists. Let me explain what am doing:

I have 2 hyperlinks. On the click of first hyperlink, ExcelReport.aspx is
executed which contains the code:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")
After this code, i write all the response.write statements that generates
the html table. The Excel Report is saved perfectly. The page does not output
anything on the screen. No problem till here!

Now when i click on the second link, Report2.aspx is called which contains
code to generate the second html table and output it on the screen. In debug
mode, every line of code is executed. But the screen is blank. The new html
table is not displayed.

I know that probably am missing something silly. Could you please help ????

Cheers..
Spacy

"Henrik Nordgren" wrote:
Hi Spacy!

You should check the execution path of your program to find out what happens
at the second postback. All the data you write to the response stream after
the;

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

...lines are streamed to that excel file. That is the key to get the correct
output.

Please step through the code to really find out what is happeneing, and
verify that you are writng the correct info from the datasource during ALL
of the postbacks, not only the first one.

And remeber

Response.Flush();
Response.Close();

when you are done writing the excel file!!

kind regards
Henrik

"Spacy" wrote:

Am creating a HTML Report in asp.net. To save this report to excel on
client-side, i write this code:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

But once the report is saved in excel, on click of hyperlink for second html
report, i dont get the second report. the same old first html report is
displayed.

Please can anyone help me. Am frustrated with this! Is it a problem of data
being cached? PLease help. Its very urgent!!!

Regards,
Spacy

Jul 21 '05 #3

Finally I got atleast some headaway with this awful problem!
I found that this problem of the new html report not being displayed
after saving the first report to excel, occurs on only certain clients.
I was testing the code on the web server, and it wasnt working.
But on some clients, IT WORKS PERFECTLY!!!!!!!!!!

Anyone knows why????

Thanks in advance.

Regards,
Spacy

"Spacy" wrote:

Hi Henrik!

Thanks for the prompt reply! I tried using response.flush() and
response.close(), but the same problem persists. Let me explain what am doing:

I have 2 hyperlinks. On the click of first hyperlink, ExcelReport.aspx is
executed which contains the code:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

After this code, i write all the response.write statements that generates
the html table. The Excel Report is saved perfectly. The page does not output
anything on the screen. No problem till here!

Now when i click on the second link, Report2.aspx is called which contains
code to generate the second html table and output it on the screen. In debug
mode, every line of code is executed. But the screen is blank. The new html
table is not displayed.

I know that probably am missing something silly. Could you please help ????

Cheers..
Spacy

"Henrik Nordgren" wrote:
Hi Spacy!

You should check the execution path of your program to find out what happens
at the second postback. All the data you write to the response stream after
the;

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

...lines are streamed to that excel file. That is the key to get the correct
output.

Please step through the code to really find out what is happeneing, and
verify that you are writng the correct info from the datasource during ALL
of the postbacks, not only the first one.

And remeber

Response.Flush();
Response.Close();

when you are done writing the excel file!!

kind regards
Henrik

"Spacy" wrote:

Am creating a HTML Report in asp.net. To save this report to excel on
client-side, i write this code:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=Report.xls")

But once the report is saved in excel, on click of hyperlink for second html
report, i dont get the second report. the same old first html report is
displayed.

Please can anyone help me. Am frustrated with this! Is it a problem of data
being cached? PLease help. Its very urgent!!!

Regards,
Spacy

Jul 21 '05 #4

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

Similar topics

2
by: mike | last post by:
ok here's the problem: I have a page that displays a form for user to select individual fields and to specify their own criteria which is used to query a database and then create an excel...
4
by: Benny Alexander | last post by:
Dear All, I have a problem, which needs your ideas. We have a excel document, which is been updated regularly. After everyday updating, we export as HTML file and upload it. As a ASP...
0
by: Spacy | last post by:
I have 2 hyperlinks. On the click of first hyperlink, ExcelReport.aspx is executed which contains the code: Response.ContentType = "application/vnd.ms-excel"...
1
by: v_verno | last post by:
Good day, I have a web page that shows info retrieved from a MySQL db and I would like to convert all these data into an .XLS file. Have searched the net high and low but seems that I'm unable to...
4
by: Spacy | last post by:
Am creating a HTML Report in asp.net. To save this report to excel on client-side, i write this code: Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition",...
1
by: desi.american | last post by:
I have a dynamically generates ASPX page with tables and data. Depending on user selection, the same page can be viewed as a simple web page (rendered in HTML) or as an excel spreadsheet. If the...
5
by: kewalmehra | last post by:
Hi All, I have a requirement of saving Excel files as HTML using C#. I have managed to write code for saving as HTLM file. however this seems to be not working in the once perticular case . ...
5
by: =?Utf-8?B?c2NobWlkdGU=?= | last post by:
Hi How can I Export an HTML Table to excel? My goal is a button, and when the user clicks this button a popup appears asking the user to 'open' or 'save' the generated Excel file. Actually...
0
by: arindams | last post by:
I'm getting problem in pasting HTML text in Excel 2007 whereas it is working fine in Excel 2003. The data pasted in excel 2007 is showing the the HTML code which is not desired. I need to have the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.