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
2
votes
1 answer

Downloading from Stream in Blazor Server Fails

While attempting to construct an Excel file using ClosedXML, I have come across some unexpected behavior regarding memory streams. In the debugger, I can see that MemoryStream ms is being populated by the wb.SaveAs() function. However, when passing…
Steve W
  • 416
  • 1
  • 3
  • 19
2
votes
0 answers

ClosedXML How to get pivot table range?

I need to get the latest row used by a pivot table. I tried: mysheet.LastRowUsed().RowNumber(); and mypivot.TargetCell.Address.RowNumber but it doesn't seem to be working. In Office object model the PivotTable has a TableRange2 property where you…
2
votes
1 answer

How to use DataTable as ItemsSource of my DataGrid

I want to load an Excel-file into my DataGrid. Using ClosedXML. I have this method: public static DataTable ImportExceltoDataTable(string filePath, string sheetName) { using (XLWorkbook wb = new(filePath)) { IXLWorksheet ws =…
Ole M
  • 317
  • 1
  • 17
2
votes
0 answers

How can I set IgnoredErrors in ClosedXML to prevent warnings in Excel 'the number in this cell is formatted as text'

I have DataTable with a string column with values that happen to look like numbers "0009.0" (accountants, go figure). I create an xml file based on this DataTable using ClosedXML .Worksheet.Add(table). When I open an spreadsheet in Excel I see…
Mark Nadig
  • 4,901
  • 4
  • 37
  • 46
2
votes
0 answers

ClosedXML insertTable formatting and order

I have a .NET Core 3.1 WebApp using ClosedXML to export data to Excel. So far I'm very impressed. I use EFCore to map my query result to a class and that data gets exported: worksheet.Cell(1, 1).InsertTable(data, false); I already figured out I can…
Paul Meems
  • 3,002
  • 4
  • 35
  • 66
2
votes
0 answers

How to Spin up a new app domain in an SSIS Script Task for a Dynamically Loaded Assembly

I have built an assembly that make calls to the ClosedXML library. Everything works perfectly until I have to export large Excel files, then things go south and I receive the following exception: System.IO.IsolatedStorage.IsolatedStorageException:…
rickmanalexander
  • 599
  • 1
  • 6
  • 17
2
votes
0 answers

Closed XML Report, horizontal and vertical table

I found horizontal table example here: https://closedxml.github.io/ClosedXML.Report/docs/en/Flat-tables.html But data was arranged in a way that every entry on a list was a row and each row had array and that array was this dynamic length horizontal…
kkamil4sz
  • 431
  • 1
  • 5
  • 19
2
votes
2 answers

how to attach a file in a response from web API

I need to generate a Excel file in my webAPI in ASP.NET Core with the data received from a aurelia web app. The flow is this: In frontend I make the request Print(printData: PrintData) { return this.http .fetch(`planning/Print`, { method:…
kintela
  • 1,283
  • 1
  • 14
  • 32
2
votes
1 answer

Sort a table in ClosedXML while keeping header row

I've tried a few methods of sorting in ClosedXML but they've all had the same results: the first row of data becomes the new header in excel. Here's the code I've used so far: Dim dtChangedScores As New…
rgorr
  • 331
  • 3
  • 18
2
votes
0 answers

Move a Range in ClosedXML

I have gone all through their Wiki and cannot find an option to move a range or even to paste a range. I see copy but no paste. I know I can use .Value = .Value but that will not work in my case. I have Columns like this: BDM | EQ_CODE | PC_CODE |…
djblois
  • 963
  • 1
  • 17
  • 52
2
votes
1 answer

Applying multiple filters in ClosedXML (SetAutoFilter)

I am applying filters for multiple columns via ClosedXML; however, only the last one is applied. Those filters work when they are alone. How can I apply all of them? I found similar question here ClosedXML Excel filter rows by values in multiple…
D Ace
  • 21
  • 2
2
votes
2 answers

Write in a cell full time

I have a variable time which contains string with time in format h:m:s.ms I was trying to write in a cell this time, but when I open excel I saw smth like 12:34:14 PM. But I want to see 12:34:14.1354 How can I solve this problem? var line =…
Anthony14
  • 105
  • 6
2
votes
1 answer

Time format Validation in ClosedXML

I'm Creating Excel file using ClosedXMl, and want to set alert message on entering Time format other than "HH:MM". I have tried below code but after entering "1" also it's not showing error message but same is working fine for Date format. …
Teja
  • 55
  • 5
2
votes
2 answers

C# Find empty cells and write them inside with ClosedXml

I have this problem, I have installed ClosedXml: I have an Excel file already created and populated, now I should find the blank line below the already populated one and write some data Example: [A, 1] = name; [B, 1] = surname; the next line will be…
Mrpit
  • 101
  • 1
  • 7
2
votes
1 answer

Closedxml: can't download file and immediately send it via mail

I want to download an excel file and automatically send the file to a mailadress aswell. Downloading the file works, but when I include the code for sending mails, it throws a FileNotFoundException: 'Could not find file…
iCV
  • 547
  • 1
  • 8
  • 29