Malt.Reporting.OpenDocument.OdfTemplate.GetEntryOutputStream C# (CSharp) Method

GetEntryOutputStream() public method

千万要记得关闭
public GetEntryOutputStream ( string entryPath ) : Stream
entryPath string
return Stream
        public override Stream GetEntryOutputStream(string entryPath)
        {
            if (string.IsNullOrEmpty(entryPath))
            {
                throw new ArgumentNullException("entryPath");
            }

            var oms = new OutputMemoryStream(entryPath, this.entries);
            this.entries[entryPath] = oms.ToArray();

            return oms;
        }

Usage Example

Example #1
0
        public override IDocument Render(IDictionary<string, object> context)
        {
            Debug.Assert(this.engine != null);

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var resultDoc = new OdfTemplate();
            this.CopyTo(resultDoc);

            var userImages = new Dictionary<Image, string>();

            this.ResetTextEngine(userImages, resultDoc);

            using (var inStream = this.GetEntryInputStream(this.MainContentEntryPath))
            using (var reader = new StreamReader(inStream, Encoding.UTF8))
            using (var ws = resultDoc.GetEntryOutputStream(resultDoc.MainContentEntryPath))
            using (var writer = new StreamWriter(ws))
            {
                this.engine.Evaluate(context, reader, writer);
            }

            return resultDoc;
        }