openxml

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

谁说我不能喝 提交于 2020-01-02 08:27:19
问题 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

ClosedXML add image

给你一囗甜甜゛ 提交于 2020-01-02 07:17:28
问题 I am able to add in an image to an excel spreadsheet by using OpenXML. However for the rest of the program I use ClosedXML to add data. I can add data at a specific cell using the column and row index. If I can add an image to an excel (It currently is a separate layer it seems, hovering over cells), how can I add it to a cell using ClosedXML? //Adds an image to the excel file public void AddImageToExcel(SpreadsheetDocument sd, MemoryStream imagestream) { DrawingsPart dp = sd.WorkbookPart

Applying number formatting in OpenXML

余生长醉 提交于 2020-01-02 06:50:10
问题 I'm trying to create an Excel spreadsheet from scratch using OpenXML and I've got everything working okay (dumping actual values into actual cells), but now I'm trying to apply number formatting to columns and I'm running into a problem. I have styles.xml that looks like this: <?xml version="1.0" encoding="utf-8"?> <x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <x:numFmts count="12"> <x:numFmt numFmtId="216" formatCode="#,###" /> <x:numFmt numFmtId="217"

How to add a row to Excel using OpenXML SDK 2.0?

泄露秘密 提交于 2020-01-01 19:17:14
问题 I am new to OpenXML and have been struggling with adding a new row with cell data in A1 after a row (with cell data as well) has been added. So essentially I want to insert "Test" in "row 1" column "A1" and "test" in "row 2" column "A1". Here is my code, it looks sound and creates the file however Excel does not open it. I opened it in OpenOffice and it only shows one row instead of two. When I comment out appending row2 to the sheetdata, it works fine. So I am thinking am creating the 2nd

Is there an alternative to open-xml sdk to generate word documents

别来无恙 提交于 2020-01-01 16:47:22
问题 I'm trying to generate word documents using open xml sdk. When the documents are small this is no problem (and rather easy). When the documents become larger (+500 pages) I notice the peformance (duration, memory usage, ...) goes down significantly. Googling this problem I came across some posts that point out the same problem. For excel there is a solution with spreadsheetgear. I would like to know if there is a word alternative to this or if there are other solutions to generate word

How to find the page number from a paragraph using OpenXML?

余生颓废 提交于 2020-01-01 11:31:46
问题 For a Paragraph object, how can I determine on which page this is located using the Open XML SDK 2.0 for Microsoft Office ? 回答1: It is not possible to get page numbers for a word document using OpanXml Sdk as this is handled by the client (like MS Word). However if the document you are working with is previously opened by a word client and saved back, then the client will add LastRenderedPageBreak to identify the page breaks. Refer to my answer here for more info about LastRenderedPageBreak s

OpenXML replace text in all document

*爱你&永不变心* 提交于 2020-01-01 03:01:08
问题 I have the piece of code below. I'd like replace the text "Text1" by "NewText", that's work. But when I place the text "Text1" in a table that's not work anymore for the "Text1" inside the table. I'd like make this replacement in the all document. using (WordprocessingDocument doc = WordprocessingDocument.Open(String.Format("c:\\temp\\filename.docx"), true)) { var body = doc.MainDocumentPart.Document.Body; foreach (var para in body.Elements<Paragraph>()) { foreach (var run in para.Elements

Insert HTML into OpenXML Word Document (.Net)

风流意气都作罢 提交于 2019-12-31 22:39:10
问题 Using OpenXML SDK, I want to insert basic HTML snippets into a Word document. How would you do this: Manipulating XML directly ? Using an XSLT ? using AltChunk ? Moreover, C# or VB examples are more than welcome :) 回答1: Here is another (relatively new) alternative http://notesforhtml2openxml.codeplex.com/ 回答2: Well, hard to give general advice, because it depends strongly on your input what is best. Here's a simple example inserting a paragraph into a DOCX document for each paragraph in an (X

unable to generate second table in PPT report using openxml

喜你入骨 提交于 2019-12-31 07:46:05
问题 I have this code. I am able to generate pptx report with text data perfectly. I have 4 tables as well in this report which has dynamic data. I am able to generate one table in PPT but unable to to do multiple. Requirement: On the right I have 4 tables. Expectation: I am able to get the 1st table. In below code I have added P.GraphicFrame graphicFrame2 in AddNewSlide method in assumption of it will create another frame for table which I can fill with data and place on PPT. But it doesnt work.

Open xml headers not being set with Office Addin

半世苍凉 提交于 2019-12-31 05:11:32
问题 I'm going through this, pretty good, document (http://dev.office.com/docs/add-ins/word/create-better-add-ins-for-word-with-office-open-xml?product=word) to understand OOXML better and to use it in a Word Addin. To test my created OOXM, I use this sample: http://dev.office.com/code-samples-detail/5789. Simple stuff works, but when I try to set the headers of the document it doesn't seem to work. Here's the OOXML snippet: <pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006