openxml-sdk

Error while creating open XML excel sheet from ASP.NET MVC

早过忘川 提交于 2019-12-05 05:20:03
问题 I am trying to export an Excel sheet from ASP.NET MVC4 using Open XML SDK 2.5. I am trying to use standard example from MSDN, extention = "xlsx"; response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; response.AddHeader("Content-Disposition",String.Format("attachment; filename={0}.{1}", fileName, extention)); using (MemoryStream mem = new MemoryStream()) { // Create a spreadsheet document by supplying the filepath. // By default, AutoSave = true, Editable

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

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

Adding to WordprocessingDocument opened from MemoryStream without getting “Memory stream is not expandable”?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 02:31:42
问题 Using Open XML SDK, the following gives "Memory stream is not expandable" when I reach the line FeedData(msData): // Bytes in, bytes out internal static byte[] UpdateDataStoreInMemoryStream(byte[] bytes, XmlDocument xdocData) { using (var msDoc = new MemoryStream(bytes)) { using (WordprocessingDocument wd = WordprocessingDocument.Open(msDoc, true)) { MainDocumentPart mdp = wd.MainDocumentPart; CustomXmlPart cxp = mdp.CustomXmlParts.SingleOrDefault<CustomXmlPart>(); using (MemoryStream msData

How to add a row to Excel using OpenXML SDK 2.0?

﹥>﹥吖頭↗ 提交于 2019-12-04 19:18:13
I am new to OpenXML and have been struggling with adding a new row with cell data in A1 after a row (with cell data as well) has been added. So essentially I want to insert "Test" in "row 1" column "A1" and "test" in "row 2" column "A1". Here is my code, it looks sound and creates the file however Excel does not open it. I opened it in OpenOffice and it only shows one row instead of two. When I comment out appending row2 to the sheetdata, it works fine. So I am thinking am creating the 2nd row incorrectly. Any help is appreciated. Thank you in advance. Here is the code: using

Defining paragraph with RTL direction in word file by OpenXML in C#

假如想象 提交于 2019-12-04 17:33:47
How to set the right-to-left direction for a paragraph in word with OpenXML in C#? I use codes below to define it but they won't make any change: RunProperties rPr = new RunProperties(); Style style = new Style(); style.StyleId = "my_style"; style.Append(new Justification() { Val = JustificationValues.Right }); style.Append(new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft }); style.Append(rPr); and at the end I will set this style for my paragraph: ... heading_pPr.ParagraphStyleId = new ParagraphStyleId() { Val = "my_style" }; But is see no changes in the output file. I

Working with Office “open” XML - just how hard is it?

ぃ、小莉子 提交于 2019-12-04 14:01:28
问题 I'm considering replacing a (very) large body of Office-automation code with something that works with the Office XML format directly. I'm just starting out, but already I'm worried that it's too big a task. I'll be dealing with Word, Excel and PowerPoint. So far I've only looked at Word and Excel. It looks like Word documents should be reasonably easy to manipulate, but Excel workbooks look like a nightmare. For example... In Word, it looks like you could delete a paragraph simply by

Is there an alternative to open-xml sdk to generate word documents

久未见 提交于 2019-12-04 13:47:22
I'm trying to generate word documents using open xml sdk. When the documents are small this is no problem (and rather easy). When the documents become larger (+500 pages) I notice the peformance (duration, memory usage, ...) goes down significantly. Googling this problem I came across some posts that point out the same problem. For excel there is a solution with spreadsheetgear . I would like to know if there is a word alternative to this or if there are other solutions to generate word documents? Thanks, Jelle I've written a blog post series on generating Open XML WordprocessingML documents.

OpenXML SDK Inject VBA into excel workbook

巧了我就是萌 提交于 2019-12-04 13:44:26
问题 I can successfully inject a piece of VBA code into a generated excel workbook, but what I am trying to do is use the Workbook_Open() event so the VBA code executes when the file opens. I am adding the sub to the "ThisWorkbook" object in my xlsm template file. I then use the openxml productivity tool to reflect the code and get the encoded VBA data. When the file is generated and I view the VBA, I see "ThisWorkbook" and "ThisWorkbook1" objects. My VBA is in "ThisWorkbook" object but the code