Questions tagged [closedxml]

ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files.

ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API.

ClosedXML provides a object oriented way to manipulate Excel 2007+ (.xlsx, .xlsm, etc) files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).

Online resources:

615 questions
8
votes
2 answers

How do you get ClosedXML to use conditional formatting with formulas?

According to the documentation you can add conditional formatting to a cell using the syntax: .AddConditionalFormat().WhenEquals("=B1") So I tried this: cell.AddConditionalFormat().WhenEquals("=F5=0") …
MadSkunk
  • 3,309
  • 2
  • 32
  • 49
8
votes
1 answer

ClosedXML .SaveAs(MemoryStream ms) does not progress when saving two .xlsm files (each about 7MB) at the same time

To reproduce the issue, I created a console project and below is the code in my Program.cs file: using System; using System.IO; using System.Threading; using ClosedXML.Excel; namespace TestSavingTwoBigFiles { public class Program { …
Ni Fang
  • 111
  • 1
  • 1
  • 5
8
votes
3 answers

How can I embed some VBA code into a spreadsheet created using ClosedXML?

I am using ClosedXML to generate spreadsheets from C# (asp.net-mvc) and it works great. I have one additional requirement so I wanted to get some feedback on how I could achieve this. I want to save as a macro enabled workbook and when I just give…
leora
  • 188,729
  • 360
  • 878
  • 1,366
7
votes
1 answer

How to use different colors of texts in same Excel cell using ClosedXML?

How to use different colors of texts in the same Excel cell using ClosedXML? worksheet.Cell(1,1).Value.Character[StartIndex, NoOfChar].Font.Color....?? ClosedXML doesn't have something like above, please help me to use two different font colors in…
WSk
  • 183
  • 4
  • 16
7
votes
3 answers

ClosedXML Adding Data to Existing Table

With ClosedXML I am trying to add data to an existing Excel Sheet In an Existing Table. The easy thing to do is to add a table to an excel sheet below is a quick example of how to do that. What I don't understand is if you already have a Table there…
scripter78
  • 1,117
  • 3
  • 22
  • 50
7
votes
1 answer

How to use a gradient fill (GradientFill) with ClosedXML

I'm working on a C#/ASP.NET web thing and want to do an Excel export. First I found OpenXML, made some first steps, but it's really hard to use. Now, I'm using ClosedXML and it's quite a relief - so far. I came up with the problem to have a gradient…
outofmind
  • 1,430
  • 1
  • 20
  • 37
6
votes
4 answers

Unable to insert minimum datetime as cell value in ClosedXML

ClosedXml does not allow to insert minimum datetime into cell. My datatable includes minimum datetime values that ClosedXml does not like. using (var workbook = new XLWorkbook()) { var dataTable = GetDataTable(); …
Pegaz
  • 367
  • 2
  • 12
6
votes
1 answer

ClosedXML - Carriage Return Within a Cell

I generate an Excel file with ClosedXML and I want to know how can I do a Carriage Return Within a Cell?
Kate
  • 145
  • 3
  • 12
6
votes
3 answers

How to read entire worksheet data in excel into DataTable using ClosedXml

Excel Worksheet contains 60K records. Needs to be read and store into DataTable. Currently reading row by row. Is there any other better way using ClosedXml. DataTable dt = new DataTable(); var wb = new XLWorkbook(fileName,…
kjana83
  • 398
  • 3
  • 16
6
votes
1 answer

Need to set a cell background color with ClosedXML in a PowerShell script

I am using PowerShell 3 and ClosedXML to write file information into an excel worksheet. In one of the cells I need to set the background color to a light blue (cornflower blue or 219, 229, 249 in the RGB). I have tried a variety of methods and,…
6
votes
1 answer

ClosedXML - Add a new row without overwrite data (first line)

I'm trying to add an empty row before filling my excel document. using (DataTable dt = new DataTable()) { sda.Fill(dt); using (XLWorkbook wb = new XLWorkbook()) { var ws = wb.Worksheets.Add(dt, "Report"); var…
Bigby
  • 119
  • 1
  • 3
  • 11
6
votes
1 answer

How to Remove header from datatable at the time of export to Excel?

From a datatable I want to remove headers. How can I remove headers or first row which includes the headers. if (dt.Rows.Count > 0) { using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt, "Customers"); …
Ganesh bagad
  • 83
  • 1
  • 2
  • 7
6
votes
1 answer

Create dropdown list using ClosedXML

I have implemented Excel template download in my project. I used ClosedXML. I have two excel sheets Sheet1: In this sheet, I have a column called Type in which I can create Dropdown List and it is the third column. Sheet2: In this sheet, I have a…
Vikash
  • 857
  • 1
  • 13
  • 32
6
votes
3 answers

Using closedXML C# library, How can I figure out what data is causing this error when trying to save

I have a C# app that exports to Excel using ClosedXML. It works fine but just ran into an issue where when i hit the : var ms = new MemoryStream(); workbook.SaveAs(ms); I get an exception: ' ', hexadecimal value 0x0B, is an invalid…
leora
  • 188,729
  • 360
  • 878
  • 1,366
6
votes
3 answers

ClosedXML add image

I am able to add in an image to an excel spreadsheet by using OpenXML. However for the rest of the program I use ClosedXML to add data. I can add data at a specific cell using the column and row index. If I can add an image to an excel (It currently…
Ayohaych
  • 5,099
  • 7
  • 29
  • 51
1 2
3
40 41