如何使用“保存文件"对话框保存Wordfile [英] how to save wordfile using save file dialog box

查看:113
本文介绍了如何使用“保存文件"对话框保存Wordfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多行文本框.我想使用保存"对话框将该文本另存为word文件(.docx).

预先感谢.

Hi i have a one multilined text box.i want to save that text as a word file(.docx) using save dialog box.

Thanks in advance.

推荐答案

hai shrivastava,

在运行时动态创建一个word文件(.docx),并在编码中将文本作为文本框内容添加..

请参考
============
http://support.microsoft.com/kb/316384

http://msdn.microsoft.com/zh-cn/library/aa192483(v=office.11​​).aspx
hai shrivastava,

create a word file(.docx) dynamically in runtime and add text as textbox content in coding ..

refer this
=============
http://support.microsoft.com/kb/316384

http://msdn.microsoft.com/en-us/library/aa192483(v=office.11).aspx


您不能通过保存对话框 [ ^ ].该对话框仅允许您的用户确定将内容保存在其中的文件的位置和名称.您仍然必须将内容转换为正确的格式,然后将其写入所选的文件中.看看字词互操作 [ ^ ]库,以获取有关创建doc/docx文件的信息.
You cannot save a text file as a word document through a save dialog[^]. The dialog merely allows your user to decide the location and name of the file that your content will be saved in. You must still convert the content into the correct format and then write it into the file selected. Take a look at the Word Interop[^] library for information on creating doc/docx files.


<asp:textbox id="txtDescription" runat="server" textmode="MultiLine" height="100" xmlns:asp="#unknown">
            Width="280"></asp:textbox>
        <asp:linkbutton id="lb_Download" runat="server" text="Download file" onclick="lb_Download_Click" xmlns:asp="#unknown"></asp:linkbutton>







protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtDescription.Text = "lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
        }
    }
    protected void lb_Download_Click(object sender, EventArgs e)
    {
        string strContents = null;
        strContents = txtDescription.Text;

        string attachment = "attachment; filename=test.doc";
        Response.ClearContent();
        Response.ContentType = "application/doc";
        Response.AddHeader("content-disposition", attachment);
        Response.Write(strContents);
        Response.End();
    }


这篇关于如何使用“保存文件"对话框保存Wordfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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