openxml-sdk

openxml sdk excel how to parse and calculate formula

纵然是瞬间 提交于 2019-12-08 12:18:20
问题 I have formula cell in excel file that has the formula =SUM(C2:C3). From the web application hosted on remote webserver in the cloud, that does not have Excel installed, I would pass in values for C2 and C3. I can also determine the exact formula in excel. How do I parse this formula programmatically in c# so that I could get the result of 6 if the input values of C2 and C3 were 2 and 4 respectively? What if the formula is very complex, what is the best way to parse the formula and calculate

Editing custom XML part in word document sometimes corrupts document

对着背影说爱祢 提交于 2019-12-08 11:58:33
问题 We have a system that stores some custom templating data in a Word document. Sometimes, updating this data causes Word to complain that the document is corrupted. When that happens, if I unzip the docx file and compare the contents to the previous version, the only difference appears to be the expected change in the customXML\item.xml file. If I re-zip the contents using 7zip, it seems to work OK (Word no longer complains that the document is corrupt). The (simplified) code: void

OpenXML library save excel file

坚强是说给别人听的谎言 提交于 2019-12-08 07:08:41
问题 I have the following code and its not saving the values to cell and also in file. It shows value in cell.cellvalue field but its not writing it to excel. I have no idea how to save the file. I used OpenXml-SDK and I am writing datatable values to each cell/row of created spreadsheet document. using (SpreadsheetDocument ssd=SpreadsheetDocument.Open(Server.MapPath(@"\ExcelPackageTemplate.xlsx"),true)) { WorkbookPart wbPart = ssd.WorkbookPart; WorksheetPart worksheetPart = wbPart.WorksheetParts

OOXML SDK illegal character replacements

为君一笑 提交于 2019-12-08 06:46:16
问题 I am having an issue with creating an XLSX document with the Open XML SDK 2.0 from MS. My issue is that I need to display some of these illegal characters in the excel sheet, but if I just add them to the sheet, the document will not load. I am using this function private static string ProcessString(string str) { return System.Security.SecurityElement.Escape(str); } Which will give me Tom's ball instead of Tom's ball. (Well I haven't figured out how to get the latter as the excel

Insert in Word bookmarks - Open XML SDK

匆匆过客 提交于 2019-12-08 05:12:58
问题 I have to learn some things abount Open XML SDK, working with C#. Things like @Ahmad Mageed answered here: Insert OpenXmlElement after word bookmark in Open XML SDK I'm in a similar situation, but in my case I need to insert text or elements inside the bookmark...(not after it) Need some help please. (Sorry for my English) Thanks. 回答1: Absolutely. Check out the "Bookmarks" section on Eric White's article Inserting / Deleting / Moving Paragraphs in Open XML Wordprocessing Documents. Here's a

Write data into TextInput elements in docx documents with OpenXML 2.5

梦想与她 提交于 2019-12-08 04:44:56
问题 I have some docx documents. I read them with OpenXML 2.5 SDK and I search for the TextInput s in each doc. byte[] filebytes = System.IO.File.ReadAllBytes("Test.docx"); using (MemoryStream stream = new MemoryStream(filebytes)) using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(stream, true)) { IEnumerable<FormFieldData> fields = wordDocument.MainDocumentPart.Document.Descendants<FormFieldData>(); foreach (var field in fields) { IEnumerable<TextInput> textInputs = field

Relationship between Sheet and Worksheet

倾然丶 夕夏残阳落幕 提交于 2019-12-08 04:14:16
问题 As to MSDN the basic document structure of a SpreadsheetML document consists of the Sheets and Sheet elements, which reference the worksheets in the Workbook. For example, there is one workbook with sheets: <workbook xmlns=http://schemas.openxmlformats.org/spreadsheetml/2006/main xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <sheets> <sheet name="MySheet1" sheetId="1" r:id="rId1" /> <sheet name="MySheet2" sheetId="2" r:id="rId2" /> </sheets> </workbook> And

OpenXML SDK2.5 (Excel): How to determine if a cell contains a numeric value?

落花浮王杯 提交于 2019-12-08 01:01:50
问题 I am busy developing a component which imports data from a MS Excel (2016) file. This component uses the MS OpenXML SDK2.5 library. The end-users installation of MS Excel is based on Dutch country / region settings. The file contains, among others, a column with financial data (numeric). The position of this column is not known in advance. To determine if a cell contains numeric data I evaluate the property Cell.DataType (of type CellValues, which is an enum). At first it seems that this

How change excel 2007 document orientation to landscape by OpenXML sdk

淺唱寂寞╮ 提交于 2019-12-08 00:13:35
问题 I need help with changing excel 2007 document orientation to landscape. I have not found any helpful information about this. I am using OpenXML SDK for this. The only thing I have found: when I create a new Worksheet I should set PageSetup() { Orientation = OrientationValue.Landscape}; But this doesn't help. Can anybody help with this problem? Thank you. 回答1: You're on the right track with the OrientationValue.Landscape. You just need to loop through all worksheets and set the orientation

Changing the margins of a Word Document

时光总嘲笑我的痴心妄想 提交于 2019-12-07 17:51:57
问题 I have created a web part with a button that once clicked generates a word document containing the list item values of particular list. I want to be able to change the margins for the document (top, bottom margins), but I am unsure as to how to proceed. Can anyone shed some light on how to achieve this? So far the code I have is a as follows: void GenerateBadges_Click(object sender, EventArgs e) { string Title = null; string jobTitle = null; WordprocessingDocument document =