Hi friends,
I want to build a asp.net program where resumes in word format will be uploaded and after reading that word file,it will show that in browser like in monster or naukri, where resumes are shown on browser after uploading.But i want to do it without adding any reference of com component.
Please help..
Loading
sanjib mukherjeePosted Mar 18, 2011, 7:55 AM
Can't we do it in any other way,using any lighter process.
I have tried with regex, below is my code:
HTMLCode = HTMLCode.Replace("\r", " ");
HTMLCode = HTMLCode.Replace("\n", " ");
HTMLCode = HTMLCode.Replace("\t", " ");
HTMLCode = HTMLCode.Replace("\0", " ");
HTMLCode = Regex.Replace(HTMLCode, "\\s*", " ");
HTMLCode = Regex.Replace(HTMLCode, @"[^\w\.@-]", "");
// Remove multiple white spaces from HTML
String Pattern="[^a-zA-Z0-9 ]";
Regex oRegex = new Regex(Pattern, RegexOptions.IgnoreCase);
MatchCollection matches = oRegex.Matches(HTMLCode);
//Text = oRegex.Replace(Text, "");
//HTMLCode = oRegex.Replace(Text, "");
//Regex oRegex=new Regex(pattern,RegexOptions.IgnoreCase);
//MatchCollection matches=oRegex.Matches(HTMLCode);
//HTMLCode = oRegex.Replace(HTMLCode, "");
StringBuilder sbHTML = new StringBuilder();
for (int i = 0; i
//if ((HTMLCode[i] >= '0' && HTMLCode[i] <= '9') || (HTMLCode[i] >= 'A' && HTMLCode[i] <= 'z') || (HTMLCode[i] == '.' || HTMLCode[i] == '_'))
//{
// sbHTML.Append(HTMLCode[i]);
//}
Match m = matches[i];
if (m.Success)
{
if (m.Value != "@")
{
HTMLCode = HTMLCode.Replace(m.Value, " ");
}
}
}
But this code also not able to show proper data.Some meta data of word document wth junk values are showing.Is their any pattern in regex which will replace this kind of junk values.Or any other process?
Please help.
Vijay YadavPosted Mar 18, 2011, 7:33 AM
sanjib mukherjeePosted Mar 18, 2011, 7:20 AM
I had set permissions also but still did not work.
Vijay YadavPosted Mar 18, 2011, 7:15 AM
All you have to do it is to add reference in your application named Microsoft.Office.Interop.Word
and then by using this namspace using Microsoft.Office.Interop.Word;
you can write code for it
for example:
Microsoft.Office.Interop.Word.ApplicationClass Application = new Microsoft.Office.Interop.Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object file = "Specify path for word file";
Microsoft.Office.Interop.Word.Document doc = Application.Documents.Open(ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.Activate();
string Doc_Content = doc.Content.Text;
TextBox1.Text = Doc_Content;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
Vijay YadavPosted Mar 18, 2011, 6:36 AM
sanjib mukherjeePosted Mar 18, 2011, 6:12 AM
I am doing all this what you mentioned.Below is the code through which I am trying to read the file and show it but it is reading some junk values also from documents which i am not able to remove.
FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
UTF8Encoding encoding = new UTF8Encoding(true);
StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
string str = sr.ReadToEnd();
Can you please help me to remove those junk values.
Vijay YadavPosted Mar 18, 2011, 6:07 AM
sanjib mukherjeePosted Mar 18, 2011, 5:57 AM
Vijay YadavPosted Mar 18, 2011, 5:55 AM
sanjib mukherjeePosted Mar 18, 2011, 5:42 AM
The exact requirement is uploading a resume and displaying that in proper format in browser.
Vijay YadavPosted Mar 18, 2011, 3:44 AM