openxml

How do you copy an Excel worksheet into a new workbook AND bring all the charts, images, etc.?

不打扰是莪最后的温柔 提交于 2019-12-05 14:23:39
Our application has distribution functionality. It takes several Excel 2007 spreadsheets, copies them into a single sheet, then emails them to the users. The problem is that images and charts are not copying over. I have tried everything I can find on here and various other sources, but sadly nothing seems to work. Our application is written using VSTO, and I have also tried OpenXML, but nothing seems to work. In fact trying to copy over in OpenXML corrupted the files so badly that Excel could not read or recover them. Here's the code we use (note: we have ExcelWrapper simply calls the same

Can EPPlus distinguish between blank cells and empty text cells in an Excel worksheet?

一笑奈何 提交于 2019-12-05 12:33:01
I'm using the EPPlus .NET library (v4.0.4) to interpret saved Excel workbooks. In one such worksheet, some empty cells have been set to 'text' format using the Excel 'apostrophe' trick (that is, the user has entered a single apostrophe in those cells, so that Excel will display them as blank). Sample XML for two such cells is as follows: <c r="F6" s="1" t="inlineStr"> <is> <t /> </is> </c> <c r="G6" s="1" /> Here, F6 has an apostrophe (i.e. is an empty text cell) and G6 is genuinely blank. Is is possible to read this 'inline string' ( inlineStr ) property using EPPlus or otherwise distinguish

OpenXML / EPPlus - Create PivotCache in .Net

荒凉一梦 提交于 2019-12-05 11:11:40
I'm hoping this could help me, at least, answer one of the 2 questions I asked here , but I am looking how to create a PivotCache in EPPlus / OpenXML and can't find anything online / in their documentation that shows how to do it. So, suposing I have one Excel sheet, wksRawData created in EPPlus and I want to create a second sheet with a pivot table based upon the pivot cache of wksRawData.Cells(wksRawData.Dimension.Address) - In the hopes that then I could delete wksRawData but still keep the pivot table. How would I do that? So far, my code for creating the pivot table in my second worksheet

OpenXml: Convert an XElement to an OpenXmlElement

感情迁移 提交于 2019-12-05 11:08:11
How would I go about converting an XElement to an OpenXmlElement ? Either my google-fu fails or this has not been addressed. You can convert a given OpenXmlElement to a XElement using the following code: OpenXmlElement el = ...; // Code to get the xml element from your office doc. // Then use XElement.Parse and the OuterXml property. XElement xel = XElement.Parse(el.OuterXml); To convert an XElement to an OpenXmlElement try the following code: XElement xe = ...; using(StreamWriter sw = new StreamWriter(new MemoryStream())) { sw.Write(xe.ToString()); sw.Flush(); sw.BaseStream.Seek(0, SeekOrigin

How to get all merge fields of word document using open xml sdk

旧街凉风 提交于 2019-12-05 10:24:33
I am beginner to open xml sdk. I am trying to find out all merge fields of document. But I am not getting the headers and footers merge fields. Can any one suggest a working solution? I am trying some thing like this - foreach (FieldCode field in docGenerated.MainDocumentPart.RootElement.Descendants<FieldCode>()) { String fieldText = field.Text; if (fieldText.StartsWith(" MERGEFIELD")) { Int32 endMerge = fieldText.IndexOf("\\"); Int32 fieldNameLength = fieldText.Length - endMerge; String fieldName = fieldText.Substring(11, endMerge - 11); fieldName = fieldName.Trim(); } } You have to loop

Freeze Panes in OpenXml SDK 2.0 for Excel document

时光怂恿深爱的人放手 提交于 2019-12-05 09:33:35
I'm generating an Excel workbook using OpenXml and have been following the examples at http://msdn.microsoft.com/en-us/library/cc850837.aspx It would be really useful if I could freeze the top panes, but I can't find a way to do this. I realise that I can do this if I use http://closedxml.codeplex.com/ but for now I'd like to stick to the OpenXml SDK Any ideas? I was trying to solve the same problem and ended up opening the Open XML SDK 2.0 Productivity Tool and using the Compare Files... feature to compare two spreadsheets, one with frozen panes and one without. When I did that, I was led to

Save PowerPoint 2007 as PowerPoint 2003 using Open Office SDK 2.0

懵懂的女人 提交于 2019-12-05 09:26:46
Is there anyway to use the Open Office SDK 2.0 to save a PowerPoint presention that you created using OOXML to a PowerPoint 2003 presentation? I know if you open a 2007 file and click Save As you have the option to save it as a PowerPoint 97 to 2003 document and I didn't know if I could do this grammatically using this SDK. The reason I am asking this question is because I need to give the user the option to save data on a website in either Office 2007 or 2003 format. I much rather just use the same code to produce the document instead of having to have two code paths for PowerPoint 2003 and

Underlining and bolding text

我怕爱的太早我们不能终老 提交于 2019-12-05 08:15:04
how do I get the text to be underlined and bold? My text gets bold but does not get underlined. Here is some of my code, which is pretty straight forward uses run properties to bold and underline the given text. Run run_header = para_main.AppendChild(new Run()); RunProperties runProps = new RunProperties(); Bold bold = new Bold(); Underline ul = new Underline(); runProps.Append(bold); runProps.Append(ul); run_header.AppendChild(new RunProperties(runProps)); //run_header.AppendChild(new RunProperties(new Bold(), new Underline())); string username = form.Username; string proces_header = form

How to read Excel XML (C#)

假装没事ソ 提交于 2019-12-05 07:43:58
I wonder if there is an easy way to read Excel 2010 XML? This XML has a different structure than I used to read. Especially ss:index attribute (ss:Index**="7") makes things a bit more complicated EDIT : To explain better: I have file with XML extension which can be easily opened in Excel I'm looking a way to read this sheet programically (eg copy to DataTable) Noticed this is not common XML I used to work XML defines fields on the begining, than use ROW, CELL and DATA tags What surprised me is when there are eg 3 fields (cells) but 2nd field doesn't have value this field is 'skipped' in XML,

OpenXML nested tables

跟風遠走 提交于 2019-12-05 06:09:12
I am trying to insert a Table into a TableCell, but when I try to open it in MS Word I get a message like: " a <p> is required before a </tc> ". When I open the file in compatibility mode the table formatting looks perfect but the table lines are missing. Inserting simple text into the cell works fine, the issue only happens when I try to insert a whole table. Inserting the Table in the document outside the other table also works fine. If you create a nested table structure in Word, and look at the resulting XML, you will see something like: <w:tc> <w:tcPr> <w:tcW w:w="4621" w:type="dxa"/> </w