openxml

Excel not inserting leading zero

蹲街弑〆低调 提交于 2020-01-24 12:36:05
问题 I am using Office OpenXml to write to an Excel file. The file is a template so it already has all my headers and formatting for my columns. I am inserting numbers that have leading zeroes to a "special" column which is basically a 10 digit number. However in my code I can see that it is setting the value to for example 0000000004 . The result in the sheet with a value of 4 in that cell and the actual cell showing 0000000004 . Here is my code to write to the cell. if (reader[2].ToString()

What is the difference between Office Automation, VSTO, and Open XML SDK?

久未见 提交于 2020-01-24 03:52:25
问题 What is the difference between Office Automation, VSTO, and Open XML SDK? Do we need all of them or some of them are obsolete? 回答1: Office Automation refers to the manipulation of an Office program (or, more commonly, an Office document via an Office program) programmatically, using COM interop. Visual Studio Tools for Office (VSTO) is a set of development tools available in the form of a Visual Studio add-in (project templates) and a runtime that allows Microsoft Office 2003 and later

OpenXML nested tables

本秂侑毒 提交于 2020-01-23 06:27:07
问题 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. 回答1: If you create a nested table structure in Word, and

C# return memory stream from OpenXML resulting to a corrupted word file

和自甴很熟 提交于 2020-01-22 14:38:12
问题 I have a problem with a MemoryStream from OpenXML. I succeed with opening a Word file, changing it and downloading it through the HttpResponse if I do all the steps in a single method. But if I try to do it in two different classes (or methods) by returning the MemoryStream, I get a corrupted word file. I thought about a flushing or buffer problem but I don't find a solution. Here is the working code : public void FillTemplateOpenXmlWord(HttpResponse response) { string filePath = @"c:

How do you change the content of a content control in Word 2007 with OpenXml SDK 2.0?

天大地大妈咪最大 提交于 2020-01-22 10:00:34
问题 About to go mad with this problem. I'm sure it's so simple I'm just missing it, but I cannot for the life of me find out how to change the content of a content control in Word 2007 with the OpenXml SDK v2.0 in C#. I have created a Word document with a plain text content control. The tag for this control is "FirstName". In code, I'd like to open up the Word document, find this content control, and change the content without losing the formatting. The solution I finally got to work involved

How to get coordinates of Run or other WordProcessing element via OpenXML?

天涯浪子 提交于 2020-01-22 02:14:47
问题 I was wondering if it is possible to find the coordinates of a specific Run (text, no drawing or other elements that have offset parameter) on a page in a Word document using OpenXML SDK . I know that OpenXML is basically .. well XML, and simple runs have no relative, numerical position embedded in them. I was reading through OpenXML SDK API and found no clues but maybe I have missed something. By coordinates I mean any tuple that can be mapped to pixels if I would generated an image out of

Converting a <V:shape>/Embed to a w:drawing

淺唱寂寞╮ 提交于 2020-01-21 19:14:36
问题 I have a V:Shape that I am assuming has come from the conversion of a .Doc file to a .Docx file, but in the code I have written, I am wanting a DocumentFormat.OpenXml.Drawing.Pictures.Picture . Is there any way to programically convert to a Picture ? The snippet I'm using is: foreach (var item in value) { if (!item.Descendants<Picture>().Any()) //pictures are processed differently - they're an absolute s**t storm to code... { p.Append(item.CloneNode(true)); } else { p.Append(CreateImageRun

Interop.Word Documents.Open is null

穿精又带淫゛_ 提交于 2020-01-18 15:46:50
问题 I am trying to open .docx file and convert to PDF using Interop.Word.Application. It works as console application but If I use the same in my web application it doesn't work. I tried to see the permissions on the folder. I gave 'Network Service' with full control, but still I get object reference not set at word.Documents.Open. Could you please let me know what could be the problem? I am stuck with this error. Please let me know. I appreciate any suggestions. Thank you. Microsoft.Office

Interop.Word Documents.Open is null

懵懂的女人 提交于 2020-01-18 15:44:13
问题 I am trying to open .docx file and convert to PDF using Interop.Word.Application. It works as console application but If I use the same in my web application it doesn't work. I tried to see the permissions on the folder. I gave 'Network Service' with full control, but still I get object reference not set at word.Documents.Open. Could you please let me know what could be the problem? I am stuck with this error. Please let me know. I appreciate any suggestions. Thank you. Microsoft.Office

What are the RGB or HEX values of the default theme colors in Microsoft Word 2010?

戏子无情 提交于 2020-01-17 07:09:14
问题 I need to capture the color values for the scheme colors (i.e. accent1, accent2,....) in a Microsoft Word 2010 document. I have tried searching on the internet a lot but couldn't find any answer. Can any one help me with the reference for these colors? 回答1: Though i didn't get any answers for my question but I eventually found the answer and thought the share it for others' use. The theme color references can be found in the word/theme/theme1.xml file, however these references can not be