openxml-sdk

Simplify/ Clean up XML of a DOCX word document

*爱你&永不变心* 提交于 2019-12-03 08:44:28
问题 I have a Microsoft Word Document (docx) and I use Open XML SDK 2.0 Productivity Tool to generate C# code from it. I want to programmatically insert some database values to the document. For this I typed in simple text like [[place holder 1]] in the points where my program should replace the placeholders with its database values. Unfortunately the XML output is in some kind of mess. E.g. I have a table with two neighboring cells, which shouldn't distinguish apart from its placeholder. But one

how can I change the font open xml

点点圈 提交于 2019-12-03 07:46:28
问题 How can I change the font family of the document via OpenXml ? I tried some ways but, when I open the document, it's always in Calibri Follow my code, and what I tried. The Header Builder I think is useless to post private static void BuildDocument(string fileName, List<string> lista, string tipo) { using (var w = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document)) { var mp = w.AddMainDocumentPart(); var d = new DocumentFormat.OpenXml.Wordprocessing.Document(); var b

OpenXML SDK Inject VBA into excel workbook

喜夏-厌秋 提交于 2019-12-03 07:32:52
I can successfully inject a piece of VBA code into a generated excel workbook, but what I am trying to do is use the Workbook_Open() event so the VBA code executes when the file opens. I am adding the sub to the "ThisWorkbook" object in my xlsm template file. I then use the openxml productivity tool to reflect the code and get the encoded VBA data. When the file is generated and I view the VBA, I see "ThisWorkbook" and "ThisWorkbook1" objects. My VBA is in "ThisWorkbook" object but the code never executes on open. If I move my VBA code to "ThisWorkbook1" and re-open the file, it works fine.

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

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:00:54
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.GetFirstChild<SheetData>(); } I am trying to get a reference to Sheet2, but I cannot find a way to do

Replacing Content Controls in OpenXML

若如初见. 提交于 2019-12-03 05:09:58
问题 I need something as a placeholder. I at first looked to Content Control as a solution but I'm having some problems with it. I then looked into adding CustomXML to the .docx but turned away from that because of the i4i lawsuit. Then I decided I would just plain change the text of the Content Control through OpenXML SDK 2.0 but even if it's so marked the Content Control doesn't go away. I guess that it doesn't know that the text changed unless it happens inside word. I could perhaps just remove

Beginner sample codes for the Open XML SDK? [closed]

隐身守侯 提交于 2019-12-03 05:06:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I recently started working on the Open XML SDK 2.0. I would like to know if there is any better documentation (instead of open xml sdk2.0 itself) or any other resource to learn working with the Open XML SDK? 回答1: Besides everything on MSDN, the most well-known place to learn Open XML and the SDK is http:/

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

泄露秘密 提交于 2019-12-03 04:19:11
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 openxml sdk2.0 on c:\program files\open xml sdk\v2\lib\DocumentFormat.OpenXml.dll. and also put my

Simplify/ Clean up XML of a DOCX word document

断了今生、忘了曾经 提交于 2019-12-02 22:33:43
I have a Microsoft Word Document (docx) and I use Open XML SDK 2.0 Productivity Tool to generate C# code from it. I want to programmatically insert some database values to the document. For this I typed in simple text like [[place holder 1]] in the points where my program should replace the placeholders with its database values. Unfortunately the XML output is in some kind of mess. E.g. I have a table with two neighboring cells, which shouldn't distinguish apart from its placeholder. But one of the placeholders is split into several runs. [[good place holder]] <w:tc xmlns:w="http://schemas

how can I change the font open xml

廉价感情. 提交于 2019-12-02 20:33:10
How can I change the font family of the document via OpenXml ? I tried some ways but, when I open the document, it's always in Calibri Follow my code, and what I tried. The Header Builder I think is useless to post private static void BuildDocument(string fileName, List<string> lista, string tipo) { using (var w = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document)) { var mp = w.AddMainDocumentPart(); var d = new DocumentFormat.OpenXml.Wordprocessing.Document(); var b = new Body(); var p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(); var r = new Run(); // Get

Replacing Content Controls in OpenXML

喜欢而已 提交于 2019-12-02 18:27:13
I need something as a placeholder. I at first looked to Content Control as a solution but I'm having some problems with it. I then looked into adding CustomXML to the .docx but turned away from that because of the i4i lawsuit. Then I decided I would just plain change the text of the Content Control through OpenXML SDK 2.0 but even if it's so marked the Content Control doesn't go away. I guess that it doesn't know that the text changed unless it happens inside word. I could perhaps just remove the CC and place text instead but I'm afraid of problems with format and styles it could bring and