openxml

What .xlsx file format is this?

荒凉一梦 提交于 2019-12-23 03:52:14
问题 Using an existing SSIS package, I was trying to import .xlsx files we received from a client. I received the error message: External table is not in the expected format These files will open in XL When I use XL (currently XL2010) to Save As... the file without making any changes: The new file imports just fine The new file is 330% the size of the original file When changing .xlsx to .zip and investigating the contents with WinZip: The original file only has 4 .xml files and a _rels folder

How to replace the InnerText of a Comment

牧云@^-^@ 提交于 2019-12-23 03:38:31
问题 I've tried the following: comment.InnerText=comment.InnerText.Replace(comment.InnerText,new_text); Which doesn't work because we can only read the InnerText property. How do I effectively change the InnerText value so I can save the modifications to WordProcessing.CommentsPart.Comments and MainDocumentPart.Document ? EDIT: DocumentFormat.OpenXml.Wordprocessing.Comment is comment's class. EDIT 2: The method: public void updateCommentInnerTextNewWorkItem(List<Tuple<Int32, String, String>> list)

Mocking OpenXML with Moq

江枫思渺然 提交于 2019-12-23 02:38:45
问题 How should I test the following GetWorksheetPart method: public class ExcelDocument : IExcelDocument { private readonly string _filePath; public ExcelDocument(string filePath) { _filePath = filePath; } public WorksheetPart GetWorksheetPart(ISpreadsheetDocument excelDoc, string sheetName) { Sheet sheet = excelDoc.GetSheet(sheetName); if (sheet == null) { throw new ArgumentException( String.Format("No sheet named {0} found in spreadsheet {1}", sheetName, _filePath), "sheetName"); } return

How to add Conditional Formatting to an XML / Excel file?

跟風遠走 提交于 2019-12-23 02:33:03
问题 I'm generating an Excel file by writing the XML for it. I am almost done, but I can't get the conditional formatting to work the way I want. I want to apply a condition to certain cells. E.g. for each data row (not a header or footer), columns 7-13 should highlight red if they are greater than the value in Column 6. The code below works for the first data row only. How can I get it to apply to a set of rows? </Table> <ConditionalFormatting xmlns="urn:schemas-microsoft-com:office:excel">

Microsoft Word Document Controls not accepting carriage returns

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 01:35:17
问题 So, I have a Microsoft Word 2007 Document with several Plain Text Format (I have tried Rich Text Format as well) controls which accept input via XML. For carriage returns, I had the string being passed through XML containing "\r\n" when I wanted a carriage return, but the word document ignored that and just kept wrapping things on the same line. I also tried replacing the \r\n with System.Environment.NewLine in my C# mapper, but that just put in \r\n anyway, which still didn't work. Note also

Generating a Word Document with C#

北城余情 提交于 2019-12-22 18:52:05
问题 Given a list of mailing addresses, I need to open an existing Word document, which is formatted for printing labels, and then insert each address into a different cell of the table. The current solution opens the Word application and moves the cursor to insert the text. However, after reading about the security issues and problems associated with opening the newer versions of Word from a web application, I have decided that I need to use another method. I have looked into using Office Open

Generating a Word Document with C#

北城以北 提交于 2019-12-22 18:51:17
问题 Given a list of mailing addresses, I need to open an existing Word document, which is formatted for printing labels, and then insert each address into a different cell of the table. The current solution opens the Word application and moves the cursor to insert the text. However, after reading about the security issues and problems associated with opening the newer versions of Word from a web application, I have decided that I need to use another method. I have looked into using Office Open

Open XML - find and replace multiple placeholders in document template [duplicate]

吃可爱长大的小学妹 提交于 2019-12-22 17:30:38
问题 This question already has answers here : OpenXML tag search (3 answers) OpenXML Find Variables within Word doc and replace them (2 answers) Closed 5 days ago . I know there are many posts on SO about this topic, but none seems to treat this particular issue. I'm trying to make a small generic document generator POC. I'm using Open XML. The code goes like this: private static void ReplacePlaceholders<T>(string templateDocumentPath, T templateObject) where T : class { using (var

Add style to Excel in openxml

[亡魂溺海] 提交于 2019-12-22 11:35:29
问题 I want to set forecolor of the text in the excel document which I open to write the text. For that I tried : var stylesheet1 = spreadSheet.WorkbookPart.WorkbookStylesPart.Stylesheet; Fills fills1 = new Fills() { Count = (UInt32Value)5U }; Fill fill5 = new Fill(); PatternFill patternFill5 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor3 = new ForegroundColor() { Rgb = "#FF0000" }; patternFill5.Append(foregroundColor3); fill5.Append(patternFill5);

EPPlus not caluculating formula output after binding

感情迁移 提交于 2019-12-22 09:39:18
问题 I am using EPPlus. I am stuck at cell formulas. My code is below: ExcelPackage pck = new ExcelPackage(@"D:\MYSheets\EmptyFile.xlsx"); var ws = pck.Workbook.Worksheets["MySheet"]; ws.Cells["A3"].Value = "2.3"; ws.Cells["A4"].Value = "10.2"; ws.Cells["A5"].Formula = "=SUM(A3:A4)"; ws.Cells["A5"].Style.Numberformat.Format = "#,##0.00"; pck.Save(); When I open Excel, by default, A5 cell is not calculating the sum of A3 and A4. Unless I modify the A3 and/or A4 cells, the A5 cell remains not