IRONSOFTWAREHOME

IronXL 支持使用 .NET Core 的 AWS Lambda 函数

Curtis Chau
Curtis Chau
Updated: 2026年4月22日

IronXL 完全支持 .NET Standard库、核心应用程序、.NET 5 和 .NET 6 项目的 AWS Lambda 函数。

要为Visual Studio添加AWS Toolkit,请访问此链接:使用AWS Toolkit中的AWS Lambda模板在Visual Studio中创建项目

在 Visual Studio 中安装 AWS Toolkit 后,即可创建 AWS Lambda 函数项目。 您可以通过此链接学习如何使用 Visual Studio 创建 AWS Lambda 函数项目。

AWS Lambda 函数代码示例

创建新的 AWS Lambda 函数项目后,您可以尝试以下代码片段:

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());
        }
    }
}

可用于部署的 IronXL NuGet 包已记录在我们的IronXL NuGet 安装指南中。

常见问题解答

如何在 Visual Studio 中创建 AWS Lambda 功能项目?

要在 Visual Studio 中创建 AWS Lambda 功能项目,请安装 Visual Studio 的 AWS 工具包。这使您能够为您的项目使用AWS Lambda模板。您可以在AWS文档中找到详细的说明。

IronXL在AWS Lambda中的应用示例是什么?

IronXL在AWS Lambda中的一个应用示例是创建一个新的 Excel 工作簿,用标签数据填充它,并返回 Excel 文件的 Base64 字符串。这展示了如何在AWS Lambda函数中使用IronXL来操作Excel文件。

如何使用 IronXL 在 AWS Lambda 中将 Excel 工作簿转换为 Base64?

在 AWS Lambda 函数中使用 IronXL,您可以创建一个工作簿并使用 workBook.ToByteArray() 将其转换为字节数组。然后使用 Convert.ToBase64String() 获取工作簿的 Base64 字符串表示。

IronXL 可以用于 AWS Lambda 函数与 .NET 5 吗?

是的,IronXL 完全支持用于 .NET 5、.NET Standard 库、Core 应用程序和 .NET 6 项目的 AWS Lambda 函数。

我在哪里可以找到有关使用 IronXL 部署 AWS Lambda 的资源?

有关使用 IronXL 部署 AWS Lambda 的资源可以在 IronXL NuGet 安装指南中找到,该指南提供了有关如何使用您的部署的 IronXL NuGet 包的文档。

当在 AWS Lambda 中使用 IronXL 时,我如何解决问题?

确保您安装了正确版本的 IronXL 和 AWS 工具包。检查代码是否有任何语法错误,并参考 IronXL 的文档以了解与 AWS Lambda 的兼容性细节。

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
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

...
阅读更多

准备开始了吗?

Nuget Downloads 2,237,574版本:2026.9刚刚发布

立即获取您的免费30 天试用密钥
无需信用卡或创建账户
C# 用于 PDF 的 NuGet 库
通过 NuGet 安装

版本: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. 在解决方案资源管理器中,右键点击引用,管理 NuGet 包
  2. 选择浏览并搜索“IronXL”
  3. 选择包并安装
C# PDF DLL
下载 DLL

版本: 2026.9

  1. 下载并解压IronXL到你的解决方案目录中的~/Libs等位置
  2. 在Visual Studio解决方案资源管理器中,右键单击引用。选择浏览,“IronXL.dll”

许可证从 $999

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户