EPPlus with OpenXML and streams
I am trying to automate a Powerpoint presentation. I am using OpenXML to navigate the powerpoint presentation up to the point that I find the Excel linked to a chart. Now I want to use EPPlus to load a datatable into one of the worksheets (because EPPlus has a simple LoadFromDataTable function whereas I think I would have to write lots of code to use OpenXML). So my problem is this.
I have a PresentationDocument in memory. And I have navigated to the particular chart that I want to manipulate via doc.PresentationPart.SlideParts.ElementAt(0).ChartParts.ElementAt(0)
I get the Excel part using var stream = chartpart.EmbeddedPackagePart.GetStream(). Then I tried
using(var pck = new ExcelPackage(stream)){ do stuff;
pck.Save(); }
and then at the end I do a doc.PresentationPart.Presentation.Save
but this hasn't changed the Presentation. I can change it using OpenXML instead - with using (var xl = Spreadsheet.Document.Open(stream, true)) { do stuff;
xl.Close(); }
with everything else the same. So I guess either xl.Close() is doing stuff that pck.Save() isn't or I am using the stream incorrectly - can anyone advise?
thanks Phil
链接地址: http://www.djcxy.com/p/72036.html上一篇: AVAssetWriter输入H.264直通至QuickTime(.mov)
下一篇: 带OpenXML和流的EPPlus