openxml

Why does my custom XML not carry over to a new version of a DOCX file when Word saves it?

社会主义新天地 提交于 2019-12-05 04:33:48
I'm adding in some custom XML to a docx for tracking it inside an application I'm writing. I've manually done it via opening the Word Document via a ZIP library, and via the official Open XML SDK route. Both have the same outcome of my XML being inserted into customXml folder in the document. The document opens fine in Word for both of these methods, and the XML is present. BUT when I then save the document as MyDoc2.docx for example all my XML disappears. What am I doing wrong? Microsoft links I've been following: http://msdn.microsoft.com/en-us/library/bb608597.aspx http://msdn.microsoft.com

Open xml replace text from word file and return memory stream using MVC

◇◆丶佛笑我妖孽 提交于 2019-12-05 04:17:15
问题 I have an word file that contain my specified pattern text {pattern} and I want to replace those pattern with new my string which was read from database. So I used open xml read stream from my docx template file the replace my pattern string then returned to stream which support to download file without create a temporary file. But when I opened it generated me error on docx file. Below is my example code public ActionResult SearchAndReplace(string FilePath) { MemoryStream mem = new

How can I embed some VBA code into a spreadsheet created using ClosedXML?

懵懂的女人 提交于 2019-12-05 03:59:29
I am using ClosedXML to generate spreadsheets from C# (asp.net-mvc) and it works great. I have one additional requirement so I wanted to get some feedback on how I could achieve this. I want to save as a macro enabled workbook and when I just give it a "xlsm" extension it doesn't seem to open (versus a xlsx). Here is my code: public ActionResult ExportExcel() { MemoryStream stream = nModel.GenerateSS(); return File(stream, @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", "MySS.xlsx"); } but if I try to do this: public ActionResult ExportExcel() { MemoryStream

Link to Microsoft Open XML SDK tutorials [closed]

时光怂恿深爱的人放手 提交于 2019-12-05 03:32:18
Anyone know any link to a good Microsoft Open XML tutorials? This is the official place to learn about Open XML: http://msdn.microsoft.com/en-us/office/bb265236.aspx . You can just skim through all results in msdn.microsoft.com for Open XML SDK Here are some other links to get your started: http://openxmldeveloper.org/default.aspx Not too active, but does get a decent amount of tutorials. http://blogs.msdn.com/b/brian_jones/archive/2010/04/06/zeyad-rajabi-s-open-xml-sdk-blog-map.aspx Microsoft program manager's blog for code snippets and tutorials. http://msdn.microsoft.com/en-us/library

Directly signing an Office Word document using XML

谁说胖子不能爱 提交于 2019-12-05 03:28:26
I'm trying to sign a Microsoft Office Word file using C# in direct XML format. There are some questions and ambiguousness arises here like: How should I fill in the digest values, what value should I exactly digest for each reference, and what value should I digest for each transform? What value should I sign to create the SignatureValue ? And what certificate should I include in x509 data and how? (We don't exactly have a certificate so a guide for creating one is appreciated.) The last question is am I doing this correctly? Maybe there is something wrong here and I have missed a package that

How to add section break next page using openxml?

允我心安 提交于 2019-12-05 02:07:18
I want to add a section break at the end of the document and add some text. My code is as below: using System; using System.Collections.Generic; using System.Linq; using System.Text; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Wordprocessing; namespace WordDocManipulation { class Program { static void Main(string[] args) { string path = @"C:\sample.docx"; string strtxt = "Hello This is done by programmatically"; OpenAndAddTextToWordDocument(path,strtxt); } public static void OpenAndAddTextToWordDocument(string filepath, string txt) { /* I want to the below text to be

How to read an .XLSX (Excel 2007) file using ADO.NET? I am finding “Could not find installable ISAM”-error

蓝咒 提交于 2019-12-05 00:37:08
问题 I need to work in .net 2.0 . So I can't use OpenXML. This is my source code and I have already Installed AccessDatabaseEngine.exe . But still getting the exception: "Could not find installable ISAM". I have also tried "Extended Properties=Excel 8.0" in the connection string. static void Main(string[] args) { DataSet dataSet = new DataSet(); OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|Data Directory|\HSC.xlsx;Extended Properties=Excel 12.0

How can I query a Word docx in an ASP.NET app?

时间秒杀一切 提交于 2019-12-04 23:45:22
问题 I would like to upload a Word 2007 or greater docx file to my web server and convert the table of contents to a simple xml structure. Doing this on the desktop with traditional VBA seems like it would have been easy. Looking at the WordprocessingML XML data used to create the docx file is confusing. Is there a way (without COM) to navigate the document in more of an object-oriented fashion? 回答1: I highly recommend looking into the Open XML SDK 2.0. It's a CTP, but I've found it extremely

How can i get actual used range for modified excels using Epplus?

混江龙づ霸主 提交于 2019-12-04 23:34:43
I am reading data from excel to datable using EPPlus. After reading an excel sheet with 10 rows of record, I modified the excel sheet by removing existing data and kept data for only one row. But when I am reading the modified excel it still reading 10 rows (1 with value and remaining as null fields) to data table. How can limit this? I am using following code for reading Excel. using (var pck = new OfficeOpenXml.ExcelPackage()) { using (var stream = File.OpenRead(FilePath)) { pck.Load(stream); } var ws = pck.Workbook.Worksheets.First(); bool hasHeader = true; // adjust it accordingly(this is

Converting docx to pdf using openxml and pdfcreator in c#

眉间皱痕 提交于 2019-12-04 20:09:34
I need to convert docx to pdf file in server. I have seen PDFCreator will do, based on below link( http://sourceforge.net/projects/pdfcreator/ ). I need some suggestions on this as listed below: can i use PDF Creator in server side. without creating word object, can i convert docx to pdf with openxml by using pdfcreator API. Please give me reply soon. You can use docx4j.NET to convert a docx to XSL FO, and from there, to PDF. Or, indeed, to any of the other output formats supported by Apache FOP. See this sample . docx4j.NET is an IKVM'd DLL of docx4j, an ASL v2 licensed open source project.