openxml-sdk

Embed contents of a RTF file into a DOCX file using OpenXML SDK

陌路散爱 提交于 2019-12-04 01:38:59
In our old MSWord-97 based system we use COM to interact with a .doc file, and embed an OLE object, so the embedded document is visible in the parent (not as an icon). We're replacing this with a system using OpenXML SDK since it requires having Word on our server, which generates .docx files. however we still need to embed the contents of RTF files into the generated DOCX... specifically we replace a bookmark with the contents of the file. I found a few examples online but they all differ. When I create a simple example in Word and view the XML, there's a lot of stuff to position/display the

How to insert a date to an Open XML worksheet?

别说谁变了你拦得住时间么 提交于 2019-12-04 00:21:29
I'm using Microsoft Open XML SDK 2 and I'm having a really hard time inserting a date into a cell. I can insert numbers without a problem by setting Cell.DataType = CellValues.Number , but when I do the same with a date ( Cell.DataType = CellValues.Date ) Excel 2010 crashes (2007 too). I tried setting the Cell.Text value to many date formats as well as Excel's date/numeric format to no avail. I also tried to use styles, removing the type attribute, plus many other pizzas I threw at the wall… Can anyone point me to an example inserting a date to a worksheet? Andrew J You have to convert

Open xml replace text from word file and return memory stream using MVC

拜拜、爱过 提交于 2019-12-03 20:57:59
I have an word file that contain my specified pattern text {pattern} and I want to replace those pattern with new my string which was read from database. So I used open xml read stream from my docx template file the replace my pattern string then returned to stream which support to download file without create a temporary file. But when I opened it generated me error on docx file. Below is my example code public ActionResult SearchAndReplace(string FilePath) { MemoryStream mem = new MemoryStream(System.IO.File.ReadAllBytes(FilePath)); using (WordprocessingDocument wordDoc =

Error while creating open XML excel sheet from ASP.NET MVC

老子叫甜甜 提交于 2019-12-03 20:57:01
I am trying to export an Excel sheet from ASP.NET MVC4 using Open XML SDK 2.5. I am trying to use standard example from MSDN, extention = "xlsx"; response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; response.AddHeader("Content-Disposition",String.Format("attachment; filename={0}.{1}", fileName, extention)); using (MemoryStream mem = new MemoryStream()) { // Create a spreadsheet document by supplying the filepath. // By default, AutoSave = true, Editable = true, and Type = xlsx. SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(mem,

Adding to WordprocessingDocument opened from MemoryStream without getting “Memory stream is not expandable”?

左心房为你撑大大i 提交于 2019-12-03 17:38:18
Using Open XML SDK, the following gives "Memory stream is not expandable" when I reach the line FeedData(msData): // Bytes in, bytes out internal static byte[] UpdateDataStoreInMemoryStream(byte[] bytes, XmlDocument xdocData) { using (var msDoc = new MemoryStream(bytes)) { using (WordprocessingDocument wd = WordprocessingDocument.Open(msDoc, true)) { MainDocumentPart mdp = wd.MainDocumentPart; CustomXmlPart cxp = mdp.CustomXmlParts.SingleOrDefault<CustomXmlPart>(); using (MemoryStream msData = new MemoryStream()) { xdocData.Save(msData); msData.Position = 0; // Replace content of ...\customXml

Open XML SDK - Adding a macro programatically to a Word 2007 document

心已入冬 提交于 2019-12-03 16:33:47
I am trying to dynamically add a new custom ribbon in a Word 2007 document following teh manual method described in this article :- http://msdn.microsoft.com/en-us/library/aa338202(v=office.12).aspx . The article specifies the following :- a) Create a XML file named customUI.xml which will contain the elements you want to display in the tab and put the same in a folder named customUI. b) Rename your Word 2007 document to .zip. Add the above "customUI" folder to the zip file. c) Add the following relationship to the "_rels/rels" file in the .zip file :- <Relationship Type="http://schemas

How to parse mathML in output of WordOpenXML?

*爱你&永不变心* 提交于 2019-12-03 15:12:55
I want to read only the xml used for generating equation, which i obtained by using Paragraph.Range.WordOpenXML . But the section used for the equation is not as per MathML which as i found that the Equation of microsoft is in MathML . Do I need to use some special converter to get desired xmls or are there any other methods? Hans You could use the OMML2MML.XSL file (located under %ProgramFiles%\Microsoft Office\Office15 ) to transform Microsoft Office MathML (equations) included in a word document into MathML . The code below shows how to transform the equations in a word document into MathML

How to include the reference of DocumentFormat.OpenXml.dll on Mono2.10?

女生的网名这么多〃 提交于 2019-12-03 14:33:22
问题 I am using C#.net Windows Desktop Application.I want to run these application with other platform also. So, i am using Mono 2.10 as a cross compiler.While running,unexpectedly my Application is terminated by saying the error message like Error:Could not open the selected folder. Could not load a file or assembly 'DocumentFormat.OpenXml.dll,version=2.0.5022.0, culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. I don't know what is problem here...I have installed

.NET OpenXML performance issues

时光毁灭记忆、已成空白 提交于 2019-12-03 13:19:58
I am attempting to write out an Excel file from an ASP.NET web server using OpenXML. I have about 2100 records and its taking around 20-30 seconds to do this. Any way I can make it faster? Retrieving the 2100 rows from the db takes a fraction of a second. Not sure why manipulating them in memory would take any longer. Note: ExcelWriter is our custom class, but all its methods are directly from code in this link, http://msdn.microsoft.com/en-us/library/cc861607.aspx public static MemoryStream CreateThingReport(List<Thing> things, MemoryStream template) { SpreadsheetDocument spreadsheet =

Generate a Word document (docx) using data from an XML file / Convert XML to a Word document based on a template

戏子无情 提交于 2019-12-03 11:17:30
问题 I have an XML file with the data that I need to be populated on a Word document. I need to find a way, to define a template which can be used as a base line to populate data from an XML file and create an output document. I believe there are two ways to do this. Create an XSLT file which will be the "template" and use this to generate Word documents using it in conjunction with the XML file. Use content controls in Word to create a template document and somehow map to an XML file. I just don