梁子铭 发表于 2016-12-6 11:50:00

点击按钮,利用serverTextControl导出文件

这段代码数据库读取到的二进制数据,已经实现在TextControl展示已经存在的二进制数据,点击导出产品到文件按钮时候,如何利用serverTextControl导出到文件?求官人给小女子指点:'(:'(:'(

梁子铭 发表于 2016-12-6 11:55:57

要是导出过程有进度条显示就更好了:victory:

gw0506 发表于 2016-12-7 09:00:16

protected void Button1_Click(object sender, EventArgs e)
{
        // create a new instance of ServerTextControl
        using (TXTextControl.ServerTextControl tx =
                new TXTextControl.ServerTextControl())
        {
                // load the document
                tx.Create();
                tx.Load(Server.MapPath("/documents/sample.docx"),
                        TXTextControl.StreamType.WordprocessingML);

                // save the document in the internal format to a byte array
                byte[] data;
                tx.Save(out data, TXTextControl.BinaryStreamType.InternalUnicodeFormat);

                // load the byte array into the read-only DocumentViewer
                DocumentViewer1.LoadDocumentFromMemory(data,
                        TXTextControl.DocumentServer.FileFormat.InternalUnicodeFormat);
        }

        btn_DownloadDocument.Visible = true;
}

梁子铭 发表于 2016-12-7 11:30:51

gw0506 发表于 2016-12-7 09:00


为什么要用tx.Load()加载服务器物理地址下的实例文档?

gw0506 发表于 2016-12-7 12:00:40

梁子铭 发表于 2016-12-7 11:30
为什么要用tx.Load()加载服务器物理地址下的实例文档?

你可以不用,你如果已经把数据给到textcontrol了就不用了。
给你就是意思他本身还有load接口,也可以穿数组参数。

梁子铭 发表于 2016-12-7 12:06:11

gw0506 发表于 2016-12-7 12:00
你可以不用,你如果已经把数据给到textcontrol了就不用了。
给你就是意思他本身还有load接口,也可以穿 ...

意思是serverTextControl和textcontrol的数据可以共用的吗?

gw0506 发表于 2016-12-7 12:51:52

我说的就是servertextcontrol,省事,少打了几个字。不过tx和servertx数据是可以共用。
页: [1]
查看完整版本: 点击按钮,利用serverTextControl导出文件