Hi @fatih uyanık , Welcome to Microsoft Q&A,
ClosedXML has an MIT license, suitable for commercial use. (This forum does not recommend the use of third-party products, nor does it provide subsequent support for them. Use with caution.)
using ClosedXML.Excel;
using System;
namespace xxx
{
internal class Program
{
static void Main(string[] args)
{
using (var workbook = new XLWorkbook())
{
var worksheet = workbook.Worksheets.Add("data");
worksheet.Cell(1, 1).Value = "ID";
worksheet.Cell(1, 2).Value = "Name";
worksheet.Cell(1, 3).Value = "Age";
worksheet.Cell(2, 1).Value = 1;
worksheet.Cell(2, 2).Value = "Zhang San";
worksheet.Cell(2, 3).Value = 30;
int currentRow = 1;
int currentCol = 1;
string myComment = "This is a comment"; worksheet.Cell(currentRow, currentCol).GetComment().AddText(myComment);
worksheet.Columns().AdjustToContents(); // Automatically adjust column width
workbook.SaveAs("Sample.xlsx");
}
Console.WriteLine("Excel file created!");
}
}
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.