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

How To Show a Table In An Excel Spreadsheet?

What i want to do is take the checked data from a datagrid, send it to
a table, then show that table on an Excel Spreadsheet. Here is a little
bit of my code...

//adminProgress.aspx
<asp:DataGrid ID="pGrid" runat="server" AutoGenerateColumns="false"
AllowSorting="true">
<Columns>
<asp:TemplateColumn HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="check" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="lastName"
HeaderText="Last Name" />
<asp:BoundColumn DataField="firstName"
HeaderText="First Name" />
<asp:BoundColumn DataField="phoneNum"
HeaderText="Work Number" />
</Columns>
</asp:DataGrid>

//code behind to find selected items
private void buildTable()
{
tblTom.ID = "tblSelection";
foreach (DataGridItem dgItem in pGrid.Items)
{

if (((CheckBox)dgItem.FindControl("check")).Checked)
{
TableRow tRow = new TableRow();
TableCell tCell = new TableCell();

tblTom.Rows.Add(tRow);
tRow.Cells.Add(tCell);
tCell.Text = "CHECKED";
//tCell.Text = dSet.Tables[0].Rows[0].ToString();

}
}

//code behind to export from adminProgress.aspx to SpreadSheet.aspx
void export_Click(object sender, EventArgs e)
{
buildTable();
Server.Transfer("SpreadSheet.aspx");

}

//code behind SpreadSheet.aspx to show table from adminProgress.aspx
protected void Page_Load(object sender, EventArgs e)
{
adminProgress progressPage = (adminProgress)Context.Handler;
this.Controls.Add(progressPage.tblTom);
}

What happens is, when i select the wanted names, and click "Export" I
get a prompt to save/open and Excel spreadsheet (which is good). but
the spread sheet is empty(which is bad).
Any help?

oh, i inserted these into the top of SpreadSheet.aspx...
<%@ Reference Page="~/adminProgress.aspx" %>
<% Response.ContentType = "application/vnd.ms-excel"; %>

Jun 28 '06 #1
0 1559

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

Similar topics

2
by: Matthew | last post by:
I've been trying to find a way to gather up data contained in a table or tables on a previously generated html page in order to send it to a cgi for further processing. Ideally this would scrape...
12
by: jimserac | last post by:
I had previously posted this in an Access forum with negative results so will try here. Although this question specifies an Access database, I also wish to accomplish this with a large MS SQL...
2
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
4
by: Martin | last post by:
There is an Access table on the network. 15 users who do not have Access are connected to the network. Is there a way for each user to be able to enter one or more rows containing 3 or 4 columns to...
0
by: me here | last post by:
I have a VBA subroutine that links an MS Excel spreadsheet and copies the data into a local table. This process is controlled by a form that allows users to select the spreadsheet from the file...
6
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at...
6
by: syvman | last post by:
Hi everyone... I am pulling my hair out trying to do this, and was wondering if someone could give me some assistance... I have an Excel spreadsheet containing several worksheets. I'd like to be...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
0
by: ssrirao | last post by:
There is an Excel Spreadsheet containing data, residing in an internet site. Itís very easy to Import data from a local Excel Spreadsheet into SQL Server Database Table using DTS. But in my case...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.