Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Online Members
naveensanagasetti
Arvind kumar
imran
Gaurav
shalini rathore
Narendra Reddy vajrala
More...
Resources
»
.NET programming
»
ASP.NET/Web Applications
Open Word and Excel files using Javascript
Posted Date:
02-Jan-2012
Category:
ASP.NET/Web Applications
Author:
Prasad kulkarni
Member Level:
Diamond
Points
: 15
Many times, we need to open files on Client side. Scripting languages played a strong role in such activities. here we used word and excel automation to open file using javascript. This is called client side automation technique.
Open Word and Excel files using Javascript
Background
Background behind this article is bit interesting, we have a project in ASP.NET, which open word and excel files on client machine.
and then user can make changes in it. Team members thought, can't we open file using Javascript ? and the answer was "yes, we can but we need some code to try"
and after some trial and error we got small piece of code in javascript, that will open word and excel file in javascript with automation object.
Javascript is one of the most powerful scripting language that allows you to create word and excel object.
why not window.open() ?
window.open() in javascript will let you open word and excel file, but it's open in
browser
not it in's own editor.
to avoid this we have to use automation with javascript
Let's cook
Write a function in javascript and call it on button click in asp.net.
for e.g. in following code i have take "open file" button and call function javascript function
openFile()
on it.
Here we used ActiveX to create word and excel object
Write a javascript function to open file : WINWORD
Check following javascript function. to create word object
Write a javascript function to open file : EXCEL
Check following javascript function.
Possible exception
when we deal with
ActiveX
, most of the time security issue are lift.
and if you run above code may be your browser gives you following error
To over come this we have to chnage the browser settings.
we have to tell browser to initialiaze and run activex controls.
change the browser setting.
InternetExplorer --> Tools --> InternetOntions --> Security --> Custom Level
Limitations
This article opens Word/Excel using ActiveX object and unfortunately, these AciveX Plugins are only supported by Internet Explorer (tested on IE6/7/8).
These objects are used to create instances of OLE Automation. Several applications (Microsoft Office Word, Microsoft Office Excel, Windows Media Player, ...)
provide OLE Automation objects to allow communication with them.
You can use the methods and properties supported by Automation objects in JavaScript.
Client side automation is a good alternative to server side automation. Server side automation is not recommended by Microsoft itself,
check article
Thanking you
Suggestions and Queries are always welcome.
Did you like this resource? Share it with your friends and show your love!
Tweet
Responses to "Open Word and Excel files using Javascript"
No responses found. Be the first to respond...
Feedbacks
Post Comment:
Notify me by email when others post comments to this article.
Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
No HTML formatting and links to other web sites are allowed.
This is a strictly moderated site. Absolutely no spam allowed.
Name:
Sign In
to fill automatically.
Email:
(Will not be published, but
required
to validate comment)
Type the numbers and letters shown on the left.
Next Resource:
ASP.NET Control Extenders
Previous Resource:
Calling server side method by using Java Script.
Return to Resources
Post New Resource
Category:
ASP.NET/Web Applications
Post resources and
earn money
!
More Resources
ASP.NET Control Extenders
List out the .pdf files from the directory and display in ASP.NET Gridview
JavaScript Object Constructor
ClientIDMode Property in ASP.Net
ADO.Net - SqlCommand Object
Using jQuery Code to Work with ASP.Net Controls
Popular Tags
Tag posting guidelines
Search Tags
Open Word and Excel files using Javascript
.
Active Members
Today
Pawan Awasthi
(18)
Prasad kulkarn...
(6)
sathishkumar.G...
(5)
Last 7 Days
naveensanagase...
(207)
Naved Hasan ...
(191)
baskar
(169)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds
Talk to Webmaster Tony John