openxml

Cannot insert the OpenXmlElement “newChild” because it is part of a tree

梦想的初衷 提交于 2019-11-29 09:23:29
The Title states the error I am getting. I'm trying to hide all the text in a word doc using OpenXml. Currently when I try and append the Paragraph properties I receive the above error. I can't find much about this error online. Code that returns error using (WordprocessingDocument wdDoc = WordprocessingDocument.Open(mDoc_copy, true)) { // Manage namespaces to perform XPath queries. NameTable nt = new NameTable(); XmlNamespaceManager nsManager = new XmlNamespaceManager(nt); nsManager.AddNamespace("w", wordmlNamespace); // Get the document part from the package. // Load the XML in the document

Matching Excel's floating point in Java

徘徊边缘 提交于 2019-11-29 09:22:58
I have an .xlsx spreadsheet with a single number in the top-left cell of sheet 1. The Excel UI displays: -130.98999999999 This is visible in the formula bar, i.e. not affected by the number of decimal places the containing cell is set to show. It's the most accurate number Excel will display for this cell. In the underlying XML, we have: <v>-130.98999999999069</v> When trying to read the workbook with Apache POI, it feeds the number from the XML through Double.valueOf and comes up with: -130.9899999999907 Unfortunately, this is not the same number the user can see in Excel. Can anyone point me

Is it possible to update a PowerPoint slide with new data (in C#)?

久未见 提交于 2019-11-29 05:14:50
Are there any examples out there on how to update a PowerPoint slide (by clearing the text in a certain textbox and updating it with new content)? I have a monthly report to generate in PowerPoint and I have all the data in a database. I am trying to determine if I can simply autogenerate the slides by having a blank PowerPoint template with three textboxes and the data would get filled in from my C# code. The other examples i would look for are: bulletted lists tables Any help in the right direction would be appreciated. I see a few questions on SOF that are similar but none seems to answer

OpenXML spreadsheet created in .NET won't open in iPad

江枫思渺然 提交于 2019-11-29 04:47:55
I am trying to generate a spreadsheet in .NET which will be opened by my manager on his iPad when he's out of the office. The spreadsheet opens fine on a Windows PC, but when trying to open on the iPad it says "An error occurred while reading the document" (so useful!) By using the "Compare" feature on the OpenXML SDK Productivity tool with a document that does open on the iPad, and by doing some manual editing of the faulty document's XML files in notepad I have narrowed it down to the file xl/_rels/workbook.xml.rels which stores the relationships of the parts in the workbook. This is the

C# & OpenXML: Insert an image into an excel document

落花浮王杯 提交于 2019-11-29 04:18:51
I am using a modified version of this code to create an excel document, add cells, and style cells. I am trying to modify this code to also be able to add images to a sheet. I am getting nowhere and there really is nothing on the web that will help. I am trying to read through the OpenXML productivity tool diff. which is kind of unhelpful. Can anyone here point me in the right direction? Thanks. I wrote something on this here in a blog post: http://polymathprogrammer.com/2009/12/21/advanced-styling-in-excel-open-xml/ Note that it was originally written for the Open XML SDK 2.0 CTP version, so

How to generate Table Of Contents using OpenXML SDK 2.0?

徘徊边缘 提交于 2019-11-29 03:58:48
Using the SDK I'm building Word documents that contain reports. These documents need to have TOC. Does anybody have a complete solution that I can follow in order to understand how to do this? (I've read everything on http://openxmldeveloper.org/ ) Have a look at Fourth and Final Screen-Cast in Series on Adding/Updating the TOC in OpenXML WordprocessingML Documents by Eric White. Hope that helps! UPDATE: According FAQ from MSDN Forums I see that this feature is not supported: 8) How to generate TOC (table of contents) in Word document? Open XML SDK 2.0 does not have this feature supported. But

Create page break using OpenXml

爷,独闯天下 提交于 2019-11-29 02:52:37
I use OpenXml to create Word document with simple text and some tables under this text. How can I force Paragraph with this text to show always on new page? Maybe this paragraph should be some Header but I'm not sure how to do this. Thanks Adam Sheehan You can create a page break within a Run element using the <w:br> element. In raw OpenXML, it would look something like: <w:p> <w:r> <w:br w:type="page" /> </w:r> </w:p> If you're using the OpenXml SDK, you can use new Paragraph( new Run( new Break(){ Type = BreakValues.Page })); EDIT: If you just want to specify that a paragraph is the last

What is the difference between CellValues.InlineString and CellValues.String in OpenXML?

两盒软妹~` 提交于 2019-11-29 02:26:08
问题 I am trying to write some code to generate an Excel spreadsheet and I am not sure what the difference between CellValues.InlineString and CellValues.String to insert text on the cells. Shall I use this: private void UpdateCellTextValue(Cell cell,string cellValue) { InlineString inlineString = new InlineString(); Text cellValueText = new Text { Text = cellValue }; inlineString.AppendChild(cellValueText); cell.DataType = CellValues.InlineString; cell.AppendChild(inlineString); } this private

create word document with Open XML

ⅰ亾dé卋堺 提交于 2019-11-29 02:04:45
I am creating a sample handler to generate simple Word document. This document will contains the text Hello world This is the code I use (C# .NET 3.5), I got the Word document created but there is no text in it, the size is 0. How can I fix it? (I use CopyStream method because CopyTo is available in .NET 4.0 and above only.) public class HandlerCreateDocx : IHttpHandler { public void ProcessRequest(HttpContext context) { using (MemoryStream mem = new MemoryStream()) { // Create Document using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(mem, WordprocessingDocumentType

Replace Text in Word document using Open Xml

守給你的承諾、 提交于 2019-11-29 01:13:21
问题 I have created a docx file from a word template, now I am accessing the copied docx file and want to replace certain text with some other data. I am unable to get the hint as to how to access the text from the doument main part? Any help would be appreciable. Below is my code till now. private void CreateSampleWordDocument() { //string sourceFile = Path.Combine("D:\\GeneralLetter.dot"); //string destinationFile = Path.Combine("D:\\New.doc"); string sourceFile = Path.Combine("D:\