openxml

Conditional formatting color gradient with hard stops

回眸只為那壹抹淺笑 提交于 2019-12-04 00:18:33
问题 I have a column of data in an Excel sheet which has positive and negative values. What I want to be able to do is apply conditional formatting (a color gradient) from say dark green to light green for positive values and light red to dark red for negative values. However, I don't seem to be able to do that. If I apply a conditional format from, say, the largest value to zero, with zero as light green, then all the negative values will end up being light green too. Is there a way to make a

ClosedXML - Creating multiple pivot tables

﹥>﹥吖頭↗ 提交于 2019-12-03 23:30:23
I am trying to export some data to an excel sheet S1 whose data would be shown as Pivoted views in the next two sheets S2 and S3 . I am able to create a single pivot and it works perfect. But when I create two pivots, the consequent Excel file renders as corrupt. By corrupt I mean, On clicking yes, I get this - Here is the code I am using to create the pivots - using XL = ClosedXML.Excel; ... XL.XLWorkbook wb = new XL.XLWorkbook(); dsData = Session["ExportData"] as DataSet; var sheet1 = wb.Worksheets.Add("output table"); sheet1.Cell(1, 1).InsertTable(dsData.Tables[0], "output table", true); //

How to create a excel file with sheets in C#?

若如初见. 提交于 2019-12-03 22:16:07
I want to create an excel file say personinfo.xls with one work sheet say Person . Is there a way in C# to do it ? You can do that with MyXLS . I have used it in a few project with great success. Its opensource. Adriaan Stander Have you tried the Excel Interop? Is this for excel 2003/2007? If it is excel 2007 xml you can try Carlos SpreadsheetGear ExcelPackage (Codeplex) Try this class: using System; using System.Collections.Generic; using System.Text; using System.IO; using Excel = Microsoft.Office.Interop.Excel; using System.Reflection; using System.Threading; using System.Diagnostics; using

export to excel through mvc3

可紊 提交于 2019-12-03 22:14:14
Hello everyone i am trying to export some data to excel in the form of table in mvc3.Here is the class i am using to generate the excel file: //------------------------------------------------------------------------------ // <copyright file="ExcelDocument.cs" company="Microsoft"> // Copyright (c) Microsoft Corporation. All rights reserved. // </copyright> // <summary>The Export to Excel Document class.</summary> // ---------------------------------------------------------------------------- namespace ExporToExcel.Controllers.ControllerExtensions { using System; using System.IO; using System

Open xml replace text from word file and return memory stream using MVC

拜拜、爱过 提交于 2019-12-03 20:57:59
I have an word file that contain my specified pattern text {pattern} and I want to replace those pattern with new my string which was read from database. So I used open xml read stream from my docx template file the replace my pattern string then returned to stream which support to download file without create a temporary file. But when I opened it generated me error on docx file. Below is my example code public ActionResult SearchAndReplace(string FilePath) { MemoryStream mem = new MemoryStream(System.IO.File.ReadAllBytes(FilePath)); using (WordprocessingDocument wordDoc =

How to programmatically insert comments into a Microsoft Word document?

青春壹個敷衍的年華 提交于 2019-12-03 17:15:22
问题 Looking for a way to programmatically insert comments (using the comments feature in Word) into a specific location in a MS Word document. I would prefer an approach that is usable across recent versions of MS Word standard formats and implementable in a non-Windows environment (ideally using Python and/or Common Lisp). I have been looking at the OpenXML SDK but can't seem to find a solution there. 回答1: Here is what I did: Create a simple document with word (i.e. a very small one) Add a

How to read an .XLSX (Excel 2007) file using ADO.NET? I am finding “Could not find installable ISAM”-error

旧城冷巷雨未停 提交于 2019-12-03 15:32:52
I need to work in .net 2.0 . So I can't use OpenXML. This is my source code and I have already Installed AccessDatabaseEngine.exe . But still getting the exception: "Could not find installable ISAM". I have also tried "Extended Properties=Excel 8.0" in the connection string. static void Main(string[] args) { DataSet dataSet = new DataSet(); OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|Data Directory|\HSC.xlsx;Extended Properties=Excel 12.0;HDR=YES;"); OleDbDataAdapter dataAdapter= new OleDbDataAdapter("select * from [Sheet1$]", connection);

How much has Open XML caught on? [closed]

人走茶凉 提交于 2019-12-03 15:30:05
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . I'm curious as to how many people are using Open XML (OOXML) these days (either pure or via the SDK) in closed and commercial environments. I'm fairly aware of what's going on on the 'public web' (MSDN, OpenXMLDeveloper.org, etc.), but am wondering about SO people's

How to parse mathML in output of WordOpenXML?

*爱你&永不变心* 提交于 2019-12-03 15:12:55
I want to read only the xml used for generating equation, which i obtained by using Paragraph.Range.WordOpenXML . But the section used for the equation is not as per MathML which as i found that the Equation of microsoft is in MathML . Do I need to use some special converter to get desired xmls or are there any other methods? Hans You could use the OMML2MML.XSL file (located under %ProgramFiles%\Microsoft Office\Office15 ) to transform Microsoft Office MathML (equations) included in a word document into MathML . The code below shows how to transform the equations in a word document into MathML

Inserting text after a bookmark in openxml

╄→尐↘猪︶ㄣ 提交于 2019-12-03 13:39:43
I am looking for a way to insert some text after a bookmark in a word doc using openxml. So far, i have been able to locate the bookmark using the following: var bookmarks = mainPart.Document.Descendants<BookmarkStart>().ToList(); var bookMarkToWriteAfter = bookmarks.FirstOrDefault(bm => bm.Name == insertAfterBoomark.Name); This bookmark in the word doc is a selection of two lines in the doc. I have to insert some text right after the two line selection. I have tried to insert text using the following: var run = new Run(); run.Append(new Text("Hello World")); bookMarkToWriteAfter .Parent