Edited 3 Years Ago by Ketsuekiame

Comments
pls, can you help me.. have done the one for .txt but my c# form has got a .jpg picture that i want it to show in the file...

Word files is not as easy as to write a text to a .txt file. You need an Office open XML API to write create a word file. Here is a link to the API:

Click Here

Comments
pls, can you help me.. have done the one for .txt but my c# form has got a .jpg picture that i want it to show in the file...

You can also use the following code...

            SqlCommand cmd = new SqlCommand("select * from sps_login", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            con.Close();
            GridView1.DataSource = ds;
            GridView1.DataBind();

            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.doc");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-word ";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            GridView1.AllowPaging = false;
            GridView1.DataBind();
            GridView1.RenderControl(hw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();

Hope it helps you...

Have a happy coding...:-D

Comments
no, it's not helping i need to create microsoft word file....

Are you developing a windows application or web application? @timmyjoshua

I am asking that because, I also used the similiar code as @ss125 posted in the above post. Its used for the web application. If you want a windows application code, you have to mention that in your question itself.

Edited 3 Years Ago by saguni: necessary

Comments
yes, i see it not dsame.. i'm developing windows app...
This question has already been answered. Start a new discussion instead.