ClosedXML is a .NET library for reading, manipulating and writing Excel files. ClosedXML is a fine library for exporting data to Excel. It is very simple to use and fast enough for smaller sets of data. Firstly you have to add reference to ClosedXML. Install ClosedXML using NuGet Package Manager. Using ClosedXML you can set … Continue reading Export Collection of data to Excel in c# using Closed XML
C-sharp
C# Items
Mock HttpContext using moq Framework
Moq is a framework that allows us to simulate dependencies at test time and monitor how our system under test interacts with them under various circumstances. Mock objects allow you to mimic the behavior of classes and interfaces, letting the code in the test interact with them as if they were real. In a project … Continue reading Mock HttpContext using moq Framework
Parallel.ForEach() Vs Foreach() Loop in C#
Foreach Loop Foreach loop runs upon a single thread and processing takes place sequentially one by one. Foreach loop is a basic feature of C#. Its execution is slower than Parallel.Foreach in most of the cases. Syntax foreach( var item in list){ DoFunction(item); } The problem with this foreach is that item 1000 has to wait until … Continue reading Parallel.ForEach() Vs Foreach() Loop in C#
Convert .xls file to .xlsx in c#
Recently, I faced one issue while handling excel file in c#. I was developing an application which read data from an excel file. but when I try to open it, an exception was thrown if the source file is saved with the .xls format. The exception messages is that "File contains corrupted data error when opening … Continue reading Convert .xls file to .xlsx in c#
Coding standards and Naming conventions
This post will helps you to understand basic coding conventions. A consistent naming pattern is one of the most important elements of predictability and discover-ability in a managed class library. Purposes of coding conventions They create a consistent look to the code, so that readers can focus on content, not layout. They enable readers to … Continue reading Coding standards and Naming conventions
Read Excel file using Open XML in ASP.Net C#
Open XML SDK provides tools for working with Office Word, Excel, and PowerPoint documents. This library supports many platforms. There are builds for .NET 3.5, .NET 4.0, .NET 4.6, and .NET Standard 1.3. This topic shows how to use the classes in the Open XML for Office to retrieve the values of cells in a spreadsheet … Continue reading Read Excel file using Open XML in ASP.Net C#
Add CSS file while generating PDF using ITextSharp
This post will helps you to add CSS file while generating PDF. Using ITextSharp we can easily convert HTML to PDF. Below example will convert HTML to PDF with CSS files. Step1: Create a new MVC Project Step 2: Install the ITextSharp Packages (Version 5) Install ITextSharp packages from Nuget package manager. Step 3: … Continue reading Add CSS file while generating PDF using ITextSharp