COMPARE TO OTHER COMPONENTS

A Comparison between IronXL and GrapeCity Excel Viewer

Published June 9, 2022
Share:

Using Excel data in a programming situation with a .NET environment can cause a slew of problems, especially when it comes to interoperability.

Excel is the most widely used spreadsheet program in the world. Users include both developers and the general public, but developers are more likely to be interested in this content. Initially, developers didn't have many alternatives for integrating Excel into their various apps. However, the Office Suite included VBA (Visual Basic for Applications), which allowed you to edit any Office product to suit your needs.

Developers customized their interactions with XLSX spreadsheets and their data, as well as its visual features, using VBA in Excel.

What is GrapeCity Documents for Excel?

GrapeCity Documents for Excel .NET Edition is a new high-performance, small-footprint spreadsheet component that can be utilized in server or desktop applications. It provides a rich API for creating, manipulating, converting, and sharing Microsoft Excel-compatible spreadsheets. You can also use it from almost any application or platform such as Angular, React or Vue to create custom styles.

It has a seamlessly embedded BI platform wyn, with interactive dashboards, scheduling, and distribution tools within any internal or commercial app.

GrapeCity's embedded BI platform offers limitless high-speed visual data exploration, allowing the everyday user to become data-driven to easily report solutions with extensive data using the BI ad hoc reporting and interactive dashboards.

GcExcel .NET is compatible with a variety of platforms, including the .NET Framework, .NET Core, and Mono, making it the ideal choice for all of your spreadsheet needs.

The best thing about GcExcel .NET is that its interface-based API is modeled around Excel's document object paradigm. As a result, users can import, calculate, query, produce, and export any spreadsheet scenario at any time. Furthermore, comprehensive reports, sort, and filter tables, sort and filter pivot tables add charts, sparklines, conditional formats, and dashboard reports, among other things, can be referenced in the imported or generated spreadsheets.

What does GrapeCity Documents for Excel offer you?

  • Allows for the creation, manipulation, and serialization of spreadsheets on the server.
  • Low memory footprint.
  • Performs complex calculations using the powerful calculation engine.
  • High-speed intuitive document; embedded business intelligence.
  • Provides full reporting solutions.
  • Gives you full control of your documents at high speed.
  • Generates output in a variety of formats, including.xlsx, and ssjson.
  • Support for .NET Framework, .NET Core, and Mono across several platforms.
  • Compatible with Winforms, WPF, ASP .NET, and other environments.

GrapeCity Excel — standout features

The latest release version 14.1 has many new and exciting features.

  • Lightweight Spreadsheet API Architecture for Improved Efficiency

GcExcel .NET enables users to save a considerable amount of time, storage memory, and effort by improving the overall efficiency with its lightweight API architecture that can be used to generate, load, edit, save and convert spreadsheets.

  • No Dependency on MS Excel

In order to work with GcExcel .NET, users don't need to install MS Office Suite or access MS Excel on their systems.

  • Create an Interactive Experience with SpreadJS DSheets

GcExcel .NET can be used with spreadsheets for a completely interactive and user-friendly spreadsheet experience.

  • Deploy Apps with Excel Spreadsheets to the Cloud

With GcExcel .NET, you can apply cloud-based deployments and deploy your applications on Azure and AWS Lambda.

  • Shapes and Pictures

With the spreadsheet API, you can insert and customize shapes and pictures on cells of a worksheet, apply formatting, gradient fill, configure text, insert hyperlinks, set adjustment points of the shapes, group/ungroup them in a worksheet and determine the position and size of an image.

What is IronXL?

IronXL is a C# library that makes it easier to read and edit Microsoft Excel documents. IronXL. Excel is a .NET software library that can read a variety of spreadsheet formats. It does not necessitate the installation of Microsoft Excel, nor does it rely on Interop.

IronXL is a user-friendly C# API that lets you read, edit, and generate Excel files in .NET at breakneck speed. .NET Core,.NET Framework, Xamarin, Mobile, Linux, macOS, and Azure are all supported by IronXL.

IronXL is a C# Excel spreadsheet library for .NET Core and .NET Framework.

IronXL Feature Set

  • Load, Read, and Edit Data — from XLS/XLSX/CSV/TSV
  • Saving and Exporting — to XLS/XLSX/CSV/TSV/JSON
  • System.Data Objects — Work with Excel Spreadsheets as System.Data.DataSet and System.Data.DataTable objects.
  • Formulas — works with Excel formulas. Formulas are recalculated every time a sheet is edited.
  • Ranges — Easy-to-use WorkSheet ["A1:B10"] syntax. Combine and create ranges intuitively.
  • Sorting — Sort Ranges, Columns, and Rows.
  • Styling — Cell visual styles, font, size, background pattern, border, alignment, and number formats.

Installing GrapeCity Documents for Excel

In order to use GcExcel .NET in a .NET Core, ASP .NET Core, or .NET Framework application (any target that supports .NET Standard 2.0), install the NuGet packages in your application using the following steps:

To find and install the GrapeCity.Documents.Excel NuGet Package

  1. Select Manage NuGet Packages from the context menu of either dependencies or a project in Solution Explorer.
  2. Select nuget.org from the Package source dropdown in the Browse tab.
  3. In the Browse tab, search for the package "GrapeCity.Documents.Excel" by typing "grapecity.documents" or "GrapeCity.Documents" in the search text box at the top.
NuGet Package Manager dialog
  1. Click Install to install the GrapeCity.Documents.Excel package and its dependencies in the project. When the installation is complete, make sure you check the NuGet folder in your solution explorer and confirm whether or not the GrapeCity.Documents.Excel package is added to your project dependencies.
NuGet Folder

IronXL C# Library Installation

You can download and install the IronXL library using the following methods:

  • Using Visual Studio with NuGet packages.
  • Download the NuGet Package directly.
  • Manually install with the DLL.

Let’s take a closer look at each one.

Using Visual Studio with NuGet Packages

Visual Studio provides the NuGet Package Manager to install NuGet packages in your projects. You can access it through the Project Menu, or by right-clicking your project in the Solution Explorer.

Select Manage NuGet Package
  • Next, from the Browse tab -> search for IronXL.Excel -> Install
Search for IronXL
  • And we are done.

Using the NuGet Package Manager Console

Another way to download and install Microsoft.Office.Interop.Excel C# library is to make use of the following steps to install the NuGet package through the Developer Command Prompt.

  • Open the Developer Command Prompt — usually found in the Visual Studio folder.
  • Type the following command:
PM> Install-Package Microsoft.Office.Interop.Excel
  • Press Enter.
  • This will download and install the package.
  • Reload your Visual Studio project and begin using it.

Add necessary using directives

  1. In Solution Explorer, right-click the Program.cs file and then click View Code.
  2. Add the following using directives to the top of the code file:
using Excel = Microsoft.Office.Interop.Excel;

Creating Excel Workbooks and Sheets

A workbook is an Excel file that contains many rows and columns of worksheets. The ability to create a new Excel workbook and sheets is available in both libraries. Let's take a step-by-step look at the code.

Creating Excel files using IronXL

It could not be any easier to create a new Excel Workbook using IronXL. Just one line of code! Yes, really. Add the following code to your static void main function in the Program.cs file:

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
Dim workbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
VB   C#

Both XLS (older Excel file version) and XLSX (current and newer file version) file formats can be created with IronXL.

And, it’s even easier to create a default Worksheet:

var worksheet = workbook.CreateWorkSheet("IronXL Features");
var worksheet = workbook.CreateWorkSheet("IronXL Features");
Dim worksheet = workbook.CreateWorkSheet("IronXL Features")
VB   C#

You may now utilize the worksheet variable to set cell values and do practically anything an Excel file can do.

Creating Excel files using a Server-Side Excel API GrapeCity excel

GrapeCity Documents for Excel (or GcExcel) is a server-side Excel API that allows you to create, load, save, convert, compute, format, parse, and export spreadsheets in any .NET Standard application. GcExcel can deploy to Azure without any Excel dependencies thanks to the full .NET5 support for Windows, Linux, and Mac.

GcExcel allows you to create and generate server-side Excel spreadsheets without having to use MS Excel.

  • Create a workbook with GcExcel in a function.
  • Return to the client-side after converting the workbook to JSON.

In this example, we're merely going to make a BidTracker.xlsx spreadsheet. This sample displays extra server-side functionality that may be programmed with GcExcel.

[HttpGet("{caseName}")]
public IActionResult GetSSJsonFromUseCase(string caseName)
{
Workbook workbook = CreateWorkbookByCaseName(caseName);
var ssjson = workbook.ToJson();
return Ok(ssjson);
}

        private Workbook CreateWorkbookByCaseName(string caseName)
        {
            switch (caseName)
            {
                case "BidTracker":
                    return GetBidTracker();
                default:
                    break;
            }

            return new Workbook();
        }
}
[HttpGet("{caseName}")]
public IActionResult GetSSJsonFromUseCase(string caseName)
{
Workbook workbook = CreateWorkbookByCaseName(caseName);
var ssjson = workbook.ToJson();
return Ok(ssjson);
}

        private Workbook CreateWorkbookByCaseName(string caseName)
        {
            switch (caseName)
            {
                case "BidTracker":
                    return GetBidTracker();
                default:
                    break;
            }

            return new Workbook();
        }
}
<HttpGet("{caseName}")>
Public Function GetSSJsonFromUseCase(ByVal caseName As String) As IActionResult
Dim workbook As Workbook = CreateWorkbookByCaseName(caseName)
Dim ssjson = workbook.ToJson()
Return Ok(ssjson)
End Function

		Private Function CreateWorkbookByCaseName(ByVal caseName As String) As Workbook
			Select Case caseName
				Case "BidTracker"
					Return GetBidTracker()
				Case Else
			End Select

			Return New Workbook()
		End Function
}
VB   C#

Edit Excel Files

Developers have to be careful when they start out modifying and editing Excel files in C# because it might be easy for one blunder to change the whole document. Being able to rely on simple and efficient lines of code helps lessen the danger of error, and makes it easier for us to update or delete Excel files programmatically. Today we'll walk over the procedures necessary to edit Excel files in C# accurately and rapidly, utilizing tested functions.

Edit Excel files with GrapeCity Excel

Let's get started using GcExcel and Java to address these issues.

You're handed a spreadsheet that looks like this:

First, we'll want to format the sheet:

  • Change the font properties of the title of the sheet and the Total Income cell.
  • Change table, table column, and cell styles.

Let's take a look at how to accomplish this using GcExcel, and Java.

Step 1: Load an existing Excel spreadsheet

Write the following code to load an existing spreadsheet into your GcExcel Workbook:

Workbook workbook = new Workbook();
workbook.open("Event budget.xlsx");
Workbook workbook = new Workbook();
workbook.open("Event budget.xlsx");
Dim workbook As New Workbook()
workbook.open("Event budget.xlsx")
VB   C#

Step 2: Get the worksheet that you want to modify

IWorksheet worksheet = workbook.getActiveSheet();
IWorksheet worksheet = workbook.getActiveSheet();
Dim worksheet As IWorksheet = workbook.getActiveSheet()
VB   C#

Step 3: Modify the font properties of the titles

Change the font properties of B2 (font size) and E4 (set to bold) cells:

//change range B2s font size.
worksheet.getRange("B2").getFont().setSize(22);

//change range E4s font style to bold.
worksheet.getRange("E4").getFont().setBold(true);
//change range B2s font size.
worksheet.getRange("B2").getFont().setSize(22);

//change range E4s font style to bold.
worksheet.getRange("E4").getFont().setBold(true);
'change range B2s font size.
worksheet.getRange("B2").getFont().setSize(22)

'change range E4s font style to bold.
worksheet.getRange("E4").getFont().setBold(True)
VB   C#

Step 4: Modify table style

Set styles of the four tables to an in-built style.

worksheet.getTables().get("tblAdmissions").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblAds").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblVendors").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblItems").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblAdmissions").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblAds").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblVendors").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblItems").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"));
worksheet.getTables().get("tblAdmissions").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"))
worksheet.getTables().get("tblAds").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"))
worksheet.getTables().get("tblVendors").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"))
worksheet.getTables().get("tblItems").setTableStyle(workbook.getTableStyles().get("TableStyleLight10"))
VB   C#

Step 5: Modify cell range style

Modify the cell style of Total Income cells. The getInterior() method of a range can help you set the ThemeColor and TintAndShade properties. You can also change the font of the entire range using the getFont() method. In addition, this code can set the borders of a range of cells.

Since the spreadsheet shows the budget data, set the number format of a range of cells to currency.

//modify range F4:G5's cell style.
worksheet.getRange("F4:G5").getInterior().setThemeColor(ThemeColor.Light1);
worksheet.getRange("F4:G5").getInterior().setTintAndShade(-0.15);
worksheet.getRange("F4:G5").getFont().setThemeFont(ThemeFont.Major);
worksheet.getRange("F4:G5").getFont().setSize(12);  worksheet.getRange("F4:G5").getBorders().get(BordersIndex.InsideHorizontal).setLineStyle(BorderLineStyle.None);
worksheet.getRange("F5:G5").setNumberFormat("$#,##0.00");
//modify range F4:G5's cell style.
worksheet.getRange("F4:G5").getInterior().setThemeColor(ThemeColor.Light1);
worksheet.getRange("F4:G5").getInterior().setTintAndShade(-0.15);
worksheet.getRange("F4:G5").getFont().setThemeFont(ThemeFont.Major);
worksheet.getRange("F4:G5").getFont().setSize(12);  worksheet.getRange("F4:G5").getBorders().get(BordersIndex.InsideHorizontal).setLineStyle(BorderLineStyle.None);
worksheet.getRange("F5:G5").setNumberFormat("$#,##0.00");
'modify range F4:G5's cell style.
worksheet.getRange("F4:G5").getInterior().setThemeColor(ThemeColor.Light1)
worksheet.getRange("F4:G5").getInterior().setTintAndShade(-0.15)
worksheet.getRange("F4:G5").getFont().setThemeFont(ThemeFont.Major)
worksheet.getRange("F4:G5").getFont().setSize(12)
worksheet.getRange("F4:G5").getBorders().get(BordersIndex.InsideHorizontal).setLineStyle(BorderLineStyle.None)
worksheet.getRange("F5:G5").setNumberFormat("$#,##0.00")
VB   C#

Step 6: Modify table column styles

Since table column ranges are different, set the ThemeColor, TintAndShade properties, and NumberFormat on a different column range of the table.

worksheet.getRange("F8:G11, F15:G18, F22:G25, F29:G33").getInterior().setThemeColor(ThemeColor.Light1);
worksheet.getRange("F8:G11, F15:G18, F22:G25, F29:G33").getInterior().setTintAndShade(-0.15);
worksheet.getRange("E8:G11, E15:G18, E22:G25, E29:G33").setNumberFormat("$#,##0.00");
worksheet.getRange("F8:G11, F15:G18, F22:G25, F29:G33").getInterior().setThemeColor(ThemeColor.Light1);
worksheet.getRange("F8:G11, F15:G18, F22:G25, F29:G33").getInterior().setTintAndShade(-0.15);
worksheet.getRange("E8:G11, E15:G18, E22:G25, E29:G33").setNumberFormat("$#,##0.00");
worksheet.getRange("F8:G11, F15:G18, F22:G25, F29:G33").getInterior().setThemeColor(ThemeColor.Light1)
worksheet.getRange("F8:G11, F15:G18, F22:G25, F29:G33").getInterior().setTintAndShade(-0.15)
worksheet.getRange("E8:G11, E15:G18, E22:G25, E29:G33").setNumberFormat("$#,##0.00")
VB   C#

Step 7: Save the Excel file

//save to an excel file
workbook.save("EventBudget.xlsx");
//save to an excel file
workbook.save("EventBudget.xlsx");
'save to an excel file
workbook.save("EventBudget.xlsx")
VB   C#

Congratulations! You have entirely changed the formatting of the document. Run the application, and your Excel spreadsheet looks like this:

Create, Modify, and Save Excel Spreadsheets in Java Apps

Edit Excel files with IronXL

Once you have installed IronXL, let's address the process of editing Excel files with it.

Edit the Values of Specific Cells

First, we'll look at how to change the values of certain cells in an Excel spreadsheet.

We do this by importing the Excel spreadsheet that has to be changed and accessing its WorkSheet. Then, we can make the changes as indicated below.

using IronXL;
static void Main(string [] args)
{
WorkBook wb = WorkBook.Load("sample.xlsx");//import Excel SpreadSheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");//access specific workshet
ws.Rows [3].Columns [1].Value = "New Value";//access specific cell and modify its value
wb.SaveAs("sample.xlsx");//save changes
}
using IronXL;
static void Main(string [] args)
{
WorkBook wb = WorkBook.Load("sample.xlsx");//import Excel SpreadSheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");//access specific workshet
ws.Rows [3].Columns [1].Value = "New Value";//access specific cell and modify its value
wb.SaveAs("sample.xlsx");//save changes
}
Imports IronXL
Shared Sub Main(ByVal args() As String)
Dim wb As WorkBook = WorkBook.Load("sample.xlsx") 'import Excel SpreadSheet
Dim ws As WorkSheet = wb.GetWorkSheet("Sheet1") 'access specific workshet
ws.Rows (3).Columns (1).Value = "New Value" 'access specific cell and modify its value
wb.SaveAs("sample.xlsx") 'save changes
End Sub
VB   C#

Here are before and after screenshots of the Excel spreadsheet sample.xlsx:

Before
After

We can see how simple it is to modify the Excel spreadsheet value.

If needed, there is also an alternative way to edit the specific cell value by cell address:

ws ["B4"].Value = "New Value"; //alternative way to access specific cell and apply changes
ws ["B4"].Value = "New Value"; //alternative way to access specific cell and apply changes
ws ("B4").Value = "New Value" 'alternative way to access specific cell and apply changes
VB   C#

Edit Full Row Values

It is pretty simple to edit full row values of an Excel spreadsheet with a static value.

using IronXL;static void Main(string [] args){    
    WorkBook wb = WorkBook.Load("sample.xlsx");    
    WorkSheet ws = wb.GetWorkSheet("Sheet1");    
    ws.Rows [3].Value = "New Value";            
    wb.SaveAs("sample.xlsx");
}
using IronXL;static void Main(string [] args){    
    WorkBook wb = WorkBook.Load("sample.xlsx");    
    WorkSheet ws = wb.GetWorkSheet("Sheet1");    
    ws.Rows [3].Value = "New Value";            
    wb.SaveAs("sample.xlsx");
}
Imports IronXL
Shared Sub Main(ByVal args() As String)
	Dim wb As WorkBook = WorkBook.Load("sample.xlsx")
	Dim ws As WorkSheet = wb.GetWorkSheet("Sheet1")
	ws.Rows (3).Value = "New Value"
	wb.SaveAs("sample.xlsx")
End Sub
VB   C#

See the screenshots of the sample.xlsx below:

Before
After

For this, we also can edit the value of a specific range of the row, by using the range function:

ws ["A3:E3"].Value = "New Value";
ws ["A3:E3"].Value = "New Value";
ws ("A3:E3").Value = "New Value"
VB   C#

Edit Full Column Values

In the same way as above, we can easily edit full columns of the Excel spreadsheet values with a single value.

using IronXL;static void Main(string [] args){    WorkBook wb = WorkBook.Load("sample.xlsx");    WorkSheet ws = wb.GetWorkSheet("Sheet1");    ws.Columns [1].Value = "New Value";    wb.SaveAs("sample.xlsx");}
using IronXL;static void Main(string [] args){    WorkBook wb = WorkBook.Load("sample.xlsx");    WorkSheet ws = wb.GetWorkSheet("Sheet1");    ws.Columns [1].Value = "New Value";    wb.SaveAs("sample.xlsx");}
Imports IronXL
Shared Sub Main(ByVal args() As String)
	Dim wb As WorkBook = WorkBook.Load("sample.xlsx")
	Dim ws As WorkSheet = wb.GetWorkSheet("Sheet1")
	ws.Columns (1).Value = "New Value"
	wb.SaveAs("sample.xlsx")
End Sub
VB   C#

This will produce our sample.xlsx spreadsheet as such:

After

Edit Full Rows with Dynamic Values

Using IronXL, it is also possible to edit specific rows with dynamic values. This means we can edit a full row by assigning dynamic values for each cell. Let's take a look at the example:

using IronXL;static void Main(string [] args){    
    WorkBook wb = WorkBook.Load("sample.xlsx");    
    WorkSheet ws = wb.GetWorkSheet("Sheet1");    
    for (int i = 0; i < ws.Columns.Count(); i++)    {        
        ws.Rows [3].Columns [i].Value = "New Value "+i.ToString();    
    }            
    wb.SaveAs("sample.xlsx");
}
using IronXL;static void Main(string [] args){    
    WorkBook wb = WorkBook.Load("sample.xlsx");    
    WorkSheet ws = wb.GetWorkSheet("Sheet1");    
    for (int i = 0; i < ws.Columns.Count(); i++)    {        
        ws.Rows [3].Columns [i].Value = "New Value "+i.ToString();    
    }            
    wb.SaveAs("sample.xlsx");
}
Imports IronXL
Shared Sub Main(ByVal args() As String)
	Dim wb As WorkBook = WorkBook.Load("sample.xlsx")
	Dim ws As WorkSheet = wb.GetWorkSheet("Sheet1")
	For i As Integer = 0 To ws.Columns.Count() - 1
		ws.Rows (3).Columns (i).Value = "New Value " & i.ToString()
	Next i
	wb.SaveAs("sample.xlsx")
End Sub
VB   C#

In the table below, we can see the screenshots of the Excel spreadsheet sample.xlsx from this output:

Before
After

Edit Full Columns with Dynamic Values

It is also easy to edit specific columns with dynamic values.

using IronXL;static void Main(string [] args){    
    WorkBook wb = WorkBook.Load("sample.xlsx");    
    WorkSheet ws = wb.GetWorkSheet("Sheet1");    
    for (int i = 0; i < ws.Rows.Count(); i++)    {        
        if (i == 0) //it is for if our first column is used as a header            
            continue;        

        ws.Rows [i].Columns [1].Value = "New Value " + i.ToString();
    }    
    wb.SaveAs("sample.xlsx");
}
using IronXL;static void Main(string [] args){    
    WorkBook wb = WorkBook.Load("sample.xlsx");    
    WorkSheet ws = wb.GetWorkSheet("Sheet1");    
    for (int i = 0; i < ws.Rows.Count(); i++)    {        
        if (i == 0) //it is for if our first column is used as a header            
            continue;        

        ws.Rows [i].Columns [1].Value = "New Value " + i.ToString();
    }    
    wb.SaveAs("sample.xlsx");
}
Imports IronXL
Shared Sub Main(ByVal args() As String)
	Dim wb As WorkBook = WorkBook.Load("sample.xlsx")
	Dim ws As WorkSheet = wb.GetWorkSheet("Sheet1")
	For i As Integer = 0 To ws.Rows.Count() - 1
		If i = 0 Then 'it is for if our first column is used as a header
			Continue For
		End If

		ws.Rows (i).Columns (1).Value = "New Value " & i.ToString()
	Next i
	wb.SaveAs("sample.xlsx")
End Sub
VB   C#

With the table results of sample.xlsx below:

Before
After

Edit Full Columns with Dynamic Values

It is also easy to edit specific columns with dynamic values.

using IronXL;static void Main(string [] args){ WorkBook wb = WorkBook.Load("sample.xlsx"); WorkSheet ws = wb.GetWorkSheet("Sheet1"); for (int i = 0; i < ws.Rows.Count(); i++) { if (i == 0)//it is for if our first column is used as a header continue; ws.Rows [i].Columns [1].Value = "New Value " + i.ToString(); } wb.SaveAs("sample.xlsx");}

With the table results of sample.xlsx below:

Convert spreadsheets to PDF, XML, and JSON

Are you using an Excel API to generate spreadsheets in Java applications? When you are working with data, there will be times when you do not want to store your data in an Excel spreadsheet. Instead, you need a PDF.

There are several reasons why you wouldn't want to store data in an Excel spreadsheet:

  • You need long-term preservation.
  • You do not have Microsoft Office installed on your system, but still want to print or distribute your Excel spreadsheets.
  • You need to share your spreadsheet and keep your formatting. You need your Excel spreadsheets to look exactly the same when opened on different systems.

Using GrapeCity to convert spreadsheets to PDF

GrapeCity Documents for Excel, Java Edition (GcExcel Java) is a high-speed, small-footprint spreadsheet API that requires zero dependencies in Excel. With full support on Windows, Linux, and MAC, you can generate, load, modify, and save spreadsheets, then convert them to a PDF.

Here are the three steps for converting spreadsheets to PDFs in Java applications:

  1. Load an existing Excel spreadsheet in a GcExcel workbook
  2. Add PDFBox as a library
  3. Convert the spreadsheet to PDF

Step 1: Load an existing Excel spreadsheet in a GcExcel workbook

Create a GcExcel workbook object and load an existing spreadsheet.

Use an Excel API to Convert Spreadsheets to PDFs in Java Apps
Workbook workbook=new Workbook();
workbook.open("FinancialKPI.xlsx");
Workbook workbook=new Workbook();
workbook.open("FinancialKPI.xlsx");
Dim workbook As New Workbook()
workbook.open("FinancialKPI.xlsx")
VB   C#

Step 2: Add PDFBox as a library

GcExcel Java references PDFBox to convert spreadsheets to PDF. PDFBox also depends on FontBox and Commons Logging packages.

Following these steps will help you add these JAR files as a library to your project:

  1. Download the package — PDFBox, FontBox, Commons Loggings JAR files.
  2. Under the 'src' folder in the project, add a folder 'libs'.
  3. Copy the three JAR files to the 'libs' folder.
  4. Right-click the 'libs' folder and choose the 'Add as library' option.
  5. Press OK.

Note: The above steps would be required only if the project is an original Java console project. If the project is a Maven or Gradle project, just adding the GcExcel Java dependency would be sufficient. Maven or Gradle will download and install all dependent JARs automatically.

In some versions of Maven, you may get a dependency error on adding the above JAR files. To resolve that, please add the following node before the dependencies in pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

Step 3: Convert the spreadsheet to PDF

Save the spreadsheet to PDF using the following code:

workbook.save("FinancialKPI.pdf", SaveFileFormat.Pdf);
workbook.save("FinancialKPI.pdf", SaveFileFormat.Pdf);
workbook.save("FinancialKPI.pdf", SaveFileFormat.Pdf)
VB   C#

You PDF will look like this:

Use an Excel API to Convert Spreadsheets to PDFs in Java Apps
Use an Excel API to Convert Spreadsheets to PDFs in Java Apps

Using IronXL to convert spreadsheets to XML and JSON

The following code demonstrates how to export an Excel file to an XML or a JSON file with IronXL. Add the following code:

Include the namespace:

using IronXL;
using IronXL;
Imports IronXL
VB   C#

Add the next few lines:

    private void button4_Click(object sender, EventArgs e)    {        
        WorkBook workbook = WorkBook.Load("IronXL_Output.xlsx");        
        workbook.SaveAsJson("IronXL_Output.json");        
        workbook.SaveAsXml("IronXL_Output.xml");    
    }
    private void button4_Click(object sender, EventArgs e)    {        
        WorkBook workbook = WorkBook.Load("IronXL_Output.xlsx");        
        workbook.SaveAsJson("IronXL_Output.json");        
        workbook.SaveAsXml("IronXL_Output.xml");    
    }
Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)
		Dim workbook As WorkBook = WorkBook.Load("IronXL_Output.xlsx")
		workbook.SaveAsJson("IronXL_Output.json")
		workbook.SaveAsXml("IronXL_Output.xml")
End Sub
VB   C#

Here, an existing Excel Workbook object is loaded and then exported to JSON and XML formats.

Licensing and Pricing

IronXL Licensing and Pricing

IronXL is an openly commercial C# Excel library. It is free for development and can always be licensed for commercial deployment. Licenses are offered for single-project use, single developers, agencies, and multinational organizations, as well as SaaS and OEM redistribution. All licenses contain a 30-day money-back guarantee, one year of software support and upgrades, validity for dev/staging/production, and also a permanent license (one-time purchase). The Lite bundle starts from $749.

GrapeCity Licensing and Pricing

On the other hand, GrapeCity Excel is also a commercial Excel library; it does not offer any free services. GrapeCity Documents pricing starts at the flat rate of $999 per year. They also offer a free trial. Their licenses are broken down into four packages:

Developer License (1 Developer, 1 Location)

One (1) developer can use GrapeCity Documents in one (1) location with a Developer License (defined as a physical address or office building). Multiple sites are considered to constitute a cloud deployment; see Unlimited Licenses for more information.

Developer Unlimited License (1 Developer, Unlimited Locations or Cloud)

One (1) developer can use GrapeCity Documents in an unlimited number of locations (specified as a physical address or office building) or in the cloud with a Developer Unlimited License.

Team Unlimited License (2–5 Developers, Unlimited Locations or Cloud)

GrapeCity Documents can be used by up to five (5) developers in infinite locations (specified as a physical address or office building) or in the cloud with a Team Unlimited License.

OEM and SaaS License (6+ Developers)

This can be set up by contacting sales support.

Conclusion

In .NET apps and websites, IronXL for .NET allows developers to read, produce, and modify Excel (and other Spreadsheet files). XLS/XLSX/CSV/TSV can be read and edited, and exports can be saved to XLS/XLSX/CSV/TSV/JSON. It is compatible with the .NET Framework, .NET Core, and Azure. All of this is accomplished without the need for additional dependencies or the installation of Microsoft Office. If you've ever felt that Excel is getting in the way of your .NET office management skills, IronXL is here to help. This is why we built the C# Excel library, which allows you to read, generate, and modify Excel files in .NET apps and websites as a successful developer.

GcExcel (GrapeCity Documents for Excel) is a fast, small-footprint spreadsheet API that does not require Excel. You may generate, load, change and convert spreadsheets in .NET Framework, .NET Core, Mono, and Xamarin with full .NET Standard 2.0 support. This spreadsheet API can be used to build apps for the cloud, Windows, Mac, and Linux. You'll never have to sacrifice design or requirements because of its sophisticated computation engine and wide range of features.

The GrapeCity Excel license starts at $995 per developer, compared to $749 for IronXL, which comes with the upper hand of a royalty-free and unlimited multi-user plan which becomes cheaper when you are buying for a large number of developers rather than the GCexcel which has a maximum of 6 users on its ultra multiuser plans.

IronXL is preferred above other C# alternatives due to its efficiency in dealing with Excel documents. IronXL also stands out due to its operational methods which encourage shorter lines of code.

Iron Software is currently offering all its customers and users the option to grab the whole Iron Software suite in two clicks — for the price of just two packages from the Iron Software suite, you can instead get all five packages along with uninterrupted support.

< PREVIOUS
A Comparison of IronXL and ClosedXML
NEXT >
A Comparison between IronXL and Syncfusion Excel

Ready to get started? Version: 2024.10 just released

Free NuGet Download Total downloads: 1,068,832 View Licenses >