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 ?
11 12632
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 ?
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?
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.
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
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.
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
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 ?
I got this code (in .aspx) to export Table into Excel : - If (Not (gridExport.HeaderRow) Is Nothing) Then
-
virTable.Rows.Add(gridExport.HeaderRow)
-
End If
-
-
For i = Val(txtPageFrom.Text) To Val(txtPageTo.Text)
-
gridExport.PageIndex = i
-
gridExport.DataBind()
-
-
For Each row As GridViewRow In gridExport.Rows
-
virTable.Rows.Add(row)
-
Next
-
-
If (Not (gridExport.FooterRow) Is Nothing) Then
-
virTable.Rows.Add(gridExport.FooterRow)
-
End If
-
Next
-
-
virTable.RenderControl(oHtmlTextWriter)
-
Response.Write(oStringWriter)
-
Response.End()
Is it what you mean ?
Or i should append row into excel. If so, would you tell me how to do it ?
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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
|
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?
|
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)
{
|
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...
| |
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...
|
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...
|
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...
|
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;
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |