473,670 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execcommand > What is happening? Anyone?

Hi!
I need help. I have a variable which is just a string containing the
output of a transform from XML to CSV format. I want the client to be
able to download this as a file (.csv), so I used this piece of code:

function SaveVarAsFile(s omeVar){
alert(someVar);
SaveFrame.docum ent.open("text/plain","replace ");
SaveFrame.docum ent.write(someV ar);
SaveFrame.docum ent.close();
SaveFrame.docum ent.charset="UT F-8";
SaveFrame.focus ();
SaveFrame.docum ent.execCommand ('SaveAs','fals e','test.csv');

SaveFrame is an iframe in the body of my page:
<iframe id="SaveFrame" style="display: none"></iframe>

Now I don't want the encoding to be UTF-8 but I need it to be ASCII,
in order to display the file properly in Excel instead of having all
the data in one column. But when I change charset into "ASCII", the
file that is saved is not the document in the iframe but the whole
html page the iframe is part of! How is this possible and what can I
do to fix it?
Secondly, the saved file begins and ends with html tags that I don't
want, I want it to be just plain text. How do I get rid of these tags?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=utf-8"></HEAD>
<BODY><PRE>

Hope someone can help 'cause I'm getting really frustrated! Thanks.
Jul 23 '05 #1
3 5527
Hello

I don't know if this helps.

I tested it for myself, and Microsoft seems to do something different
depending on the extension you give the file name.

If you use ".csv" then as you noted, it seems to save the HTML mark
up.

However if you use ".txt", then it will just save the plain text as
desired.

If you want to save with a file name ".csv" then you may need to use
the ActiveX object "Scripting.File SystemObject" but obviously this is
only for browsers that support it, and it will depend on browser
security settings.

Julian
Jul 23 '05 #2
Thanks, but I had already gotten rid of the HTML tags differently, by
changing the MIME type of
SaveFrame.docum ent.open("text/plain","replace "); to text/html. What
remains is the encoding problem, I get this neat file which looks like
this:

"id","datat ype"
"0","Unknow n"
"1","intege r"
"2","float"
"3","string "
"4","memo"
"6","date-time"
"7","boolea n"

but the encoding is unicode and Excel therefore does not separate the
columns but shows the data above all in one column. When I open it
with notepad, save it as ANSI and reopen it in Excel, it is displayed
correctly in two columns without showing the commas and apostrophes.
Who can help me? Thanks!
Jul 23 '05 #3
Hello

Sorry I could not help.

I wonder if it would make any difference to specify the encoding as well.

See the following page:-

http://www.w3.org/International/tuto...rial-char-enc/
Julian
Jul 23 '05 #4

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

Similar topics

1
2562
by: dd | last post by:
Cannot figure it out. If somebody can help, I'd appreciate it. I am using DHTML Edit control from C# for editing HTML pages. I am trying to insert a table into an HTML page and I keep getting an error. Here is the code: DHTMLEDLib.DEInsertTableParamClass oTableParam = new DHTMLEDLib.DEInsertTableParamClass(); oTableParam.NumCols = 3; oTableParam.NumRows = 3; oTableParam.TableAttrs = "align=\"left\" border=\"1\" width=\"100%\"";...
1
6747
by: E J | last post by:
Does anyone know of a way to wrap custom tags around selected text using execCommand or otherwise? I am developing a rich text editor for use in a web site and while there are a few decent ones already floating around I need to implement a few extra bits of functionality. Specifically tool tips. Idealy I'd like to wrap custom tags around selected text using execCommand. Ie "Selected Text"
3
4496
by: Patrick S | last post by:
I am using IE 6.0. On a page, I have placed a contenteditable div which I want to use as a Rich Text Area. I am using the execCommand method of the document to control bold, italics, underlining, and undo for this div. I have placed an input element on the page to. All but the undo, are restricted to working only on the div. How can I restrict the undo to working on only the div? Below is the complete page so you can see what I am...
2
13369
by: Rafal Konopka | last post by:
I've read MS documentation, I've searched the discussion threads, I cannot invoke the SaveAs command from a web page. I tried <a href="javascript:window.execCommand(\"SaveAs\");"><click here</a> <a href="javascript:document.execCommand(\"SaveAs\");"><click here</a> I tried passing arguments (\"SaveAs\",1,\"myfile.htm\"); I cannot get it to work.
4
7142
by: am75 | last post by:
Hi everybody, I'm developing web pages for content management using iframes, through which users can edit html portions... I found execCommand to apply simple formats (bold, italic...) to text. Is there a command to pass to execCommand for applying a style through a class attribute to the text? Does anyone know where can I find a reference with all the possible commands to execCommand? And also a reference to what is standard and what is...
0
1506
by: SAL | last post by:
Below is my javaScript function that I am having trouble with. When I set the bUserInterface parameter to FALSE in the follow statement, "document.execCommand("CreateLink","false", oSource)", the dialog window should NOT come up because I have supplied the URL for it from my oSource parameter I past to my function. Can anyone tell me why it's not working? I found this example here:...
23
7682
by: abdalimohd | last post by:
hi all, i m developing an html editor for my web page since i cannot trace out the enter key press for the available html editors for asp.net app. now i have done everything that i need with this editor but the execCommand doesnt work with IE, it works perfectly with FF. when i alerted myEditor.document.queryCommandEnabled('Bold') i get false for IE where myEditor is the Iframe id which is used in editable mode. please help me... i will...
1
4902
by: appleseed | last post by:
I'm having some problems on IE with a small editor I'm building. The source of the problem is the following: Consider having an iFrame with designMode="on" in which you select some text. When clicking anywhere in the page (outside de iframe), the iFrame looses focus and selection. However, this doesn't happen for images. When clicking on images the iFrame keeps its focus. So, all my toolbar buttons (Bold, Italic, OL, UL... s.o.) that have...
0
8471
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
8388
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
8907
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
8817
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
7423
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
6218
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
5687
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
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

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.