IronXL 对 AWS Lambda 功能以 .NET Core 支持
This article was translated from English: Does it need improvement?
TranslatedView the article in English
IronXL完全支持用于.NET Standard库、Core应用程序、.NET 5和.NET 6项目的AWS Lambda函数。
要添加AWS ToolKit for visual studio,请跟随此链接。在面向 Visual Studio 的 AWS 工具包中使用 AWS Lambda 模板
将 AWS ToolKit 安装到 Visual Studio 中可以让您创建 AWS Lambda 函数项目。 您可以学习如何使用Visual Studio创建AWS Lambda函数项目。链接
工作中的AWS Lambda函数代码示例
在创建新的AWS Lambda函数项目后,您可以尝试此代码片段
namespace AWSLambdaIronXL
{
public class Function
{
/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public string FunctionHandler(string input, ILambdaContext context)
{
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);
var newSheet = workBook.CreateWorkSheet("new_sheet");
string ColumnsNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
foreach (char col in ColumnsNames)
{
for (int row = 1; row <= 50; row++)
{
var cellName = $"{col}{row}";
newSheet [cellName].Value = $"Cell : {cellName}";
}
}
return Convert.ToBase64String( workBook.ToByteArray());
}
}
}
namespace AWSLambdaIronXL
{
public class Function
{
/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public string FunctionHandler(string input, ILambdaContext context)
{
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLS);
var newSheet = workBook.CreateWorkSheet("new_sheet");
string ColumnsNames = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
foreach (char col in ColumnsNames)
{
for (int row = 1; row <= 50; row++)
{
var cellName = $"{col}{row}";
newSheet [cellName].Value = $"Cell : {cellName}";
}
}
return Convert.ToBase64String( workBook.ToByteArray());
}
}
}
Namespace AWSLambdaIronXL
Public Class [Function]
''' <summary>
''' A simple function that takes a string and does a ToUpper
''' </summary>
''' <param name="input"></param>
''' <param name="context"></param>
''' <returns></returns>
Public Function FunctionHandler(ByVal input As String, ByVal context As ILambdaContext) As String
Dim workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLS)
Dim newSheet = workBook.CreateWorkSheet("new_sheet")
Dim ColumnsNames As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
For Each col As Char In ColumnsNames
For row As Integer = 1 To 50
Dim cellName = $"{col}{row}"
newSheet (cellName).Value = $"Cell : {cellName}"
Next row
Next col
Return Convert.ToBase64String(workBook.ToByteArray())
End Function
End Class
End Namespace
VB C#
IronXL NuGet 软件包可用于我们的IronXL NuGet 安装指南.