openxml-sdk

copying openXML image from one document to another

梦想与她 提交于 2019-12-07 13:11:23
问题 We have conditional Footers that INCLUDETEXT based on the client: IF $CLIENT = "CLIENT1" "{INCLUDETEXT "CLIENT1HEADER.DOCX"}" "" Depending on our document, there could be a varying amount of IF/ELSE , and these all work correctly for merging the correct files in the correct place. However, some of these documents may have client specific images/branding, which also need to be copied across from the INCLUDETEXT file. Below is the method that is called to replace any Picture elements that exist

Adding multiple Cells to a single Row

瘦欲@ 提交于 2019-12-07 11:54:46
问题 I am new to this and when I try to add more than one cell to a row it says there is unreadable content. Here is what I have. SpreadsheetDocument ssDoc = SpreadsheetDocument.Create(saveFile, SpreadsheetDocumentType.Workbook); // Add a WorkbookPart to the document WorkbookPart workbookPart = ssDoc.AddWorkbookPart(); workbookPart.Workbook = new Workbook(); // Add a WorksheetPart to theWorkbookPart WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>(); worksheetPart.Worksheet =

OpenXml: Convert an XElement to an OpenXmlElement

喜欢而已 提交于 2019-12-07 05:28:40
问题 How would I go about converting an XElement to an OpenXmlElement ? Either my google-fu fails or this has not been addressed. 回答1: You can convert a given OpenXmlElement to a XElement using the following code: OpenXmlElement el = ...; // Code to get the xml element from your office doc. // Then use XElement.Parse and the OuterXml property. XElement xel = XElement.Parse(el.OuterXml); To convert an XElement to an OpenXmlElement try the following code: XElement xe = ...; using(StreamWriter sw =

programaticaly embedding Font Family in .docx file

核能气质少年 提交于 2019-12-06 13:36:25
I am trying to insert the font family (not system fonts) in the docx file. I am using openxml-sdk to achieve this functionality. Somehow I am able to get the font information from a particular docx file. But not able to embed the font family in the document Is it possible to embed the font in a docx file using code? Yes, it trivial for docx. MS Word have check-box for that [ http://www.howtogeek.com/howto/microsoft-office/embed-true-type-fonts-in-word-and-powerpoint-2007-documents/] . To do this programmatically, investigate first simple DOCX with and without font, and compare the differences.

How change excel 2007 document orientation to landscape by OpenXML sdk

岁酱吖の 提交于 2019-12-06 11:22:48
I need help with changing excel 2007 document orientation to landscape. I have not found any helpful information about this. I am using OpenXML SDK for this. The only thing I have found: when I create a new Worksheet I should set PageSetup() { Orientation = OrientationValue.Landscape}; But this doesn't help. Can anybody help with this problem? Thank you. You're on the right track with the OrientationValue.Landscape. You just need to loop through all worksheets and set the orientation attribute on the PageSetup element in order to set all worksheets to landscape: public static void SetLandscape

Converting from 'WordOpenXML' to In-Memory System.IO.Packaging.Package

丶灬走出姿态 提交于 2019-12-06 08:06:21
When using VSTO 2012 to manipulate an MS Word Document, I see that the document has a 'WordOpenXML' string property, which is an XML representation of all the files constituting the .docx package which would be saved to disk when saving this Word document as a .docx. I want to convert this string to an equivalent System.IO.Packaging.Package object in memory . The SO question here is very similar. Indeed, the OP even mentions 'in memory' in his question. However, the answers given involve saving the Package to disk using the System.IO.Packaging.ZipPackage.Open method. I do not want to save the

Defining paragraph with RTL direction in word file by OpenXML in C#

流过昼夜 提交于 2019-12-06 07:16:50
问题 How to set the right-to-left direction for a paragraph in word with OpenXML in C#? I use codes below to define it but they won't make any change: RunProperties rPr = new RunProperties(); Style style = new Style(); style.StyleId = "my_style"; style.Append(new Justification() { Val = JustificationValues.Right }); style.Append(new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft }); style.Append(rPr); and at the end I will set this style for my paragraph: ... heading_pPr

Corrupt document after calling AddAlternativeFormatImportPart using OpenXml

喜你入骨 提交于 2019-12-06 03:37:35
问题 I am trying to create an AddAlternativeFormatImportPart in a .docx file in order to reference it in the document via an AltChunk. the problem is that the code below causes the docx file to read as corrupted by Word and cannot be opened. string html = "some html code." string altChunkId = "html234"; var document = WordprocessingDocument.Open(inMemoryPackage, true); var mainPart = document.MainDocumentPart.Document; var mainDocumentPart = document.MainDocumentPart; AlternativeFormatImportPart

How do I unlock a content control using the OpenXML SDK in a Word 2010 document?

﹥>﹥吖頭↗ 提交于 2019-12-06 02:13:39
问题 I am manipulating a Word 2010 document on the server-side and some of the content controls in the document have the following Locking properties checked Content control cannot be deleted Contents cannot be edited Can anyone advise set these Locking options to false or remove then altogether using the OpenXML SDK? 回答1: The openxml SDK provides the Lock class and the LockingValues enumeration for programmatically setting the options: Content control cannot be deleted and Contents cannot be

How to replace an Paragraph's text using OpenXML Sdk

不羁的心 提交于 2019-12-05 23:26:04
问题 I am parsing some Openxml word documents using the .Net OpenXml SDK 2.0. I need to replace certain sentences with other sentences as part of the processing. While iterating over the paragraphs, I know when I've found something I need to replace, but I am stumped as to how I can replace it. For example, lets say I need to replace the sentence "a contract exclusively for construction work that is not building work." with a html snippet to a Sharepoint Reusable content below. <span class="ms