I'd like to create/display an Excel spreadsheet from javascript. We
have an HTML page with results of a search and it can be reasonably
large.
The first attempt was to format the data into an HTML table and send
it to an ASP page. The ASP page has:
Response.AddHeader ("Content-Disposition", "inline");
Response.ContentType = "application/vnd.ms-excel");
Response.Write(formatted_html_data);
Works fine until there's more than 100K bytes of data. It then hits
an ASP limit and blows chunks.
Second attempt: Do it all on the client side in Javascript. A
variable has the HTML:
<html>
<head>
<meta http-equiv="Content-Type" CONTENT="application/vnd.ms-excel">
<meta http-equiv="Content-Disposition" CONTENT="inline">
</head>
<body>
<table>
....html-formatted data...
</table></body></html>
We send the data to a new window:
var newWin = window.open('','','width=300,height=300');
newWin.document.write(variable_with_html);
newWin.document.close()
The window pops up, html-formatted data displays in it, but Excel
doesn't run.
What's the difference between the first method and the second? Both
send 'stuff' to the browser that it will interpret.
Are the <meta> tags wrong? It's the only thing I can think of, since
one is generated by ASP (and it works) and the other by me (doesn't
work).
Thanks,
Jim 1 47724
Jim, N2VX wrote: I'd like to create/display an Excel spreadsheet from javascript. We have an HTML page with results of a search and it can be reasonably large.
The first attempt was to format the data into an HTML table and send it to an ASP page. The ASP page has: Response.AddHeader ("Content-Disposition", "inline"); Response.ContentType = "application/vnd.ms-excel"); Response.Write(formatted_html_data);
Works fine until there's more than 100K bytes of data. It then hits an ASP limit and blows chunks.
Try NOT building up a HUGE string before you write to the Response
object. Have a function which outputs the Excel data to the Response
rather than one which creates a huge string.
HINT: You can create proper, functional Excel Spreadsheets by sending a
correctly formatted XML spreadsheet with that ContentType. See http://msdn.microsoft.com/library/de.../odc_xmlss.asp
It's finicky about the XML formatting, but once you get it right, you
can get some really nice spreadsheets out. Persevere with this approach.
This is the way to go, you cannot generate a spreadsheet in javascript.
Second attempt: Do it all on the client side in Javascript. A variable has the HTML:
<html> <head> <meta http-equiv="Content-Type" CONTENT="application/vnd.ms-excel"> <meta http-equiv="Content-Disposition" CONTENT="inline"> </head> <body> <table> ...html-formatted data... </table></body></html>
We send the data to a new window: var newWin = window.open('','','width=300,height=300'); newWin.document.write(variable_with_html); newWin.document.close()
The window pops up, html-formatted data displays in it, but Excel doesn't run.
No, it won't suddenly fire up Excel. You are writing data into an HTML
document in the browser. That's what document.write() does. Once you are
IN a document, it makes no difference what data you write into it - it's
an HTML DOCUMENT!
The previous method used the HTTP standard (Do a google on it) to inform
the browser what kind of data was coming back from the server. You
correctly informed the browser that Excel data was coming back
(ContentType = "application/vnd.ms-excel"), so the browser offers to run
the application (or save the output).
Hope this helps.
Nige This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Powell |
last post by:
What would one best recommend to parse an existing Excel spreadsheet (was
done in Excel 97 or 2000 not sure to be honest)? I am looking for the most
practical way of parsing an existing spreadsheet to place contents into a
mySQL db.
Thanx, Phil
PS: can you use fopen() to read the contents and parse? The spreadsheet is
on a remote site.
|
by: quadric |
last post by:
Hi,
I have an application that requires that Python initiate and mediate a live
and iterative conversation
between an external application (in which Python is embedded) and an
external Excel
spreadsheet. Python will have to pass info to the spreadsheet, spreadsheet
will make
calculations, Python will obtain results and pass back to...
|
by: Mark |
last post by:
I've been asked to convert a pay increase spreadsheet to an intranet
page. So far I've developed a page that uses a combination of ASP and
Javascript to retrieve all of the required information from the HR
database. The problem is that I need to be able to calculate the new
salary based on an increase_amount field, as well as maintain a...
|
by: Ken Hall |
last post by:
Is it possible to create an Excel spreadsheet using VB.NET without
opening the Excel application or having to have the Excel application
on the operating computer?
KH
|
by: Scott M. Lyon |
last post by:
I'm trying to figure out a way to export data (actually the result of a
Stored Procedure call from SQL Server) into a specified Excel spreadsheet
format.
Currently, I have the data read into a DataSet that consists of one
DataTable.
That DataTable has a specific name (for arguments purposes, let's say it's
called "DataGrid"), that I...
| |
by: PeterW |
last post by:
Hello.
Is it possible, using code, to create a spreadsheet in excel format, with
cells containing constant text and formulae and inserting data from a
recordset in specific cells?
If so, could someone point me to an information page with details on how to
achieve this?
Many thanks
|
by: eolmos |
last post by:
Hello everyone, I am currently working on a project that requires a webform in asp.net using C# as the code behind. The page must allow the user to create a report in excel. This report must also generate a chart based on the input dataset. (By the way, the component must be free)
So far, I have tried a lot of components which are really good but...
|
by: Sport Girl |
last post by:
Hi everybody ,
i have the task of developing in Perl a script that retrieves data from 3 tables ( bugs, profiles, products) from a MySQL database called bugs and display them in an excel sheet report.
I always get when trying to test it " 500 Internal Server Error - The server encountered an internal error or misconfiguration and was unable...
|
by: zacks |
last post by:
I have an application that can read an Excel spreadsheet on a computer
that doesn't have Excel installed on using the Jet ODBC 4.0 driver.
I know need to modify the application to also be able to create a new
Excel spreadsheet and write data to it on the same computer, a
computer that does not have Excel, or even Office installed.
I have...
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |