Menu

DataSet to Excel in C# Without a Row Loop: NPOI and IronXL
📰

DataSet to Excel in C# Without a Row Loop: NPOI and IronXL

DEV Community: dotnet·IronSoftware·about 8 hours ago
#xV3XYRqH
#devtodotnet#devto#dev#table#workbook
Long article (1147 words) — no AI summary yet.
Reading 0:00
15s threshold

A scheduled job fills a DataSet with one table per warehouse zone, and by morning the floor supervisors expect nightly-stock-count.xlsx in a shared folder. To export data to Excel in C# from that DataSet, the code has to turn tables into sheets, columns into a header row and rows into cells, and the question is how much of that the library does.

NPOI brings the Apache POI project to .NET and reads and writes the .xls, .xlsx and .docx formats. We walk through its export route for the stock count and then the same export in IronXL.

How does NPOI start the stock count workbook?

With a workbook object typed by its interface. XSSFWorkbook is the .xlsx class, and the variable is typed as IWorkbook so the same code can target the older .xls format.

using NPOI . SS . UserModel ; using NPOI . XSSF . UserModel ; using System . Data ; using System .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.