473,562 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export To Excel - ASP.NET 1.1

Hello All,
First, thank you for any help you can provide.

I'm trying to do a simple export to excel. I've used the classic
code that is all over the internet, and of course it worked without a
problem.

The problem is that I want to add text above the data grid in the
excel sheet. The text already exists on the web page in various panels
(there is different text depending on the parameters of the datagrid
report). But, every attempt to accomplish this, results in HTML being
rendered (for both the text and the data grid). Again, the data grid
exports correctly without the additional text.
Any help would be appreciated, even a references to an article on the
internet.
--- The code I'm using --
//Filling the data grid is handled else where...

//
//export to excel
Response.Clear( );

Response.Charse t = "";
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);

Response.Conten tType = "applicatio n/vnd.ms-excel";
//Response.Conten tType = "applicatio n/vnd.xls";
this.EnableView State = false;
System.IO.Strin gWriter oStringWriter = new
System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter oHtmlTextWriter = new
System.Web.UI.H tmlTextWriter(o StringWriter);

dgReport.Render Control(oHtmlTe xtWriter);
Response.Write( oStringWriter.T oString());
Response.End();
----
Here are a couple things that I've tried. Just before the
dgReport.Render Control(oHtmlTe xtWriter), I've inserted
rptText.RenderC ontrol(oHtmlTex tWriter) -- this "worked" but the HTML
formating didn't work, all of the HTML was visible in excel like I was
looking at the page in notepad.

Additionally, I've tried to export the entire page to excel, but then
the headers (and filter bar) show up in it. My attempt to hide all of
the headers (and the filter bar) didn't work... Even though the
visible property (wrapped around the filter bar) was set to false, it
still rendered in excel.

I hope this is enough information, but if more is needed ask.

Thank you & Regards,
Frank

Mar 15 '07 #1
1 7200
The method you are using converts the contenttype of the entire page which
works well for display excel but leaves very little room for customization.
Perhaps add a header data row with the required information before streaming
out the input. It's not as neat but it should provide a workaround.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"JawzX01" <ja*****@gmail. comwrote in message
news:11******** **************@ y66g2000hsf.goo glegroups.com.. .
Hello All,
First, thank you for any help you can provide.

I'm trying to do a simple export to excel. I've used the classic
code that is all over the internet, and of course it worked without a
problem.

The problem is that I want to add text above the data grid in the
excel sheet. The text already exists on the web page in various panels
(there is different text depending on the parameters of the datagrid
report). But, every attempt to accomplish this, results in HTML being
rendered (for both the text and the data grid). Again, the data grid
exports correctly without the additional text.
Any help would be appreciated, even a references to an article on the
internet.
--- The code I'm using --
//Filling the data grid is handled else where...

//
//export to excel
Response.Clear( );

Response.Charse t = "";
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);

Response.Conten tType = "applicatio n/vnd.ms-excel";
//Response.Conten tType = "applicatio n/vnd.xls";
this.EnableView State = false;
System.IO.Strin gWriter oStringWriter = new
System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter oHtmlTextWriter = new
System.Web.UI.H tmlTextWriter(o StringWriter);

dgReport.Render Control(oHtmlTe xtWriter);
Response.Write( oStringWriter.T oString());
Response.End();
----
Here are a couple things that I've tried. Just before the
dgReport.Render Control(oHtmlTe xtWriter), I've inserted
rptText.RenderC ontrol(oHtmlTex tWriter) -- this "worked" but the HTML
formating didn't work, all of the HTML was visible in excel like I was
looking at the page in notepad.

Additionally, I've tried to export the entire page to excel, but then
the headers (and filter bar) show up in it. My attempt to hide all of
the headers (and the filter bar) didn't work... Even though the
visible property (wrapped around the filter bar) was set to false, it
still rendered in excel.

I hope this is enough information, but if more is needed ask.

Thank you & Regards,
Frank

Mar 18 '07 #2

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

Similar topics

1
5352
by: congngo | last post by:
Hi all Every time I export a table into an excel spreadsheet. It has a leading apostrophe on every cells. This drive me nut. I have to do a work around by export table into a txt file than import in excel to get rid of the apostrophe. It has been happen about two months now before it didn't do that. It is only happen when I have text...
5
2656
by: Tim Frawley | last post by:
I created a .NET Com Class object for use in ASP reports to export database results directly to Excel. I have it all working just find but I cannot get the Excel process to go away after the job is done. I am using the following .NET code in my Com Class object: <ComClass(DIF2XLS.ClassId, DIF2XLS.InterfaceId, DIF2XLS.EventsId)> _ Public...
3
2586
by: ABC | last post by:
What methods can export excel file from stored procedure with parameters which input from web form?
1
3044
by: panku007 | last post by:
hi All, I wanted to export excel data into ms word document through java coding.So please send me reply,according to my question. thanks
2
1850
by: tbenchakroune | last post by:
How can I export Excel spreadsheets to Access db? Thanks, T.
1
2847
by: san1014 | last post by:
Hi How to import and export excel data into oracle database using java. Thank you
1
6185
by: CF FAN | last post by:
Can Report Builder Export Excel Files with multiple Sheets How can I create a report that it can export in excel by multiple
3
3021
by: minhtran | last post by:
Hi all Anyone has any idea how to get a Excel header column in VB.NET. Please, help me. Thank you so much in advance
0
2501
by: Dubois | last post by:
Bonjour Lorsque je lance un export excel au travert d'une page en ASP.NET C#, cela fonctionne sur la machine de développement, par contre, sur le serveur de production j'ai l'erreur suivante : ***************** La récupération de la fabrique de classe COM pour le composant avec le CLSID {00024500-0000-0000-C000-000000000046} a échoué en...
3
4061
by: prashantdixit | last post by:
Hi, I am trying to export excel data to text file in a particular format. The Format for each ROW of Excel is like IMAN_ROOT/bin/import_file -f=<Column A> -type=<Column B> -d=<Column C> -ref=<Column D> -vb -log=<Column E> Every Row of the excel should export in text with this format.
0
7579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7628
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7937
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6224
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3608
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
904
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.