ReoGrid
C# .NET Library for Fast XLSX Spreadsheets
Open Source C# API allows to create, read, modify & export Microsoft Excel XLSX Spreadsheet, manage worksheets, row and column settings and so on.
A powerful open source .NET spreadsheet component that enables software apps to create and manage Excel file formats with ease. The library is very lightweight and can perform several operations with lesser time and cost. It can process spreadsheet-related tasks up to 300 times faster than similar products.
ReoGrid API supports multiple platforms and works on both Windows Form and WPF. It is very feature-rich and has included several important features related to Excel Spreadsheet creation and management, such as generating a new workbook from scratch, managing worksheets, row, and column settings, Cell styles support, borders handling, Cell value and data formats, use formulas, insert and manage Images, using floating objects, add charts or graphs and much more.
ReoGrid uses an optimized memory management model as well as enhanced cell memory usage. It split down larger spreadsheets into smaller parts and thus memory allocations and releases are performed on these small parts making the process faster. The library also uses an optimized border algorithm that quickly recognizes where to start drawing the borders.
Getting Started with ReoGrid
The following steps update the compiler and set the appropriate environment variables.
Install PIP Command
PM> Install-Package unvell.ReoGrid.dll
Excel Workbook Creation via .NET API
The open source library ReoGrid enables software developers to generate a new Excel workbook with just a couple of lines of C# code. The library also allows to add a new worksheet, assign names to worksheets, delete unwanted sheets, move worksheets,s and so on. The library also makes it easy to access worksheets and supports managing cell data, styles, borders, outlines, ranges, formula calculation, etc.
Add Worksheet to Workbook via .NET API
private void btnAddWorksheet_Click(object sender, EventArgs e)
{
// create worksheet
var newSheet = this.grid.CreateWorksheet();
// set worksheet background color
newSheet.SetRangeStyles(RangePosition.EntireRange, GetRandomBackColorStyle());
// add worksheet into workbook
this.grid.AddWorksheet(newSheet);
// set worksheet as current focus
grid.CurrentWorksheet = newSheet;
}
Export Excel XLSX File to CSV & HTML
The open source component ReoGrid enables software developers to export Excel XLSX spreadsheets to other supported file formats inside their own .NET applications. Developers can easily load CSV files, export worksheets as CSV format, export worksheets as HTML or PDF, output spreadsheets to printers,s and so on. It is also possible to select a specified range of a row or grid rather than an entire worksheet and export it to other supported formats. It also supports exporting worksheets to RGF files with just a couple of lines of code.
Convert Excel XLSX File to CSV via .NET API
// load from stream
void LoadCSV(Stream s);
// load from file
void LoadCSV(string path);
// load from stream and convert string by specified encoding
void LoadCSV(Stream s, Encoding encoding);
// load from path and convert string by specified encoding
public void LoadCSV(string path, Encoding encoding);
//Export as CSV
worksheet.ExportAsCSV(Stream steam);
worksheet.ExportAsCSV(string filepath);
Adding Charts to a Worksheet
The ReoGrid component has provided very strong support for handling charts inside an Excel worksheet. It allows to display chart on a worksheet and saving into or loading from an Excel file. There are different types of charts supported inside a worksheet such as Line Chart, Column Chart, Bar Chart Pro, Area Chart, Pie Chart, Doughnut Chart, and so on. You can also easily modify your charts with ease.
Add Column Chart to Excel XLSX File via C# API
var worksheet = this.grid.CurrentWorksheet;
worksheet["A2"] = new object[,] {
{ null, 2008, 2009, 2010, 2011, 2012 },
{ "City 1", 3, 2, 4, 2, 6 },
{ "City 2", 7, 5, 3, 6, 4 },
{ "City 3", 13, 10, 9, 10, 9 },
{ "Total", "=SUM(B3:B5)", "=SUM(C3:C5)", "=SUM(D3:D5)",
"=SUM(E3:E5)", "=SUM(F3:F5)" },
};
// Create three ranges, data source range, row title range and column title range
var dataRange = worksheet.Ranges["B3:F5"];
var rowTitleRange = worksheet.Ranges["A3:A6"];
var categoryNamesRange = worksheet.Ranges["B2:F2"];
worksheet.AddHighlightRange(rowTitleRange);
worksheet.AddHighlightRange(categoryNamesRange);
worksheet.AddHighlightRange(dataRange);