Tech Blog

Coding

Generate large excel files in C#

By Yash chandvani2 min read
← Back to blog

Hi Folks! In this blog, we will learn how to generate large excel files in C# in an efficient manner.

What is an XLSX File?

Microsoft introduced the XLSX file format for Microsoft Excel documents with the release of Microsoft Office 2007. XLSX files have the capability to create virtual layouts and organize data boosts data analysis.

XLSX type of documents is a must for the companies that acquire data that is large in amount and needs organization. The advantage of this type is that one can organize and sort the data in different ways which help the team to get enriched information and more chances of information discovery. Furthermore, XLSX boosts the understanding of data by creating opportunities for users to view large amounts of data within a visually-simplistic format.

When users see the organized data in a meaningful layout of rows and columns, it helps them to gain valuable insights from it.

How to generate large excel files with a size of GB’s or TB’s?

So the answer to this question is the LargeXlsx library. LargeXlsx – A .net library to write large XLSX files. This library can be used to write huge amounts of data into an XLSX file with ease. This library will write files in a streamed manner, so that potentially huge files can be created while consuming a low, constant amount of memory.

Here is a snippet of code that writes a basic single-sheet Excel document:

using (var stream = new FileStream("SampleReport.xlsx", FileMode.Create, FileAccess.Write))
using (var xlsxWriter = new XlsxWriter(stream))
{
    xlsxWriter
        .BeginWorksheet("Sheet 1")
        .BeginRow().Write("EmployeeID").Write("Name").Write("Department")
        .BeginRow().Write(1).Write("Lorem").Write("Sales")
        .BeginRow().Write(2).Write("Ipsum").Write("Marketing")
        .BeginRow().Write(3).Write("Dummy").Write("Finance");
}
Generate large excel files in C#

This library supports more features related to the excel files such as,

  1. Supports all datatypes with custom formulas
  2. Customized font, size and color
  3. Cell validation with multiple sheets

To explore more about this library, please visit LargeXlsx

Keep reading

You may be interested in

Browse all articles →
Active Directory Federation Service
July 5, 20235 min read

Active Directory Federation Service

Active Directory Federation Service (ADFS) uses claims-based identity model to maintain application security and to implement federated identity. ADFS is a concept of Windows Server operating system, that provides users with single sign-on access to the application, those are located across organizational boundaries. For Example: We have 2 organizations – Organization 1 and Organization 2. […]

By Abinash MishraRead More →
Remote Access to Microsoft SQL Database Server
April 5, 20232 min read

Remote Access to Microsoft SQL Database Server

Remote access to a SQL server is important because it allows users to access the server from anywhere, at any time. This enables remote workers to access the data they need when they need it, even if they are not physically in the same location as the server. It also allows IT admins to access […]

By Malkeet SinghRead More →
Types of Load Balancer in AWS
February 6, 20235 min read

Types of Load Balancer in AWS

What is Load Balancing ? Load balancing is a critical component of any scalable and highly available Cloud or On-premise architecture. It helps distribute incoming traffic across multiple servers, improving the availability and scalability of a website or application. In the cloud, load balancing is offered as a service by various cloud providers such as […]

By Keerthik ShenoyRead More →