openxml

Do we need Office Installation to work with OpenXML?

梦想的初衷 提交于 2020-07-05 07:04:05
问题 I am working with OpenXML manipulating the document. Do we need to have office installed for opening document through OpenXML? 回答1: No. You only need to have a reference to the library that provides all the OpenXML functionality. That library is not dependant on Office. 来源: https://stackoverflow.com/questions/3015272/do-we-need-office-installation-to-work-with-openxml

Add Conditional Formatting OpenXML C#

主宰稳场 提交于 2020-06-26 05:45:30
问题 How can I add conditional formatting in OpenXML using C# .Net. I would like the following conditions applied: =INDIRECT("D"&ROW())="Disapproved" then the rule should apply to: =$1:$3,$N$4:$XFD$4,$5:$1048576 I have my function setup like so: using (SpreadsheetDocument document = SpreadsheetDocument.Open(openFileDialog1.FileName, true)) { // apply conditions here } 回答1: To add conditional formats, you need to add a ConditionalFormatting instance to the Worksheet . This object will hold the list

String split with specified string without delimiter with text in middle

不羁岁月 提交于 2020-06-17 15:26:07
问题 This is in continuation with post - String split with specified string without delimeter Use case #1: When searchedText is beginning / or in the end of the (watch) , if fragments value is empty I replace with searchText and it works string watch = "Arrests as cops bust $100m money-laundering gang"; string searchedText = "Arrests as cops bust $100m"; string[] fragments = watch.Split(new string[] { searchedText }, StringSplitOptions.None); Use case #2: when searchedText is in between of the

Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document

廉价感情. 提交于 2020-04-09 20:31:26
问题 I'm using the OpenXml namespace in my application. I'm using this to read the XML within an Excel file. This works fine with certain excel files but on others I get a run time error saying Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document. I get the run time on the following line using (var spreadsheet = DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(filePathCopy, true)) I'm not sure why it works for some Excel files and doesn't work on others. 回答1:

Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document

我与影子孤独终老i 提交于 2020-04-09 20:31:03
问题 I'm using the OpenXml namespace in my application. I'm using this to read the XML within an Excel file. This works fine with certain excel files but on others I get a run time error saying Invalid Hyperlink: Malformed URI is embedded as a hyperlink in the document. I get the run time on the following line using (var spreadsheet = DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(filePathCopy, true)) I'm not sure why it works for some Excel files and doesn't work on others. 回答1:

Docx4j 添加页码

回眸只為那壹抹淺笑 提交于 2020-03-06 11:22:38
Office 2007 之后使用 XML 格式来存储文档数据,这个变化其实是非常不错的。如何操作这些XML生成文件呢?或许你还在使用 POI,也有可能你在使用已经放弃更新的 iText (只是doc已经放弃更新,PDF持续更新),但是我觉得,你可以选择使用 Docx4j,这是个不错的开源软件,国内很少使用而已。 下面就简单的使用 docx4j添加页码的代码做一个简单的介绍。 /** * 创建页脚(分页信息) */ public static void createFooter(WordprocessingMLPackage wordMLPackage) throws Exception { Relationship relationship = DocxUtil.createFootPart(wordMLPackage); DocxUtil.createFootReference(wordMLPackage, relationship); } /** * 创建页脚的组件 */ public static Relationship createFootPart( WordprocessingMLPackage wordprocessingMLPackage) throws Exception { FooterPart footerPart = new FooterPart();

OpenXML how to check if a row is empty in a sheet

ⅰ亾dé卋堺 提交于 2020-02-25 05:28:07
问题 I want to check if a row beside the header row is empty in a spreadsheet. If it's empty, I want to delete the sheet. So far I can only get it to look at cell A2 and check if it empty, but is there a way to check the entire row? Thanks private void CheckForEmptyRow(WorkbookPart wbp, string sheetId) { Sheet sheet = wbp.Workbook.Descendants<Sheet>().FirstOrDefault(s => s.Id == sheetId); WorksheetPart wsp = (WorksheetPart).(wbp.GetPartById(sheetId)); Cell cell = wsp.Worksheet.Descendants<Cell>()

OpenXML 2.0 Gets wrong cell value

社会主义新天地 提交于 2020-02-22 07:32:46
问题 I'm having a bit of a problem reading a value from an Excel 2010 worksheet. On a standard Excel 2010 worksheet I have a cell with the currency format with two decimal places and the value 1270,14 € . When I read this value on OpenXML 2.0 (C# code) I get 1270.1400000000001 instead of the original 1270.14 . The same happens with other values on any cell with the same formating. Get value from cell OpenXML code: private string GetCellValue(string column, int row) { column = column.ToUpper(); var

OpenXML 2.0 Gets wrong cell value

佐手、 提交于 2020-02-22 07:30:12
问题 I'm having a bit of a problem reading a value from an Excel 2010 worksheet. On a standard Excel 2010 worksheet I have a cell with the currency format with two decimal places and the value 1270,14 € . When I read this value on OpenXML 2.0 (C# code) I get 1270.1400000000001 instead of the original 1270.14 . The same happens with other values on any cell with the same formating. Get value from cell OpenXML code: private string GetCellValue(string column, int row) { column = column.ToUpper(); var

Why Office OpenXML splits text between tags and how to prevent it?

末鹿安然 提交于 2020-02-20 09:40:09
问题 I'm currently trying to work with docx files using PHPWord library and its templating system. I have found and updated someones (cant remember the name, but its not important) path to this library that can work with tables (replicate its rows and then use standard setValue() from PHPWord on each of row). If i create my own document, the data in xml is in normal structure, so the variable to be replaced ${variable} is in its own tag like this: <w:tbl> <w:tr> ... ${variable} </w:tr> </w:tbl> I