我一直在过去的一个小时内一直在努力。如何将文档实例转换为FileStream
有人可以帮我将Microsoft.Office.Interop.Word.Document的一个实例转换为FileStream吗?我有这个功能,下面不工作,但可能会帮助你们有什么即时试图做一个想法:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Microsoft.Office.Interop.Word;
using System.IO;
namespace DropDownTemplate.Web.WebServices.Word
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "WordGenerator" in code, svc and config file together.
public class WordGenerator : IDocumentGenerator
{
FileStream IDocumentGenerator.GenerateDocument()
{
// For optional parameters create a missing object
object missing = System.Reflection.Missing.Value;
// open the document specified in the fileName variable
Document adoc = new Document();
adoc.InlineShapes.AddPicture(@"http://localhost:2014/Resources/MG.PNG", ref missing, ref missing, ref missing);
using (StreamReader y = new StreamReader())
{
y.Read(adoc);
}
return adoc;
}
}
}
不确定要明白你想要做什么。你有一个文件,你想要它的内容在二进制文件? – 2012-01-18 09:02:22
对不起,这里的代码伙计只是一个新手:(...我想创建一个Word文档,并以FileStream格式发送回Web服务.... – 2012-01-18 09:03:37
从来没有这样做,但可能的解决方案是:1。生成文档2.保存到临时文件3.返回临时文件的内容我不确定你可以直接返回一个FileStream,除非你设置你的服务使用流媒体 – 2012-01-18 09:09:01