C# Excel 마지막 행 찾기, 2024-04-03

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

class Program
{
    static void Main(string[] args)
    {
        // 엑셀 파일 경로
        string filePath = @"C:\Users\Username\Documents\output.xlsx";

        // 엑셀 파일 불러오기
        FileInfo file = new FileInfo(filePath);
        using (ExcelPackage package = new ExcelPackage(file))
        {
            ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"];

            // 마지막 행 찾기
            int lastRow = worksheet.Dimension.End.Row + 1;

            // 새로운 데이터 추가
            worksheet.Cells[lastRow, 1].Value = "New Name";
            worksheet.Cells[lastRow, 2].Value = "New Age";

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

        Console.WriteLine("New data added to the Excel file successfully.");
    }
}

Enter fullscreen mode Exit fullscreen mode

참조 : chatGPT3.5

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