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

gridview not exporting to excel

Tom
I have a gridview on all of my web pages in my web app and they all export
to excel. I have one page where the gridview is binding to a datatable that
i created and only the first column is exporting to excel. How can I get the
entire grid to export to excel?

Dec 17 '06 #1
4 2477
I have a gridview on all of my web pages in my web app and they all
export to excel. I have one page where the gridview is binding to a
datatable that i created and only the first column is exporting to
excel. How can I get the entire grid to export to excel?
Provide a hyperlink on your page to a handler (IHttpHandler) that emits "text/csv".
In your handler use Response.Output.WriteLine("1,2,3,4") to generate your
data. Excel will hapily open this data.

-Brock
http://staff.develop.com/ballen
Dec 17 '06 #2
Tom
thats what i have on every page that has a grid and every page works except
for this one.
its only exporting the first column.

"Brock Allen" <ba****@NOSPAMdevelop.comwrote in message
news:b8*************************@msnews.microsoft. com...
>I have a gridview on all of my web pages in my web app and they all
export to excel. I have one page where the gridview is binding to a
datatable that i created and only the first column is exporting to
excel. How can I get the entire grid to export to excel?

Provide a hyperlink on your page to a handler (IHttpHandler) that emits
"text/csv". In your handler use Response.Output.WriteLine("1,2,3,4") to
generate your data. Excel will hapily open this data.

-Brock
http://staff.develop.com/ballen


Dec 17 '06 #3
Hello Tom,

Based on my experience, the problem you met is likely caused by the data
bound to the GridView. I suggest you try saving the exported file as xls or
csv on the client machine and then use notepad or any other text editor to
open it. You can check whether all the data rows and columns(from
server-side datasource) have been persisted in it. If those rows and
columns are missing, it should be caued by some problem with the
server-side gridview databinding and the code logic of flushing the data to
response stream. If the data rows/columns are all persisted in the file,
that means the server-side page/handler has successfully render out the
data, but the cilent-side excel fails to display all the columns when
parsing the file/response stream. How do you think?

BTW, would you provide some detailed code logic on how did you render out
the GridView data as csv format or directly render out the GridView?

Please feel free to let me know if there is anything I missed.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 18 '06 #4
Thanks for your reply Tom,

I'm glad that you've figured out the issue. If you meet any new problem
later, please feel free to post here also.

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 19 '06 #5

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

Similar topics

0
by: Mike P | last post by:
I am using the following code to export my gridview to excel : protected void btnExport_Click(object sender, ImageClickEventArgs e) { Response.Clear(); Response.AddHeader("content-disposition",...
2
by: mike | last post by:
Hi, I have surfed through several posting about exporting gridview to excel and it works great. using the following code... response.Clear() response.ContentType = "application/vnd.ms-excel"...
2
by: manmit.walia | last post by:
Hello Fellow Developers, I have a small problem that you might be able to help me with. The method that I am trying to create is the ability to export a GridView and a image to word or excel. I...
3
by: Daves | last post by:
hi, exporting GridView data to Excel is no problem but in the first data row I would like to put some descriptive information for the table. I cannot see any way to add this directly to the...
0
by: David | last post by:
Using ASP.Net 2.0 and I have identical code for exporting a GridView to Excel in 2 web sites. One works fine and the 2nd one gives me the error "RegisterForEventValidation can only be called...
0
by: gujarsachin2001 | last post by:
Hi Friends, I am expeorting data from gridview to excel data is exporting fine .But saving file or cancling saving file when I am coming back to my web page it gets hanged ......... So can any...
0
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a gridview. I calculated some values in the gridview for the footer of the gridview so basically I am adding all the values that are displayed in the gridview for each...
2
by: =?Utf-8?B?SkRSYXZlbg==?= | last post by:
I have searched all over and can not seem to find an effective way to simply copy the contents of a ASP:gridview column to the clipboard based on a button or similar HTML or ASP.NET control. ASP...
1
by: Yordan Georgiev | last post by:
I have a search form using master page , which is dynamically generated from the column names of the database - when the users have a search result it should be exported to Excel by clicking the...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.