reading doc file apart from using mircorsoft word object library
I want to allow download facilities for doc files but dynamically have to add clients name but without using microsoft word object library. Here is the secnario:-
1) Download Link 2) clicking upon which it should be starting to downloading the doc file which i have kept at my shared location on my server. 3) before downloading, it should actually insert registered clients name in that doc file and then allow him to download.
the doc file stored at shared location is without c开发者_运维问答lients name but with a blank so to fill up the clients name dynamically.
but without using microsoft word 12.0 object library
Can this be possible ? if yes then how to go about.
protected void B1(object s, EventArgs e)
{
if (FileUpload1.HasFile)
{
string FTSI = @"c:\temp\doc\";
string FP = folder_to_save_in + FileUpload1.FileName;
FileUpload1.SaveAs(FP);
Word.ApplicationClass wordApplication = new Word.ApplicationClass();
object oNO = System.Reflection.Missing.Value;
object oFP = FP;
Word.Document doc = wordApplication.Documents.Open(ref oFP,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO);
string newfilename = folder_to_save_in + FileUpload1.FileName.Replace(".doc", ".html");
object oNF = newfilename;
object oFR = Word.WdSaveFormat.wdFormatHTML;
object oEN = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
object oEN = Word.WdLineEndingType.wdCRLF;
wordApplication.ActiveDocument.SaveAs(ref oNF, ref oFR, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO);
Label1.Text = "Uploaded file successfully!";
doc.Close(ref oNO, ref oNO, ref oNO);
}
}
精彩评论