473,657 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exporting data to Excel, strange problem

1 New Member
I have an aspx page that retrieves data from several different sources and uses them to define a new GridView, which is the exported as an Excel file.

I originally had all of the code required in a single Page_Load sub. Once I worked out all of the standard problems that seem to trouble those of us trying to export to Excel, it was working fine. But now I need to make it so that it exports exports the GridView as an Excel file upon clicking a button. "Easy enough," I thought, "I'll just cut and paste that part of the code into a Button_Click sub." It's not working out at all though.

The Excel file it produces when I click the button is only 17 bytes long. It consists of <div> in cell A1 and </div> in cell A3 and nothing else. I've tried a hundred things but I can't seem to get this to work. I'm still somewhat new to ASP, so it may well be something simple and obvious I just don't know about. Any suggestions?

Thanks much.
Sep 28 '07 #1
2 1319
shweta123
692 Recognized Expert Contributor
Hi,

I dont get exact idea what may be wrong in the code

These are some useful links that may help you

Link1

Link2





I have an aspx page that retrieves data from several different sources and uses them to define a new GridView, which is the exported as an Excel file.

I originally had all of the code required in a single Page_Load sub. Once I worked out all of the standard problems that seem to trouble those of us trying to export to Excel, it was working fine. But now I need to make it so that it exports exports the GridView as an Excel file upon clicking a button. "Easy enough," I thought, "I'll just cut and paste that part of the code into a Button_Click sub." It's not working out at all though.

The Excel file it produces when I click the button is only 17 bytes long. It consists of <div> in cell A1 and </div> in cell A3 and nothing else. I've tried a hundred things but I can't seem to get this to work. I'm still somewhat new to ASP, so it may well be something simple and obvious I just don't know about. Any suggestions?

Thanks much.
Sep 29 '07 #2
jhardman
3,406 Recognized Expert Specialist
Site administrators have asked that I keep ASP.NET with the .NET forum so I have moved it over. Sorry for any confusion.

Jared, moderator
ASP forum
Oct 1 '07 #3

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

Similar topics

3
9525
by: Jeremy | last post by:
Hi, I have a webpage that is taking input from a form and using it as criteria to select data out of an sql database. The page displays an html table with the results. The user can then click a button "excel" to open or save the file as an excel document. This works, and everything in the excel document is formatted fine except for the first column which in this case is "Part Number". The problem is that this part number: 883100105100...
3
9237
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
4
3942
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear" TEXT field that contains data such as 2000/01, 2001/02, etc. If I export a Query with this kind of data to Excel, it gives me the text value of this field; however, when I export a Report bound to this TEXT field, Excel gives me the values 36526,...
2
2301
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following code which I am using allows exporting only from text data from data grid & not from Edit columns which are link buttons. How to leave this column while displaying data from data grid in Excel?
1
2315
by: NancyA | last post by:
I am using the following code to write data from a datagrid to an Excel file: Dim tw As New System.IO.StringWriter Dim hw As New System.Web.UI.HtmlTextWriter(tw) dg.RenderControl(hw) Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Response.AppendHeader("content-disposition", "attachment;filename=test.xls") Response.Write(txtWriter.ToString) Response.End()
2
2402
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform exporting ALL data from the datagrid control. Exporting data works fine when I show all data on the datagrid control. I'd like to shows only 30 records on the datagrid control instead of ALL data using page navigation, and perform exporting...
2
3170
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
1
6971
by: 333sridhar333 | last post by:
Hi, I am having a problem in exporting a data from jsp to excel. I am getting the values from a servlet and populating it to a JSP. And form there i export them to Excel. The functionality works fine. But the problem is with the exported data. I am having values with leading zeros. for example: Patron Code
2
3575
by: 333sridhar333 | last post by:
Hi, I am having a problem in exporting a data from jsp to excel. I am getting the values from a servlet and populating it to a JSP. And form there i export them to Excel. The functionality works fine. But the problem is with the exported data. I am having values with leading zeros. for example: Patron Code
6
2176
by: jpatchak | last post by:
Hi, I have kind of a strange problem. I have a report that I need to export to excel. The report opens fine in Access and when I export it or click on "Analyze It with Microsoft Office Excel," I get the dialog that says it's exporting page n of total to file such and such. I get no error message. However, no Excel file is created. I've tracked down the problem to one of my fields on the report. It is a field called "ExpectedRate," with...
0
8323
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
8838
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...
1
8513
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
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...
0
7351
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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
4173
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...
1
2740
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
2
1732
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.