C# Excel EPPlus, 2024-04-03

sunj - Apr 3 - - Dev Community
using OfficeOpenXml;
using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        // 크롤링한 데이터
        string[,] data = {
            { "Name", "Age" },
            { "John", "30" },
            { "Alice", "25" },
            { "Bob", "35" }
        };

        // 엑셀 파일 생성
        FileInfo file = new FileInfo(@"C:\Users\Username\Documents\output.xlsx");
        using (ExcelPackage package = new ExcelPackage(file))
        {
            ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Sheet1");

            // 데이터 쓰기
            for (int i = 0; i < data.GetLength(0); i++)
            {
                for (int j = 0; j < data.GetLength(1); j++)
                {
                    worksheet.Cells[i + 1, j + 1].Value = data[i, j];
                }
            }

            // 파일 저장
            package.Save();
        }

        Console.WriteLine("Excel file created successfully.");
    }
}

Enter fullscreen mode Exit fullscreen mode

참조 : chatGPT3.5

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player