如何显示在asp.net web表单word文件 [英] How to display word file in web form in asp.net

查看:108
本文介绍了如何显示在asp.net web表单word文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作职位门户website.In的是,我有求职者登记form.In的求职者上传resume.I只有现在的储蓄在当地folder.In其它Web数据库和实际的恢复恢复的文件名形式,我想显示div标签的简历就像naukri.com的更新/查看profile.So我怎么能做到这一点?
我可以从数据库中检索的简历文件名。
所以,请任何一个建议我任何解决方案。
先谢谢了。


解决方案

  //如何创建一个新包为Word文档。
公共静态无效CreateNewWordDocument(字符串文件)
{
   使用(Wordpro​​cessingDocument wordDoc = Wordpro​​cessingDocument.Create(文件,Wordpro​​cessingDocumentType.Document))
   {
      //设置文件的内容,这样Word可以打开它。
      MainDocumentPart mainPart = wordDoc.AddMainDocumentPart();      SetMainDocumentContent(mainPart);
   }
}// MainDocumentPart集的内容。
公共静态无效SetMainDocumentContent(MainDocumentPart部分)
{
   常量字符串docXml =
@&下; XML版本=1.0编码=UTF-8,独立=是&GT?;
< W:文档的xmlns:W =http://schemas.openxmlformats.org/wordpro​​cessingml/2006/main>
    < W:身体GT;< W:P>< W:R>< W:!T>世界,你好< / W:T>< / W:R>< / W:P>< / W:身体GT;
< / W:文件>中;    使用(流流= part.GetStream())
    {
       。字节[] buf中=(新UTF8Encoding())GetBytes会(docXml);
       stream.Write(BUF,0,buf.Length);
    }
}

这花去 这里

这里

I am working on job portal website.In that,I am having job-seeker registration form.In that job-seeker upload resume.I am saving only resume file name in database and actual resume in local folder.In another web form ,I want to show resume in div tag just like in naukri.com's update/view profile.So how i can do this? I can retrieve the resume file name from database. so,please any one suggest me any solution. Thanks in advance.

解决方案

// How to: Create a new package as a Word document.
public static void CreateNewWordDocument(string document)
{
   using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(document, WordprocessingDocumentType.Document))
   {
      // Set the content of the document so that Word can open it.
      MainDocumentPart mainPart = wordDoc.AddMainDocumentPart();

      SetMainDocumentContent(mainPart);
   }
}

// Set content of MainDocumentPart.
public static void SetMainDocumentContent(MainDocumentPart part)
{
   const string docXml =
@"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>
<w:document xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main"">
    <w:body><w:p><w:r><w:t>Hello world!</w:t></w:r></w:p></w:body>
</w:document>";

    using (Stream stream = part.GetStream())
    {
       byte[] buf = (new UTF8Encoding()).GetBytes(docXml);
       stream.Write(buf, 0, buf.Length);
    }
}

Took from here

Another nice tutorial from here

这篇关于如何显示在asp.net web表单word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆