openxml

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

Create Excel file with style tag using OpenXmlWriter SAX

半城伤御伤魂 提交于 2019-12-06 07:11:38
I am trying to write an Excel Xlsx spreadsheet with styling using OpenXmlWriter (SAX). I am able to create the file with rows and columns (populate them as strings). I am looking for a simple code on how to make the first row (header) with bold font. I do not have a template file to start with as the file will be dynamic. I found a few articles on how to add WorkbookStylesPart, but they are all using the DOM. As i need to write large number of rows, the DOM will not work for me. Could anyone point me at the right direction? Simple code to add a header row as bold when using WriteStartElement

Parse MathType MTEF data from OLE binary string

可紊 提交于 2019-12-06 07:02:05
问题 There is a need to convert the MathType equations in the MS-WORD 2003 or below to MathML in order to render nicely on the the web. The MathType's built in function "Publish to MathPage" can do the job very nicely, but I want to integrate the equation conversion process in my C# application. Because I couldn't find any API references that the MathPage export interface is provided by the MathType SDK, I need to figure out a way to do the individual equation conversion by myself. The current

Horizontal Text alignment in Word using OpenXml Sdk 2.0

风流意气都作罢 提交于 2019-12-06 06:38:04
问题 I need another help... My export function exports my report as a table in word. I need to apply horizontal alignment property for each cell. The Code I wrote for exporting is given below. Tbl is a textblock which I am using in my report. I wrote Alignment code here. But doesn't works.. Please help me to accomplish this task using OpenXML SDk 2.0 using Word = DocumentFormat.OpenXml.Wordprocessing; WordprocessingDocument WordDoc = WordprocessingDocument.Create(SavePath,

Insert comment in Word using office.js

有些话、适合烂在心里 提交于 2019-12-06 06:02:31
I am trying to make a Word add-in in office.js that inserts comments in the document. It seems to me the only way to achieve this is to use OOXML. I can insert the comment but my problem is that when I do so a paragraph break is inserted as well as can be seen from this image. A far as I can see it boils down to that if I am only inserting some text the content of the body looks like the following which works fine <w:p> <w:r> <w:t>Some text</w:t> </w:r> </w:p> But if I am inserting a reference to a comment it results in a paragraph end right after whatever I am insering. In that case the

Repeating content with Office Open XML

时光怂恿深爱的人放手 提交于 2019-12-06 05:29:47
I've been checking out what is possible with the Office Open XML specification for documents. I'm particularly interested in being able to add custom XML content to a document and binding it to content controls. I was wondering if it is possible to have a repeating content control type? For example, say I have some custom XML in my .docx file that looks like so: <Work> . . <People> <Person> <Name>Jane Doe</Name> <EmailAddress>jane@abc.com</EmailAddress> </Person> <Person> <Name>John Doe</Name> <EmailAddress>john@xyz.com</EmailAddress> </Person> </People> </Work> Is there any repeating content

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

Cell spanning multiple columns in table using python-docx

不打扰是莪最后的温柔 提交于 2019-12-06 03:03:18
I'm trying to create a table that looks like this, using the python-docx module. Working from the example code for creating a table in example-makedocument.py and reading through the code in docx.py, I thought something similar to this would work: tbl_rows = [ ['A1'], ['B1', 'B2' ], ['C1', 'C2' ] ] tbl_colw = [ [100], [25, 75], [25, 75] ] tbl_cwunit = 'pct' body.append(table(tbl_rows, colw=tbl_colw, cwunit=tbl_cwunit)) however this corrupts the docx document, and when Word recovers the document the table is shown as this: How can I get a row to properly span multiple columns using python-docx?

What's the best approach to generate Word document based on existing templates

…衆ロ難τιáo~ 提交于 2019-12-06 02:30:30
TL;DR Can I generate Word documents with .NET like XAML ItemTemplates? I'm finding it pretty hard to come up with a solution that meets all my requirements, so I thought I'll throw this out to stackoverflow in the hope someone can guide me. Much thanks in advance. Simply put, I need to generate Word document based on data from a database. My ideal solution: I want it to work like how DataTemplates work in xaml. I've found heaps of examples and solutions where the Template represents a static document, with bits of (single) dynamic content which needs to be replaced. e.g. WordDocGenerator The

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