469,645 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

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 2238
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mike P | last post: by
3 posts views Thread by Daves | last post: by
reply views Thread by David | last post: by
reply views Thread by gujarsachin2001 | last post: by
reply views Thread by =?Utf-8?B?Vmlua2k=?= | last post: by
2 posts views Thread by =?Utf-8?B?SkRSYXZlbg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.