openxml

OpenXML SDK: Make Excel recalculate formula

I update some cells of an Excel spreadsheet through the Microsoft Office OpenXML SDK 2.0. Changing the values makes all cells containing formula that depend on the changed cells invalid. However, due to the cached values Excel does not recalculate the formular, even if the user clicks on "Calculate now". What is the best way to invalida...

Parsing an Open XML doc via styled blocks

I'm working with docx docs, and I need to parse a document into sections on the basis of headings styled with the "heading 1" style. So if I had a doc like this (markup is pseudocode): <doc> <title style>Doc Title</title style> <heading1>First Section</heading1> ... <heading2>Second Section</heading2> ... <heading3>Third Section</headin...

Open XML document ContentControls problem with signed id's

I have an application that generates Open XML documents with Content Controls. To create a new Content Control I use Interop and the method ContentControls.Add. This method returns an instance of the added Content Control. I have some logic that saves the id of the Content Control to reference it later, but in some computers I've been ...

Using Excel sheet as a template vs. a "real" Excel template in OpenXML

Does anyone have any good answer what kind of difference there is between using some arbitrary pre-formatted Excel 2007 *.xlsx file as a template, loading it in my C# app, and filling up some of its cells with data using the Microsoft OpenXML SDK versus creating specific Excel templates (*.xltx) files and using those as basis for...

Adding Date to Excel using Open XML

Hi, I would like to insert Date value to excel file using Open XML. Here is my code sample. cell.CellValue = new CellValue(value.ToString()); cell.DataType = new EnumValue<CellValues>(CellValues.Date); ...

Theme confusion in SpreadsheetML.

I've been fighting this all day. Inside my styles.xml file I have color information given like so: <fgColor theme="0" tint="-0.249977111117893" /> ECMA 376 defines a theme color reference as: Index into the <clrScheme> collection, referencing a particular <sysClr> or <srgbClr> value expressed in the Theme part. Ok, tha...

How can I get WorkbookPart from WorkSheet ?

Hi, I am trying to create Excel file using OpenXML SDK. I have one situation to get WorkBookPart from WorkSheet instance. How can I get it? Thanks. Ant. ...

ASP.NET library to extract plain text from Open XML file formats

Is there a pre-existing library to extract plain text form Open XML file formats (e.g. docx, pptx, and xlsx) files? I require this to populate a lucene.net index. I've found this example which extracts text from docx and it seems to work okay. But before building my own solution based on this I was wondering if there's something alread...

Create page break using OpenXml

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 ...

Replace image in word doc using OpenXML

Following on from my last question here OpenXML looks like it probably does exactly what I want, but the documentation is terrible. An hour of googling hasn't got me any closer to figuring out what I need to do. I have a word document. I want to add an image to that word document (using word) in such a way that I can then open the docu...

How to change PowerPoint chart data with .NET?

I have a PowerPoint template that contains one slide and on that slide is a chart. I'd like to be able to manipulate that chart's data using .NET. So far I have code that... unzips the Powerpoint file. unzips the embedded excel file (ppt\embeddings\Microsoft_Office_Excel_Worksheet1.xlsx) It successfully manipulates the data in the e...

Binding Data to Word 2007 Content Controls Using Visual Studio Tools for the Office System (3.0)

I found this article - Binding Data to Word 2007 Content Controls Using Visual Studio Tools for the Office System (3.0) - and thought that that's exactly what I'm trying to do. I want to programatically build a product brochure using Content Controls and Open XML. The article in question refers to an accompanying video which unfortunat...

Easy creation/updating of Office Open XML Charts (PowerPoint preferred)

Does anybody know Office-independent .NET components supporting creation/updating full-fledged office open xml charts from different types of documents (PowerPoint preferred) in a couple of lines of code. An example from MSDN How to: Insert a Chart into a Spreadsheet Document does it in a difficult way (as far as I can understand I nee...

Can someone explain how OpenXML works(in this SP)?

Hi I am looking at this tutorial and it confuses me as I don't get the SP CREATE PROCEDURE [dbo].[spTEST_InsertXMLTEST_TEST](@UpdatedProdData nText) AS DECLARE @hDoc int exec sp_xml_preparedocument @hDoc OUTPUT,@UpdatedProdData INSERT INTO TBL_TEST_TEST(NAME) SELECT XMLProdTable.NAME FROM OPENXML(@hDoc, 'ArrayOfTBL_TEST...

Conversion failed when converting datetime from character string. Linq To SQL & OpenXML

Hi I been following this tutorial on how to do a linq to sql batch insert. http://www.codeproject.com/KB/linq/BulkOperations_LinqToSQL.aspx However I have a datetime field in my database and I keep getting this error. System.Data.SqlClient.SqlException was unhandled Message="Conversion failed when converting datetime from ...

Would this rollback/stop all records from inserting?

Hi I been going through this tutorial http://www.codeproject.com/KB/linq/BulkOperations_LinqToSQL.aspx and them make a SP like this CREATE PROCEDURE [dbo].[spTEST_InsertXMLTEST_TEST](@UpdatedProdData nText) AS DECLARE @hDoc int exec sp_xml_preparedocument @hDoc OUTPUT,@UpdatedProdData INSERT INTO TBL_TEST_TEST(NAME) SELECT...

Inserting newlines in Word using OpenXML

I am using openxml WordProcessingDocument to open a Word template and replace placeholder x1 with a string. This works fine unless I need the string to contain a newline. How can I replace x1 with text may contain newlines that word would recognise? I have tried \n \r but these do not work Just to explain further when the word templat...

Treating empty elements as nulls in SQL Server's OPENXML function

I have the following (highly simplified) XML document that I am reading into my database using the OPENXML function: <root> <row> <bar>123</bar> </row> <row> <bar>0</bar> </row> <row> <bar></bar> </row> </root> I am importing in into the database like so: insert into [Foo] ([bar]) s...

Add Hyperlink to Cell in Excel 2007 Using Open XML SDK 2.0

I can't seem to find any documentation or code samples on how to add a hyperlink to a cell in Excel 2007 using the Open XML SDK 2.0. I am using the following code, but is there a step I am missing? WorksheetPart workSheetPart = ExcelUtilities.GetWorkSheetPart(mWorkBookPart, "Program"); workSheetPart.AddHyperlinkRelationship(new Uri("h...

Storing UTF-8 XML using Word's CustomXMLPart or any other supported way

I am writing a Word add-in which is supposed to store some own XML data per document using Word object model and its CustomXMLPart. The problem I am now facing is the lack of IStream-like functionality for reading/writing XML to/from a CustomXMLPart. It only provides BSTR interface and I am puzzled how to handle UTF-8 XMLs with BSTRs. To...