openxml-sdk

Replacing bookmarks in docx file using OpenXml SDK and C++/CLI

孤街浪徒 提交于 2019-12-11 07:58:44
问题 I am trying to replace bookmark in docx with text in c++\cli using open xml SDK concept. The below piece of code will fetch bookmarks from word document and checks whether the bookmark matches the string “VERSION” if it is true, it is replaced with the string “0000” in the docx file. Paragraph ^paragraph = gcnew Paragraph(); Run ^run = gcnew Run(); DocumentFormat::OpenXml::Wordprocessing::Text^ text = gcnew DocumentFormat::OpenXml::Wordprocessing::Text(“0000”); run->AppendChild(text);

OpenXML SpreadsheetML Sideways text

你离开我真会死。 提交于 2019-12-11 07:28:37
问题 I'm trying to figure out how to get text to print sideways in a spreadsheet cell in OpenXML. I'm thinking it can be done somehow with the ExtendedProperties of the Cell class. here's what I've got. Cell cell = GetCell(worksheetPart.Worksheet, columnName, rowIndex); cell.DataType = CellValues.InlineString; cell.InlineString = new InlineString() { Text = new Text(textToInsert) }; //fictitious method cell.ExtendedAttributes.SpinSideways(); worksheetPart.Worksheet.Save() 回答1: Styles for cells are

Unable to read Shapes from DOCX file using OpenxmlSDK

我只是一个虾纸丫 提交于 2019-12-11 07:28:17
问题 I have a requirement where in I have to parse a DOCX file and extract all the text and images. I am using OpenxmlSDK 2.5 to achieve this. I am able to parse the images and text but the DOCX also have a group of Shapes which I trying to parse and convert them to Drawing images, which is giving me wrong results. Here is the Sample docx file which I am trying to parse. I referred the this Stack overflow discussion and tried the same way but no luck. The resulting DOCX which I am creating with

how to get page numbers based on openxmlelement

南笙酒味 提交于 2019-12-11 06:05:39
问题 For a Paragraph object, how can I determine on which page this is located using the Open XML SDK 2.5 ? I've obtained all child elements in my document and fetched innertext also, using this. foreach (var i in mainPart.Document.ChildElements.FirstOrDefault().ChildElements) { ParagraphElements.Add(i); //openxmlelement list } I want to get page number for corresponding paragraph. for example, I have "this is heading 1" marked as style Heading 1 and this will be updated in TOC. so there I need to

Create openxml document dynamically

孤街醉人 提交于 2019-12-11 05:46:45
问题 I am trying to build a openxml document dynamically, basically I have some classes responsible for creating the sections of my document (tables,paragraph...) then I need to have another class that builds my document, in my case I called it doc, and my other classes are docTable,docRun ... So at the moment I have this: DocRun projectNameTitle = new DocRun(); Run projectNameTxt = disclaimerDescription.createParagraph(document.projectName, SUBTITLECOLOR, FONTSIZESUBTITLE,FONTTYPE); DocRun

Copy vba code to another xlsm file using Open XML from a template xlsm file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:06:46
问题 I use this code to add VbaPart of the template xlsm file into another. When I open the vb section duplicate entries get added for each sheet as well as the "ThisWorkBook". Below is the screen shot of how it looks in the developer tab And below is the code that I use: using (SpreadsheetDocument myDoc = SpreadsheetDocument.Open(convertDocumentFile, true)) { VbaProjectPart extendedPart = FindPart(myDoc); if (extendedPart != null) myDoc.DeletePart(extendedPart); if (vbaPart != null) myDoc

Edit Word bookmark changes the font

核能气质少年 提交于 2019-12-11 04:59:21
问题 I have a C# program that generates documents using OpenXml. It replaces bookmarks with values using the following method : private void FillBookmark(BookmarkStart bookmark, string value) { var text = new Text(value); bookmark.RemoveAllChildren(); IEnumerable<OpenXmlElement> elementsAfter = bookmark.ElementsAfter(); IEnumerable<OpenXmlElement> insideBookmark = elementsAfter.TakeWhile(element => !(element is BookmarkEnd)); foreach (OpenXmlElement element in insideBookmark) { element

Set text value using SharedStringTable with xml sdk in .net

南楼画角 提交于 2019-12-11 04:48:17
问题 I have a piece of code (below) that can get the text of an specific cell in excel, but I don't know how to modify this text to change the cell text. public static void UpdateTextCell(string docName, string text, uint rowIndex, string columnName, string sheetName) { // Open the document for editing. using (SpreadsheetDocument spreadSheet = SpreadsheetDocument .Open(docName, true)) { WorksheetPart worksheetPart = GetWorksheetPartByName(spreadSheet, sheetName); if (worksheetPart != null) {

C#, Write XLSX using OpenXmlWriter and Open XML SDK

谁说我不能喝 提交于 2019-12-11 03:58:11
问题 In C#, the following program compiles and runs, but it doesn't write anything in the excel output file. I got it working without the OpenXmlWriter but I started running out of memory so I have to switch to the OpenXmlWriter according to this http://blogs.msdn.com/b/brian_jones/archive/2010/06/22/writing-large-excel-files-with-the-open-xml-sdk.aspx class Program { static void Main(string[] args) { File.Copy("book.xlsx", "output.xlsx", true); WriteValuesSAX("output.xlsx", 10, 10); } static void

Reading decimal value from an Excel cell (in C#)

喜夏-厌秋 提交于 2019-12-11 03:29:19
问题 When reading values from Excel cells that contain decimals, I am running into the following issue: If I enter 9.95 in the cell in Excel, CellValue.InnerText in C# returns "9.9499999999999993" How can I get the actual value that was entered, meaning "9.95", knowing that the code that's trying to get these values does not know ahead of time that it's a decimal or indeed a number. 回答1: You cannot retrieve the actual value entered for a numeric entry. I don't believe that is stored anyplace. The