openxml-sdk

How I can export from a DataTable to a Content control in C# using Openxml?

流过昼夜 提交于 2020-01-30 11:49:54
问题 So I have this code, but i want to know how possible it is to convert from a result gotten from an SQL DataTable to print on a Microsoft word content control My code looks something like this public bool PrintTableonContentControl(string connectionString, string DbQuery,string filePath, string placeholderText) { try{ DataTable dt = new DataTable(); using(SqlConnection con = new SqlConnection(connectionString)){ con.Open(); using(SqlCommand cmd = new SqlCommand(DbQuery,con)){ using

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()

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

How can I make my bullets larger in Open XML?

大城市里の小女人 提交于 2020-01-16 07:50:17
问题 I'm generating docx files using the Open XML SDK for .NET The bullets in my lists are super tiny but I can't figure out why. So here's what I've done: Generating a doc with a single bulleted item Created a doc from Word with a single bulleted item Used Open XML Productivity Tools to compare both files Cannot for the life of me see any differences If I click on the bullet in both, to where it shows the font and size, they are both the same! I don't see any differences in the numbering section

Reading Excel files using OpenXML

只愿长相守 提交于 2020-01-15 06:01:54
问题 I am trying to read Excel files via OpenXML and looking to output into a CSV. Currently it reads each cell in a separate line (due to writeline) or a single line (when using write). What is the best way to read and outputing in a tabular format like in Excel? Is there a built in feature in OpenXML which I can leverage for this? static void Main(string[] args) { String xlDocName = @"C:\Users\xlp111\source.xlsx"; using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open

Is there a tool to find errors in Excel documents created with the OpenXML SDK?

旧城冷巷雨未停 提交于 2020-01-13 02:13:13
问题 Is there a tool that can identify the exact location of errors in an Excel document created using the OpenXML SDK? I've created an Excel file using the Microsoft OpenXML SDK 2.5 (also tried v 2.0 with the same result), and must have made a mistake somewhere in the code. What I'm trying to find out is where. The SDK validation functions all say the document is valid. When validating the generated Excel file using the OpenXML SDK Productivity tool, the response is "No validation error is found

Add Header and Footer to an existing empty word document with OpenXML SDK 2.0

岁酱吖の 提交于 2020-01-10 01:04:06
问题 I'm trying to add a Header and Footer to an empty word document. I use this code to add Header part in word/document.xml when change docx to zip. ApplyHeader(doc); public static void ApplyHeader(WordprocessingDocument doc) { // Get the main document part. MainDocumentPart mainDocPart = doc.MainDocumentPart; // Delete the existing header parts. mainDocPart.DeleteParts(mainDocPart.HeaderParts); // Create a new header part and get its relationship id. HeaderPart newHeaderPart = mainDocPart

C# - OpenXML SDK 2.5 - Insert New Slide from Slide Masters with the layout that contains images

 ̄綄美尐妖づ 提交于 2020-01-07 06:57:27
问题 I used this [https://codingthedocument.wordpress.com/author/agschwantes/] to create my new slides with the help of the OpenXML 2.5 SDK. I designed and used my own Slide Master to create a new slide. My Slide Master includes some layouts with images and some layouts without images. If I create a slide from my Master Layout without images, everything works fine. If I create a slide with the layout, that contains images, I get the right layout BUT on top of every fixed images there is another

change table style text in openxml for powerpoint generatron

♀尐吖头ヾ 提交于 2020-01-06 06:06:31
问题 I have this code using openxml sdk which generates table in PPT report. This line is the reason for table style. tableStyleId.Text = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; Style is : I need to change the style and colors but I couldn't find anything for that. Please help. private D.Table GenerateTable(int projectID, string reportType) { // Declare and instantiate table D.Table table = new D.Table(); // Specify the required table properties for the table D.TableProperties tableProperties =

OpenXML SDK getting ActiveX controls value

我与影子孤独终老i 提交于 2020-01-05 07:14:38
问题 For one of my projects in college I had to create a test as a Word document and add some ActiveX forms in it to be completed by another person. After this I had to programmatically extract the answers from it and put a grade on the test. I used OpenXML SDK for processing the document, but it gave me headaches because I couldn't find a way to get the ActiveX values. So what was the solution? 回答1: After searching the Internet and a bit of sniffing on the document I have found that the ActiveX