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
15
votes
6 answers

How to disable autofilter in closedXml c#?

I am facing a weird problem in closedXML library. I am exporting a datatable to .xlsx (excel file) using closedXML library. By default, autofilter is enabled in the library. I want to disable or remove the autofilter and export only the…
CST RAIZE
  • 428
  • 1
  • 5
  • 18
14
votes
4 answers

Can I save an EXCEL worksheet as CSV via ClosedXML?

Is it possible to save a worksheet of a workbook as CSV via ClosedXML? For example: var workbook = new XLWorkbook(fileName); IXLWorksheet worksheet; workbook.Worksheets.TryGetWorksheet(sheetName, out worksheet); How to Save it as CSV?
pencilCake
  • 51,323
  • 85
  • 226
  • 363
11
votes
1 answer

ClosedXML iterate Worksheets programmatically.

In my Workbook, I have 4 worksheets with different tab names. Say if they are named as follows: First, Second, Third, Fourth. I could not find online how to iterate through each of the worksheet with say for for loop. As I am iterating, I would also…
Nate Pet
  • 44,246
  • 124
  • 269
  • 414
11
votes
2 answers

In ClosedXML, is there anyway to get the column letter from column header name?

I have an excel worksheet that has column headers and I don't want to hard code the column letter or index so I am trying to figure out how I could make it dynamic. I am looking for something like this: var ws = wb.Worksheet("SheetName"); var…
leora
  • 188,729
  • 360
  • 878
  • 1,366
11
votes
2 answers

Set lock true for group of cells

I'm using closedxml to export excel.. Now i can protect (Lock cell) cell using the following function, workSheet.Cell(rowIndex,column).Style.Protection.SetLocked(true); I want to set group of cells.. Is that Possible in closedxml ?
user3035874
10
votes
2 answers

Read Excel worksheet into DataTable using ClosedXML

I would like to read the contents of an Excel worksheet into a C# DataTable. The Excel worksheet could have a variable numbers of columns and rows. The first row in the Excel worksheet will always contain the column names but other rows may be…
webworm
  • 10,587
  • 33
  • 120
  • 217
10
votes
6 answers

ClosedXML - Could not load file or assembly

I am trying to use ClosedXML to produce excel documents within an application however when ever I try to run it I receive a could not load file or assembly server error. Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0,…
Ethel Patrick
  • 885
  • 7
  • 18
  • 38
10
votes
1 answer

ClosedXML: Working with percents, 1 decimal place and rounding?

I am attempting to use C# and ClosedXML to enter data into an excel sheet. I have found most of the things I am looking for, however I am having some issues getting ClosedXML to take care of the number of decimal places as well as rounding the…
sec_goat
  • 1,272
  • 1
  • 12
  • 20
9
votes
5 answers

Reach ActiveX or Form objects (textbox) from codebehind in an Excel document

There are several textboxes in an excel file as ActiveX objects and I want to reach them from codebehind. I am using ClosedXML for other fields, but I am open for other suggestions.
Pecheneg
  • 768
  • 3
  • 11
  • 27
9
votes
1 answer

Multiple Pivot tables ClosedXML

Using latest Closed XML (0.76) on Net 4.5.1 Created a Worksheet with a table by: DataTable Table = ... var DataWorkSheet = Workbook.Worksheets.Any(x => x.Name == "Data") ? Workbook .Worksheets .First(x => x.Name == "Data") : …
Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
9
votes
3 answers

ClosedXML Format cell to contain formula

I'm hoping someone can help me with ClosedXML as I'm new to Excel exporting and from what I've seen of ClosedXML the documentation is fairly limited in certain areas. At the moment I'm putting data into a Datatable, formatting rows to their correct…
Verno
  • 428
  • 1
  • 5
  • 20
8
votes
3 answers

Assembly Load error from DocumentFormat.OpenXml

I get an error using the Microsoft ClosedXml and DocumentFormat.OpenXml NuGet utility packages. After I updated these NuGet packages, (from version 2.7.2 to version 2.8.1), I now get this exception: Exception System.IO.FileLoadException: Could not…
Charles Bretana
  • 143,358
  • 22
  • 150
  • 216
8
votes
3 answers

Save as pdf using ClosedXML

Does ClosedXML have any function that can be used to save an excel file as PDF? Currently i am using ClosedXML to create and populate the excel file and then using Interop to save as PDF. But since Interop depends on the MS Office installed on the…
ilmenite
  • 199
  • 1
  • 3
  • 11
8
votes
1 answer

Is it possible to make a excel sheet right to left with closedXML

I am using closedXML to generate a XML file(in arabic) and i need this file to be in right to left layout how can it do this in closedXML. XLWorkbook wb = new XLWorkbook(); var ws = wb.Worksheets.add("Sheet1"); ws.Cell(1,1).Value =…
Asanka Madushan
  • 463
  • 8
  • 17
8
votes
3 answers

Export big amount of data from XLSX - OutOfMemoryException

I am approaching to export a big amount of data (115.000 rows x 30 columnd) in Excel OpenXML Format (xlsx). I am using some libraries like DocumentFormat.OpenXML, ClosedXML, NPOI. With each of this, OutOfMemoryException is thrown because the…
Gianluigi Liguori
  • 351
  • 1
  • 5
  • 13
1
2
3
40 41