473,890 Members | 1,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with code to download table to excel

Hi
I have always downloaded table data to excel using a perl_cgi. The perl
cgi will simpley print("Content-Type: application/vnd.ms-excel");
followed by the usual html table formatted data.

However if I try the same with javascript it does not seem to work.

ie document.write( "Content-Type: application/vnd.ms-excel");
document.write( "<html><table>< thead>bla bla...</html>);
This never triggers the save file as/ or open with excel. It displays
the data in the browser but does not trigger an excel save.
What am I doing wrong?

Thanks
May 14 '07 #1
2 7085
ASM
lxrocks a écrit :
Hi
I have always downloaded table data to excel using a perl_cgi. The perl
cgi will simpley print("Content-Type: application/vnd.ms-excel");
followed by the usual html table formatted data.
where does-it print that ?
However if I try the same with javascript it does not seem to work.
where do you try the following ?
ie document.write( "Content-Type: application/vnd.ms-excel");
document.write( "<html><table>< thead>bla bla...</html>);
That would have to write an "html" file ( *.html )
This never triggers the save file as/ or open with excel. It displays
the data in the browser but does not trigger an excel save.
What am I doing wrong?
To do not produce an Excel file ( *.xls ) ?

My last play with this idea (Excel document) :
http://perso.orange.fr/stephane.mori...o_xls_op.shtml

Perhaps with XML and JS-DOM ?

And read or re-read here in c.l.javascript the thread :
"FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?"
<http://groups.google.c om/group/comp.lang.javas cript/browse_frm/thread/ca13c70349b96de 6/75c7b581bb814f1 0?#75c7b581bb81 4f10>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
May 14 '07 #2
ASM wrote:
lxrocks a écrit :
>Hi
I have always downloaded table data to excel using a perl_cgi. The
perl cgi will simpley print("Content-Type: application/vnd.ms-excel");
followed by the usual html table formatted data.

where does-it print that ?
>However if I try the same with javascript it does not seem to work.

where do you try the following ?
>ie document.write( "Content-Type: application/vnd.ms-excel");
document.write( "<html><table>< thead>bla bla...</html>);

That would have to write an "html" file ( *.html )
>This never triggers the save file as/ or open with excel. It displays
the data in the browser but does not trigger an excel save.
What am I doing wrong?

To do not produce an Excel file ( *.xls ) ?

My last play with this idea (Excel document) :
http://perso.orange.fr/stephane.mori...o_xls_op.shtml

Perhaps with XML and JS-DOM ?

And read or re-read here in c.l.javascript the thread :
"FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?"
<http://groups.google.c om/group/comp.lang.javas cript/browse_frm/thread/ca13c70349b96de 6/75c7b581bb814f1 0?#75c7b581bb81 4f10>

I realise now that there is a difference between client and server side
code when dealing with Mime. Thank you for the example it is most helpful.
May 14 '07 #3

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

Similar topics

7
18804
by: Martin | last post by:
I have a situation where I'm displaying some information in a table on a web page. I've given the user the ability to make several different "queries" and show different sub-sets of the data. I would like to add a button to the page that would allow the user to create an .XLS file that would contain the current contents of the table. I realize that I could create it on the server and allow him to download it but I'd rather let him create...
9
4038
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then need to input this in an Access database, where I do a comparison with the Actual cost. The table “TblBudget” in Access is made of 4 fields, namely: (1) CostElement (2) CostCenter (3) Month (4) Amount$. At the moment this method is very cumbersome....
5
3794
by: Maria L. | last post by:
Hi, I need to export the content of a DataGrid (in Windows application in C#), into an Excel spreadsheet. Anyone knows how to do this? Any code snippets would help! thanks a lot, Maria
0
6592
by: Learner | last post by:
Gurus, I have a C# .NET Web application that downloads a datagrid to an Excel sheet. But when I upload the same excel sheet to server again, if gives me this wiered message "External table is not in the expected format". I have some idea why this is happening..Because my downloaded file is getting saved as an HTML file eventhough it will get opened in Excel and looks like an Excel file. If I open the downloaded file and do a
1
1267
by: Coleen | last post by:
To export data from a datagrid to an excel file. I am using VB.net/ASP.net v 2003, and not connecting to an SQL database. I have an existing datagrid that I want to get the data from and download it to an excel file. Mrozu was kind enough to send me some code (thank you) - unfortunately it does not work - it gives me an error "Cannot create ActiveX component." which he says is due to not having Excel installed on my machine. I DO have...
9
3952
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
2
1732
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I created a simple dll in VB2005 to use ADO.Net -- oleDBDataAdapter to write data to an Excel file. The code (below) works fine from an Excel file (invoke the dll from Excel to write to another Excel file) But if I run the same dll (tlb) from MS Access - I get an error that I need to use an updateable query. Why does the following code work fine in Excel but not in MS Acces? Maybe because Excel doesn't use Jet? Any...
1
1557
by: JRussell | last post by:
Hi, I am trying to download sql database through asp on my webpage and I keep getting weird outcomes in Excel. I have had to put in <char10> and <char13> into my sql data to have it display properly on the webpage and I know this is messing with the csv file download. What it is doing in excel is breaking the "breaks" into multiple rows per recordset. Here is my download code, is there anyway to fix this without removing them from my...
1
1840
by: Amzul | last post by:
hello all i am trying to create an excel report file to download i have saw few examples in this site and work with them, this is whats going on: main.php have a form that the user choose date to extract his report, then with ajax i return the table affter being generated from mysql.
0
9978
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
9821
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
11229
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
9630
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
8016
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
5850
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...
0
6042
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4271
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3276
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.