471,591 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,591 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...

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

//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();

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)


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

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 1485

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Matthew | last post: by
9 posts views Thread by dba123 | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.