C#/C# 라이브러리
[C# NPOI] 01. 엑셀 파일 생성, 워크 시트 생성
Hostramus
2022. 9. 13. 16:08
반응형
1. Point
- 사전 준비 : '참조 - NuGet' 에서 NPOI를 설치
- 엑셀 파일 생성
- 워크 시트 생성
반응형
2. 전체 코드
// 참조 추가
using System.IO;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
namespace manual_NPOI_excel_IO
{
internal class Program
{
static void Main(string[] args)
{
var newFile = @"./dir/newbook.core.xlsx";
using (var fs = new FileStream(newFile, FileMode.Create, FileAccess.Write))
{
// 워크북 생성
IWorkbook workbook = new XSSFWorkbook();
// 시트 생성
ISheet sheet1 = workbook.CreateSheet("Sheet1");
// 작업 내용 파일에 작성 및 저장
workbook.Write(fs);
}
}
}
}
반응형