how to display word file after upload in asp.net and c#

Posted by reddysankark-13471 under ASP.NET on 9/27/2012 | Points: 10 | Views : 8619 | Status : [Member] | Replies : 4
hi,

how to display wordfile after upload .in naukri website we can upload any resume it shows that resume how to do that in asp.net

sankarreddy


Responses

Posted by: Megan00 on: 9/28/2012 [Member] Starter | Points: 25

Up
0
Down
I think you can try below code:
private void button1_Click(object sender, EventArgs e)

{
//Create word document
Document document = new Document();
document.LoadFromFile(@"D:\Sample.doc");
//Save doc file.
document.SaveToFile("Sample.html", FileFormat.Html);
//Launching the MS Word file.
WordDocViewer("Sample.html");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}

this requires a .net word component, it supports asp.net.
http://www.e-iceblue.com/Download/download-word-for-net-now.html


Never give up! Smile to the world!
http://excelcsharp.blog.com/

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sebas on: 6/13/2013 [Member] Starter | Points: 25

Up
0
Down
I can suggest you to try a special .NET component to convert word file to html string and display it on asp.net page.
I put some example for you:

on .aspx page:
<table width="100%">

<tr>
<td>
Select WORD file to display:<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:Button ID="Button1" runat="server" Text="Convert" onclick="Button1_Click" />
</td>
</tr>
<tr>
<td>
<div id="report_container" runat="server"></div>
</td>
</tr>
</table>


in .cs file:

using Docs.Word;
using System.IO;

protected void Button1_Click(object sender, EventArgs e)
{
Document doc = null;
string name = Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName);
string ext = Path.GetExtension(FileUpload1.PostedFile.FileName);
try
{
switch (ext.ToLower())
{
case ".docx": doc = Document.ReadDOCX(FileUpload1.PostedFile.InputStream); break;
case ".doc": doc = Document.ReadDOC(FileUpload1.PostedFile.InputStream); break;
case ".rtf": doc = Document.ReadRTF(FileUpload1.PostedFile.InputStream); break;
case ".txt": doc = Document.ReadTXT(FileUpload1.PostedFile.InputStream); break;
default: report_container.InnerHtml = "Please select docx, doc or rtf file"; return;
}
}
catch (Exception ex)
{
report_container.InnerHtml = ex.Message;
return;
}
report_container.InnerHtml = doc.WriteHTML(System.Text.Encoding.ASCII);
}

link to the component:
http://www.eleriumsoft.com/Word_NET/WORD2HTML/Default.aspxhttp://www.eleriumsoft.com/Word_NET/WORD2HTML/Default.aspx

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: erashishkansal-22737 on: 6/21/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

How can i attach DLL for Docs.Word. Because i have already searched a lot in the ADD REFERENCE section. And i have also searched on google but i din't get appropriate answer.

Please solve my problem.

@$H!$H K@N$@L

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sebas on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
Sorry for late answer. To attach DLL for Docs.Word you need to download component from
http://www.eleriumsoft.com/Word_NET/WORD2HTML/Default.aspx
Then you need to put dll into /bin directory of your asp.net project.

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response