Tuesday, September 27, 2011

Read, Edit and Create Microsoft Word documents in asp.net using docX

Microsoft word is mostly used in web applications. It is very easy to edit MS word documents on the server using docx.dll.
Docx is a .NET Library which allows word 2007 manipulation. You can download it from codeplex.

Create a web form containing a fileupload, Textbox and two buttons, one for upload and second for editing and saving the document. The code is below:
Source Code:
Upload CV
In the btnUpload event handler we write the code for saving the word file on the server and display it in the textbox with the help of docX.
Code behind:
protected void btnUpload_Click(object sender, EventArgs e)
    if (FileUpload1.HasFile == true)
        if ( System.IO.Path.GetExtension(FileUpload1.FileName)==".docx" )
            FileUpload1.SaveAs(Server.MapPath("~\\CVs\\") + 
            this.lblupload.Text = "CV successfully uploaded";                
            DocX doc = DocX.Load(Server.MapPath("~\\CVs\\") + FileUpload1.FileName);      
            \\ Created a Docx variable doc and using Docx.Load("word file") to load the word 2007 file                         
            txtWord.Text = doc.Text; 
            \\Set the text property of doc to textbox text property. Text property of doc returns all the text from the word document.               
On the btnSave eventhandler we have deleted the previous word file and created a new word document and apply simple formatting and then put the content from textbox in the new word document and finally save it.
Code for saving edited data:
protected void btnSave_Click(object sender, EventArgs e)
         FileInfo file = new FileInfo(MapPath("~\\CVs\\") + 
         if (file.Exists)
             File.Delete(MapPath("~\\CVs\\") + ViewState["CV"].ToString());
             \\ Delete existing word file
             DocX doc = DocX.Create(Server.MapPath("~\\CVs\\") +
             \\ Create a new word document            
             Formatting f = new Formatting();
             f.FontFamily = new FontFamily("Tahoma");
             \\Defines font family

With DocX it's very easy to play with word files but it supports only .docx format.
Any question or suggestion is appreciable.

Waqar Farooq Janjua

Sunday, September 18, 2011

Solution of Android Error: invalid command-line parameter

Android Error:
invalid command-line parameter: Files.
Hint: use '@foo' to launch a virtual device named 'foo'.
please use -help for more information

The problem is due to the spaces in the path of android sdk.

For Windows XP:
If android SDK is located at C:\Program Files\Android\android-sdk
Then you should change the path to C:\PROGRA~1\Android\android-sdk  in the preferences of ECLIPSE IDE.

For Windows 7(64-bit):
In window 7 there are two program files folders. Program Files and Program Files (x86). Android is installed at Program Files (x86) because android SDK is a 32-bit.
In window 7 SDK is located at C:\Program Files (x86)\Android\android-sdk
then you have to change the path to C:\PROGRA~2\Android\android-sdk

Hope it helps.

Saturday, September 17, 2011

What is Sharepoint Server 2010

Sharepoint Server was first released in 2001 as Sharepoint portal server 2001, also in the same year Microsoft launched a content Managemet Server 2001 (CMS) . In 2003, Microsoft launched Sharepoint portal server 2003 as well as an updated version of Content Management Server. These products were ultimately combined to become Microsoft Office Sharepoint server 2007 ( MOSS ) in late 2006.

What is SharePoint 2010?
Sharepoint 2010 is a fully integrated platform that is made up of the best bits of many tried-and-tested products. 
SharePoint 2010 platform is the .NET Framework with a whole host of reusable application services such as content management, business intelligence, offline synchronization and workflow.
SharePoint is more than a document management tool, a content management tool, or an application that allow users to create collaborative websites. Behind all of this, Sharepoint is a new kind of operating system that runs accross an entire organisation and provides the tools and services that information workers needed on a day-to-day basis.

Monday, April 18, 2011


Jquery is a JavaScript library which helps you in accessing and manipulating HTML elements. It is an open source library which works with every browser.It simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development