我一直在過去的一個小時內一直在努力。如何將文檔實例轉換爲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