openxml

Why Office OpenXML splits text between tags and how to prevent it?

隐身守侯 提交于 2019-12-04 10:27:14
I'm currently trying to work with docx files using PHPWord library and its templating system. I have found and updated someones (cant remember the name, but its not important) path to this library that can work with tables (replicate its rows and then use standard setValue() from PHPWord on each of row). If i create my own document, the data in xml is in normal structure, so the variable to be replaced ${variable} is in its own tag like this: <w:tbl> <w:tr> ... ${variable} </w:tr> </w:tbl> I simplified the code, in actual code there is number of other tags descibing sizes, styles, etc. My

Parse MathType MTEF data from OLE binary string

こ雲淡風輕ζ 提交于 2019-12-04 10:19:42
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 procedure is to convert the MS-WORD 2003 or below documents into the Open XML format(docx). After the docx

Open XML SDK 2.0 to get access to excel 2010 worksheet by name

浪尽此生 提交于 2019-12-04 10:11:39
问题 I have an Excel 2010 spreadsheet that has 3 worksheets named Sheet1, Sheet2 and Sheet3. I'm trying to get a reference to a worksheet by name. I'm using the code: using (SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(FileName, true)) { //Access the main Workbook part, which contains all references WorkbookPart workbookPart = myWorkbook.WorkbookPart; WorksheetPart worksheetPart = workbookPart.WorksheetParts.Last(); // this gives me Sheet1 SheetData sheetData = worksheetPart.Worksheet

Corrupt document after calling AddAlternativeFormatImportPart using OpenXml

两盒软妹~` 提交于 2019-12-04 08:07:52
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 chunk = mainDocumentPart.AddAlternativeFormatImportPart (AlternativeFormatImportPartType.Xhtml,

How to set Excel “Print Titles” with OpenXML

感情迁移 提交于 2019-12-04 06:41:52
问题 How can I set the "Print Titles" property of a spreadsheet with OpenXML, to have a row show at the top of every printed page? 回答1: The property is directly saved in the SpreadsheetPrintingParts object, however, this doesn't appear to be fully integrated into OpenXML as of yet, and requires passing a base64 string in to the variable. (see here) The content of this string appears to be tied to the machine the file is opened on, which didn't work for my implementation - I wasn't able to create a

How can I get the Worksheetpart from name or sheet ID in OpenXML?

倖福魔咒の 提交于 2019-12-04 06:31:14
The following creates an XLSX, adds two worksheets with some data. I then want to be able to get the spreadsheet later based on name (or preferably the id) so I can add/modify the sheets at a later point in time. I'm stuck on how to get the sheet again where the code is incomplete below. Sub Main() Using doc As SpreadsheetDocument = SpreadsheetDocument.Create(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "c:\temp\fubar.xlsx"), SpreadsheetDocumentType.Workbook) Dim currSheet As WorksheetPart ' create the workbook doc.AddWorkbookPart() doc.WorkbookPart.Workbook = New Workbook()

Get particular page from Word document using Open XML SDK

瘦欲@ 提交于 2019-12-04 05:43:31
问题 I want to convert each page of document into separate word document. So i need to get every page of document. I am not able to differentiate pages in open xml format. So please move me to right direction. using (WordprocessingDocument document = WordprocessingDocument.Open("test.docx", true)) { MainDocumentPart mainPart = document.MainDocumentPart; } 回答1: Based on the documentation here, The client uses LastRenderedPageBreak toidentify pages when its last saved. and the xml for it is: <w

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

对着背影说爱祢 提交于 2019-12-04 05:36:53
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? 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 edited So, to set those two options to "false" ( LockingValues.Unlocked ), search for all SdtElement elements in

C# to replace strings of text in a docx

喜你入骨 提交于 2019-12-04 05:35:25
Using C#, is there a good way to find and replace a text string in a docx file without having word installed on that machine? Yes, using Open XML . Here's an article which addresses your specific question: Creating a Simple Search and Replace Utility for Word 2007 Open XML Format Documents You may also try Aspose.Words for .NET in order to find and replace text in Word document . This component doesn't require MS Office to be installed. The API is quite simple and easy to use and implement. Disclosure: I work as developer evangelist at Aspose. 来源: https://stackoverflow.com/questions/3375811/c

Prevent tables from breaking over a page, if possible

谁说我不能喝 提交于 2019-12-04 05:30:34
问题 I am using OpenXML to generate a word document which contains thousands of tables. Some of them span over the length of entire page, which is fine as there is no way to prevent that from happening, however, many of the tables contain only a few rows. Is there a property I can set to prevent these tables from breaking? It looks awful when a table with only two rows is split between two pages, or when a key row is the only one split on the previous page. I've spent a serious chunk of time