gridview not exporting to excel

T

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?
 
B

Brock Allen

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.
 
T

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.
 
S

Steven Cheng[MSFT]

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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.

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



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

Steven Cheng[MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top