IronXL Support for AWS Lambda Function with .NET Core
IronXL fully supports AWS Lambda Function for .NET Standard 2.0 Libraries, Core applications, .NET 8, and .NET 10 projects.
To add AWS Toolkit for Visual Studio, follow this link: Using the AWS Lambda Templates in the AWS Toolkit for Visual Studio.
Installing AWS Toolkit into Visual Studio enables you to create an AWS Lambda Function Project. You can learn how to create an AWS Lambda Function Project using Visual Studio through this link.
Working AWS Lambda Function Code Example
After creating a new AWS Lambda Function project, you can try this code snippet:
using System;
using Amazon.Lambda.Core;
using IronXL;
// Ensure this attribute targets your Lambda function
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace AWSLambdaIronXL
{
public class Function
{
/// <summary>
/// A simple function that takes a string input and processes it using IronXL.
/// This specific example creates a new Excel workbook and fills cells with labeled values.
/// </summary>
/// <param name="input">The string input for the function</param>
/// <param name="context">The Lambda context</param>
/// <returns>A Base64 string representation of the Excel file</returns>
public string FunctionHandler(string input, ILambdaContext context)
{
// Create a new workbook with ExcelFileFormat.XLS
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);
// Create a new worksheet named "new_sheet"
var newSheet = workBook.CreateWorkSheet("new_sheet");
string columnNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
foreach (char col in columnNames)
{
for (int row = 1; row <= 50; row++)
{
// Construct cell name and fill it with data
var cellName = $"{col}{row}";
newSheet[cellName].Value = $"Cell: {cellName}";
}
}
// Convert the entire workbook to a byte array and then to a Base64 string
return Convert.ToBase64String(workBook.ToByteArray());
}
}
}Imports System
Imports Amazon.Lambda.Core
Imports IronXL
' Ensure this attribute targets your Lambda function
<Assembly: LambdaSerializer(GetType(Amazon.Lambda.Serialization.Json.JsonSerializer))>
Namespace AWSLambdaIronXL
Public Class Function
''' <summary>
''' A simple function that takes a string input and processes it using IronXL.
''' This specific example creates a new Excel workbook and fills cells with labeled values.
''' </summary>
''' <param name="input">The string input for the function</param>
''' <param name="context">The Lambda context</param>
''' <returns>A Base64 string representation of the Excel file</returns>
Public Function FunctionHandler(input As String, context As ILambdaContext) As String
' Create a new workbook with ExcelFileFormat.XLS
Dim workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLS)
' Create a new worksheet named "new_sheet"
Dim newSheet = workBook.CreateWorkSheet("new_sheet")
Dim columnNames As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
For Each col As Char In columnNames
For row As Integer = 1 To 50
' Construct cell name and fill it with data
Dim cellName = $"{col}{row}"
newSheet(cellName).Value = $"Cell: {cellName}"
Next
Next
' Convert the entire workbook to a byte array and then to a Base64 string
Return Convert.ToBase64String(workBook.ToByteArray())
End Function
End Class
End NamespaceIronXL NuGet Packages available for deployments are documented in our IronXL NuGet installation guide.
Frequently Asked Questions
What versions of .NET does IronXL support for AWS Lambda functions?
IronXL supports AWS Lambda Function for .NET Standard 2.0 Libraries, Core applications, .NET 8, and .NET 10 projects.
How can I start an AWS Lambda project using IronXL?
To start an AWS Lambda project with IronXL, first install the AWS Toolkit into Visual Studio to enable project creation. Then, follow the AWS Lambda Templates in the AWS Toolkit for Visual Studio for guidance.
Is there a code example for using IronXL with AWS Lambda?
Yes, the provided code example demonstrates creating a new Excel workbook, filling cells with data, and returning a Base64 string using IronXL in an AWS Lambda function.
Can IronXL create Excel files within an AWS Lambda function?
Yes, IronXL can create Excel files within an AWS Lambda function by using its features to construct Excel workbooks and worksheets programmatically.
How do I convert an Excel workbook to a Base64 string with IronXL?
You can convert an Excel workbook to a Base64 string in IronXL by first converting the workbook to a byte array and then using Convert.ToBase64String method.
What is the purpose of the 'FunctionHandler' method in IronXL's AWS Lambda example?
The 'FunctionHandler' method in the IronXL AWS Lambda example processes a string input, generates an Excel workbook by filling cells with labeled values, and returns the workbook as a Base64 string.
What AWS resource can I use for detailed instructions on deploying an IronXL project in AWS Lambda?
Detailed instructions for deploying an IronXL project as an AWS Lambda function can be found in the AWS documentation under AWS Lambda Templates in the AWS Toolkit for Visual Studio.
Where can I find the IronXL NuGet installation guide?
The IronXL NuGet installation guide is available under the documentation section on Iron Software's website, specifically in the IronXL NuGet installation guide.
How do I create a new worksheet in an Excel workbook using IronXL?
In IronXL, you can create a new worksheet in an Excel workbook using the CreateWorkSheet method. For example, `var newSheet = workBook.CreateWorkSheet("new_sheet");` creates a sheet named 'new_sheet'.
What is the benefit of using IronXL with AWS Lambda?
Using IronXL with AWS Lambda allows seamless integration of .NET applications with AWS cloud services, enabling programmatic creation and manipulation of Excel files in serverless environments.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.