473,386 Members | 1,819 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.

Export Excel Question

Hi all,

I have a parent page(parent.aspx) which will open different new windows
depending on the user input.

for example,
the new windows are opened using the following code :
window.open('child.aspx', document.userinput.value)

In the child.aspx, the result is rendered as Excel, Word, PDF, etc...
depending on the input parameters from the parent pages.

There is no problem when the user just open 1 pop up window.
However, when the user first open a Excel Window, and then open another
window (Word) , the first window will become blank. Then the result in the
second window
will become the result in first window (Excel).

Thank You.
Sep 20 '06 #1
1 1598
Here are the sample codes.
Parent.html :

<html>
<head>
<script language=javascript>
function OpenWindow()
{
var oWnd = window.open('', document.frmOption.selOption.value);
document.frmOption.target = document.frmOption.selOption.value;
document.frmOption.submit();

}
</script>
</head>
<body>
<form id=frmOption name=frmOption method=post action="child.aspx">
<select id=selOption name=selOption>
<option value=1>Excel</option>
<option value=2>Word</option>
</select>
<input type=button value="Open Window" onclick="OpenWindow()">
</form>
</body>
</html>

Put the following code in Child.aspx :
c#

if (Request["selOption"].ToString().Trim() == "1")
{
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition",
"inline;filename=excel.xls");
Response.Write("This is Excel");
}
else
{
Response.ContentType = "application/vnd.msword";
Response.AddHeader("Content-Disposition",
"inline;filename=word.doc");
Response.Write("This is Word");
}
Response.End();
vb.net

if Request("selOption").ToString().Trim() = "1" Then
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition",
"inline;filename=excel.xls")
Response.Write("This is Excel")
else
Response.ContentType = "application/vnd.msword"
Response.AddHeader("Content-Disposition",
"inline;filename=word.doc")
Response.Write("This is Word")
end if
Response.End()

Sep 20 '06 #2

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

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
4
by: Gary Wright | last post by:
I have an Access 2K database split into front and back. Quite often the users want to do some data analysis that I have not created a report for so they want to export some subset of the data into...
5
by: Igor | last post by:
Hi everyone! I have a question about exporting data to Microsoft Excel. I am writing program in C# and have to export some data to excel workbook. It works very good using OLE technology, but...
2
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType =...
4
by: paul.chae | last post by:
I have a table in Access with about 3000 records. There are ~60 unique values in the ID field for the 3000 records. What I would like to do is automatically generate multiple Excel worksheets...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
5
by: karthick | last post by:
Hi, I am exporting a Gridview to Excel and it works fine without any issues. But as one of the field holds values such as "71646E100" it gets converted to: "7.16E+104" (like a formula) in...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
19
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.