openxml

Copying a worksheet in OpenXML that has previously been modified

让人想犯罪 __ 提交于 2019-12-04 19:41:31
I have followed the routine used here to copy a worksheet in a workbook into the same workbook by using .AddPart<>() and a temporary workbook to serve as a middleman, but have come up with some issues. Prior to copying the worksheet, I have made modifications to it. However, the copied version of the worksheet retains the original sheet, not the modified one. Here's the code: Document = SpreadsheetDocument.Open(filename, true); SetupPages(0, nSections); CopySheet(1); SetupPages() simply gets a worksheet which has a table with only one row and then copies that row nSections - 1 times, so that

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

Generating docx file from HTML file using OpenXML

前提是你 提交于 2019-12-04 17:51:16
I'm using this method for generating docx file: public static void CreateDocument(string documentFileName, string text) { using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(documentFileName, WordprocessingDocumentType.Document)) { MainDocumentPart mainPart = wordDoc.AddMainDocumentPart(); string docXml = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?> <w:document xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main""> <w:body><w:p><w:r><w:t>#REPLACE#</w:t></w:r></w:p></w:body> </w:document>"; docXml = docXml.Replace("#REPLACE#", text); 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

how to calculate the rotation value for the MS Office Powerpoint Shapes from the xml data given

瘦欲@ 提交于 2019-12-04 16:24:47
I want to get the proper rotation value to draw the shape of the MS office Powerpoint 2007 file from the given OOXML data as below : <p:sp> <p:nvSpPr> <p:cNvPr id="3" name="Rectangle 66" /> <p:cNvSpPr> <a:spLocks noChangeArrowheads="1" /> </p:cNvSpPr> <p:nvPr /> </p:nvSpPr> <p:spPr bwMode="auto"> ***<a:xfrm rot="5400000">*** <a:off x="2443049" y="-1042472" /> <a:ext cx="304800" cy="4419600" /> </a:xfrm> <a:prstGeom prst="rect"> <a:avLst /> </a:prstGeom> <a:ln> <a:headEnd /> <a:tailEnd /> </a:ln> </p:spPr> The value of rotation is given as "xfrm rot = 5400000". Considering this, its proper

Excel accepts some characters whereas OpenXml has error

孤街醉人 提交于 2019-12-04 16:11:37
i have a string that i want to export on excel file with openxml component in C#. My text has '\u001f' character and openxml has error with this character. error text: "hexadecimal value 0x1f, is an invalid character". i copy that test directly to excel and no problem and copy is success. Does OpenXml have configs for solving this problem or How i can solve this problem. thanks. You need to write it using the format _xHHHH_ where H represents a hexadecimal character. In your particular instance you need to set the value to "_x001F_" . From the documentation for a Cell Value : The possible

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.

Horizontal Text alignment in Word using OpenXml Sdk 2.0

眉间皱痕 提交于 2019-12-04 12:42:56
I need another help... My export function exports my report as a table in word. I need to apply horizontal alignment property for each cell. The Code I wrote for exporting is given below. Tbl is a textblock which I am using in my report. I wrote Alignment code here. But doesn't works.. Please help me to accomplish this task using OpenXML SDk 2.0 using Word = DocumentFormat.OpenXml.Wordprocessing; WordprocessingDocument WordDoc = WordprocessingDocument.Create(SavePath, WordprocessingDocumentType.Document); MainDocumentPart mainDocument = WordDoc.AddMainDocumentPart(); mainDocument.Document =

Need suggestions on how to extract data from .docx/.doc file then into SQL Server

☆樱花仙子☆ 提交于 2019-12-04 12:16:56
I'm suppose to develop an application for my project, it will load past-year examination / exercises paper (word file), detect the sections accordingly, extract the questions and images in that section, and then store the questions and images into the database. (Preview of the question paper is at the bottom of this post) So I need some suggestions on how to extract data from a word file, then inserting them into a database. Currently I have a few methods to do so, however I have no idea how I could implement them when the file contains textboxes with background image. The question has to link