hi,
I have a dataTable in Session.On the click of a button in a Modal Dialog window I need to export this dataTable to Excel sheet.How could i do this...??
i tried using a window.open('Excel.aspx','','','') in the onclick of the button And wrote the code for export in the page load of Excel.aspx .But my session gets cleared.There are no datas in the dataTable.
i dont want to use query string...
Thanks in Advance,
Blacky
11 5224
hi,
I have a dataTable in Session.On the click of a button in a Modal Dialog window I need to export this dataTable to Excel sheet.How could i do this...??
i tried using a window.open('Excel.aspx','','','') in the onclick of the button And wrote the code for export in the page load of Excel.aspx .But my session gets cleared.There are no datas in the dataTable.
i dont want to use query string...
Thanks in Advance,
Blacky
Look into where and why your Session is getting cleared.
I am doing about the same thing with a gridview and found the "dialogArguments" property to be useful as in: -
<script>
-
/* file popuptext.htm */
-
function fnGetInfo()
-
{
-
var sData = dialogArguments;
-
ta4details.innerText = sData;
-
ta4details.style.height = document.documentElement.clientHeight;
-
ta4details.style.width = "100%";
-
}
-
</scipt>
-
..
-
<body onload="fnGetInfo();" ..
-
I call it from my aspx page as follows: -
function LaunchGVRowCol(row, col) {
-
var ThisText = gridview1.rows[row].cells[col].title
-
showModelessDialog("popuptext.htm", ThisText, "dialogWidth:400px; dialogHeight:300px")
-
}
-
My C# page stores the info to display in "title" which is the tooltip and creates the OnClick attribute -
e.Row.Cells[desField].Attributes.Add("onclick", "return LaunchGVRowCol(" + e.Row.RowIndex + "," + nField.ToString() + ")");
-
-
HTH
In IE you can right-click the table and chose to export the data.
I on the other hand usually format my data as a CSV and allow the user to download/open it. Which normally would put it in Excel
Can you give me the code snippet..?? i want to export data from a grid in popup window to excel.. this is my requirement.
thanks in advance,
Blacky
Can you please tell me export from datagrid to excel.on click of a button in a modal dialog window
Have a page say "DownloadData.aspx" (or whatever) and pass it paramaters (querystring, post, session, whatever)
In that page build your data from the paramaters into a CSV, then change the response type to like "text/csv" and send the data down the response stream.
Here's the thing, the most common solution to exporting data as an Excel file requires you to implement an ASPX page that returns an Excel file instead of HTML. The headers, mime types and content are configured to indicate to the browser that an Excel file is being sent to it instead of HTML and therefore the browser opens the "save file as" dialogue.
So once you have implemented the page that returns the Excel file, you need to configure your button to open this page....the Excel file will be sent to the browser and the user will be presented with a "save file" dialogue.
the excel file is been generated and it is in temp. The problem is since i export the datagrid data to excel in a button click of a modal dialog window. I am not getting a popup to open a excel file or save it....
Since i need to maintain the datagrid items in the modal dialog, i have used
<base target="_self" /> in my html page.
This line of code does not make a popup for opening the excel...
anyways about how to handle it...??
I'm wondering if an iFrame will help you.
Place an iFrame on the page, when the user clicks the "download Excel version" button have the iFrame load the ASPX page that returns the excel file. This should pop up the "Save As" dialogue.
wat r u using?
if u r binding the datagrid to a datatable or a dataset
use this -
public static void WriteExcel(DataTable dt_Excel)
-
{
-
StringBuilder swColSb = new StringBuilder();
-
using (StreamWriter sw2Excel = File.CreateText(FileName.xls))
-
{
-
//get the Columns of the DataTable in the 1st Line
-
for (int i = 0; i < dt_Excel.Columns.Count; i++)
-
{
-
swColSb.Append(dt_Excel.Columns[i].ColumnName + "\t");
-
}
-
sw2Excel.WriteLine(swColSb.ToString());
-
//Fill The Rows To the Excel File
-
for (int i = 0; i < dt_Excel.Rows.Count; i++)
-
{
-
StringBuilder swRowSb = new StringBuilder();
-
for (int k = 0; k < dt_Excel.Columns.Count; k++)
-
{
-
swRowSb.Append(dt_Excel.Rows[i][k].ToString() + "\t");
-
}
-
sw2Excel.WriteLine(swRowSb.ToString());
-
}
-
}
-
}
-
-
and cal the function - WriteExcel((System.Data.DataTable)Datagrid.DataSource);
have fun
regards,
narz1986
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sunilkumar Reddy via DotNetMonster.com |
last post by:
hai all
first we can take binded grid
Export to excel data from ultrawebgrid (or) datagrid rows,
Each row data Expoting to one worksheet in excel workbook,
like as
grid row1 data contain sheet1...
|
by: Eric |
last post by:
Dear All,
I want to export datagrid content to a Excel file, the code just like below:
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim...
|
by: Bidarkota |
last post by:
Hi,
I have a DataGrid in which there are some images and Data are displayed and
in the webform.asp page i am using some stylesheets. when i export the
datagrid all the images are also exported...
|
by: sunilkumar Reddy via DotNetMonster.com |
last post by:
hai all
first we have taken binded grid
Export to excel data from ultrawebgrid (or) datagrid rows,
Each row data Expoting to one worksheet in excel workbook,
like as
grid row1 data contain...
|
by: Sridhar |
last post by:
Hi,
I have to export data inside the datagrid into an excel worksheet. I have
to do this on button click event. I am trying to do like this.
First get the DataTable from the datagrid and...
|
by: Frank |
last post by:
Hello All,
I ham using VS.NET 2003.
Have followed instructions from
http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several
other articles to no avail. I am pulling my hair...
|
by: mattmerc |
last post by:
Hi all,
We have all seen lot of method for exporting datagrids to Excel. I have
a slightly different need. I think it should be easy to accomplish but
I am not sure how. I would like when a user...
|
by: amitmnagarwal |
last post by:
I have a page where i export to excel the content of Page 1
following code is written on page 2 to generate the excel
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"...
|
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...
|
by: Reggie |
last post by:
Hi and TIA! I have an export procedure that exports my data from my
datagrids to excel. The problem is that I lose leading zero's cause excel
removes them and doesn't treat them as text. Is it...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |