473,795 Members | 3,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export GridView to Excel cause System.OutOfMem oryException - ASP.NET VB

15 New Member
Hello everyone,

I want to export GridView (25000 records) to Excel. But i got an error message like : System.OutOfMem oryException was Thrown.

But i need to export the records (even more than 25000 records) to excel

How to solve this ?
Oct 27 '08 #1
11 12632
ulai
15 New Member
Hello everyone,

I want to export GridView (25000 records) to Excel. But i got an error message like : System.OutOfMem oryException was Thrown.

But i need to export the records (even more than 25000 records) to excel

How to solve this ?
Oct 27 '08 #2
kenobewan
4,871 Recognized Expert Specialist
Why don't you create the excel spreadsheet directly from the database? Why would you need to create a spreadsheet that is 25000 records long, how useful is that spreadsheet going to be?
Oct 27 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
Well, you're trying to load more data than you have RAM. That's why you would get an OutOfMemoryExce ption.

Also, that is getting close to Excel's row limit, I think.
Oct 27 '08 #4
ulai
15 New Member
Thanks for replying

For the reason is I want to list the data with the spesific criteria that was given. And for 25000 records is just a matter of the USER BAD-HABIT that i want to handle.

And is it depend on memory that i have ?
my memory is 2004 MB RAM, and i checked the usage of memory is so low
Oct 28 '08 #5
kenobewan
4,871 Recognized Expert Specialist
If it is a user bad habit you are wanting to handle, then you either need to set a timeout for the transaction and/or enable custom error handling in your application.
Oct 28 '08 #6
jhardman
3,406 Recognized Expert Specialist
Hello everyone,

I want to export GridView (25000 records) to Excel. But i got an error message like : System.OutOfMem oryException was Thrown.

But i need to export the records (even more than 25000 records) to excel

How to solve this ?
Would you be opposed to exporting it as a csv or xml file (either of which are compatible with excel)? I know XML files are virtually limitless, and csv files can be written one line at a time - this wouldn't use much system memory. Now that I think about it, to get through that many records, you might need to add it a row at a time, just because of size restrictions.

BTW, in ASP we usually don't talk about GridViews, that is a term used in ASP.NET. Are you using ASP.NET (file extension .aspx) or ASP (file extension .asp)?

Jared
Oct 28 '08 #7
ulai
15 New Member
If it is a user bad habit you are wanting to handle, then you either need to set a timeout for the transaction and/or enable custom error handling in your application.
I am new in asp.net. And i don't know how to do that. Would you tell me how to do that ?
Oct 29 '08 #8
ulai
15 New Member
I got this code (in .aspx) to export Table into Excel :

Expand|Select|Wrap|Line Numbers
  1. If (Not (gridExport.HeaderRow) Is Nothing) Then
  2.     virTable.Rows.Add(gridExport.HeaderRow)
  3. End If
  4.  
  5. For i = Val(txtPageFrom.Text) To Val(txtPageTo.Text)
  6.                 gridExport.PageIndex = i
  7.                 gridExport.DataBind()
  8.  
  9.                 For Each row As GridViewRow In gridExport.Rows
  10.                     virTable.Rows.Add(row)
  11.                 Next
  12.  
  13.                 If (Not (gridExport.FooterRow) Is Nothing) Then
  14.                     virTable.Rows.Add(gridExport.FooterRow)
  15.                 End If
  16. Next
  17.  
  18. virTable.RenderControl(oHtmlTextWriter)
  19. Response.Write(oStringWriter)
  20. Response.End()
Is it what you mean ?
Or i should append row into excel. If so, would you tell me how to do it ?
Oct 29 '08 #9
jhardman
3,406 Recognized Expert Specialist
Moved your thread to the .NET forum - this spot has a lot of experts that are better than me at this type of thing. If they don't give you a response in a day or two we'll ask a couple of them to help out.

It looks like your code puts all of the data in a temporary table before saving it - and it is the temporary table that is probably having the problem since Excel has a limit of something like 65,000 rows. Instead of forming a temporary table, we should be trying to add each row directly to the Excel file.

So would you say you are opposed to saving the file in a XML or CSV format? The reason I ask is they are both compatible with Excel (excel can open them just fine) but there are many methods available to string them together and even write the files a line at a time - so much so that it might be more flexible than trying to save a .xls file

Jared
Oct 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

11
5651
by: Not Me | last post by:
Hi, I'm trying to export from a gridview control, to an excel file using code intended for a datagrid control (it's all over the web, can post if requested) I get the error. Control 'gvSearch' of type 'GridView' must be placed inside a form tag with runat=server.
6
671
by: Paul Zanbaka | last post by:
I have this code below it works fine when exporting to excel. However 2 things: 1-It does prompt me to save to file to excel (just displays excel in browser) 2-It aonly works if AllowSorting="false' in <asp:GridView > tag Can anyone help! -- Paul
2
9235
by: wubin_98 | last post by:
Hi, I want to export a gridview data and a image from image control to export to an Excel document. When I executed following code, GridView data was exported to Excel properly. But no image was displayed in Excel. Only a blank image icon was show inside Excel. Could any body point out what is wrong in my code or missing anything?
0
1248
by: Peter | last post by:
I experienced a bug, "Control GridView1 of type GridView myst be placed inside a form tag with runat=server". But I did so. I do not why, please advise. my code as below. Thanks. Peter <%@ Page language="C#" %> <script runat="server"> protected void Page_Load(object sender, EventArgs e) {
3
10126
by: =?Utf-8?B?bWFuaWthMDI=?= | last post by:
Hi, I have a GridView control in page called eventslisting which is inheriting from a MasterPage. The normal code to export to GridView does not work and gives me an error - "Control of type GridView must be placed inside form tag with runat = server". I understand that this is because my Masterpage has the formtag and not the eventslisting page. As a workaround I programatically created an HTML form, added runat=server attribute to it...
1
3364
by: edwinparker | last post by:
Hi, I'm trying to convert a gridview to an excel report and have one small hang up. So far I've been able to create my gridview and export it to excel ok, but in my gridview I have an image. The problem is, the image won't display unless I'm connected to the Internet or if I use a relative path and have the image stored relative to the excel file. Is it possible to "embed" the image from the gridview into the excel workbook so I could give...
0
463
by: Mike | last post by:
On my page I'm using an updatepanel, updateProgress, and a ModalProgress, everything works great But when I try to export my GridView to excel I'm getting the following error message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common cause for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is...
3
5214
by: ulai | last post by:
Thanks for your help. It really help to solve my work. But now i have a bigger problem : I had more than 65535 records in gridview divide by 10/pages. And when i tried to export the gridview in excel on every way : 1. I disabled the allowpaging in gridview and got and error messages like : System.OutOfMemoryException Was Thrown 2. My idea is to store row in gridview to virtable per pages. I create virtable as Table. Added row to virtable...
2
6423
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the method.... it creates 6 sheets # region Namespaces using System;
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.