473,586 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use a stringwriter to export invisible contents?

I'm writing the contents of my datagrid to an Excel spreadsheet using
the following code:

Sub WriteToExcel(Se nder as Object, E as EventArgs)
'Export the contents of the current datagrid to Excel
Response.Clear( )
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition", "attachment;fil ename=Data.xls" )
Response.Charse t = ""
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache)
Dim stringWrite As StringWriter = New StringWriter
Dim htmlWrite As HtmlTextWriter = New HtmlTextWriter( stringWrite)
dgrExportGrid.R enderControl(ht mlWrite)
Response.Write( stringWrite.ToS tring())
Response.End()
End Sub

This works great, but when I enabled paging on my datagrid, only the
displayed page of data is exported, not the whole dataset. My workaround
is to place a second, non-paged datagrid on my page, populate it with
the same data as my main datagrid, and set its visible property to
false. But my sub now exports a blank Excel spreadsheet. I guess if a
control is invisible, it's invisible to a stringwriter too...?

Can anyone solve this problem or suggest another approach? As always,
any help is much appreciated.
Jul 27 '08 #1
0 1102

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

Similar topics

7
14356
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to display the graph but it is not possible to send query parameters to an OLE graph on a report (or programatically change any properties of an OLE...
4
9281
by: Einar Høst | last post by:
Hi, I'm having weird problems using StringWriter and XmlTextWriter. My code looks like this: StringWriter sw = new StringWriter(CultureInfo.InvariantInfo); XmlTextWriter xtw = new XmlTextWriter(sw); // NullReferenceException thrown here! xtw.WriteStartDocument(); xtw.WriteStartElement("MyRoot");
3
4343
by: Bidarkota | last post by:
When i export DataGrid to Excel all the HTML contents are also exporting to excel. i am using stylesheets in the ASPX Page and i am getting an alert message that stylesheets are missing. i need to export only the contents of the Datagrid to excel. i don't need all other stuff which is present on the page. is there any way to achieve it. ...
4
2834
by: fabrice | last post by:
Re hello, I m' sorry for my questions .. Under framework 1.1 with vb.net, i m using a StringWriter object to export in .xls file. To empty memory, I would like to use the propterty dispose on the object StringWriter. But i have received an error like this : example :
1
5580
by: InvestorTrade | last post by:
Hi, I've been trying to export/import a table from a DB with Chinese_PRC_CI_AS collation, and I can't seem to get it working at all - the export seems rather simple, it is the import that is not working at all. I am using MSSQL 2000: The table (under a Chinese_PRC_CI_AS collation DB) is as follows:
6
4133
by: jefftyzzer | last post by:
Friends: Let's say I'd like perform a delete, but before I delete, I'd like to export the target rows. I could use an export whose SELECT clause references the OLD TABLE of a DELETE, but the issue is I'm deleting the table in chunks, like so: WHILE (V_NO_DATA = 0) DO DELETE FROM
1
25706
by: Swedge | last post by:
Hello I'm very new to using DB2, and would like to know about exporting the contents of a table to a flat file. For example, I have the following character string in a text field Craig Sweeney 99 Letsby Avenue Scotland UK. I would like to be able to extract the contents of this field to a txt file so that it was in the following format ...
9
4779
by: Mel | last post by:
I have 10 columns total. 3 of them are invisible. The rest are read- only BoundFields, 3 of which are editable fields using TemplateFields. Upon editing, I want to validate what the user enters against one of those invisible columns. How do I accomplish this? The code below that I attempted just returns an empty string when I try to...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
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
8215
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
6610
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
5710
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
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
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
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
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.