2
I am using the NPOI library to generate an Excel file.
It is the first time I am having contact with this library and would like help to put background color in the cells of the first line.
My current code is this:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NPOI.HSSF.UserModel;
using NPOI.HSSF.Util;
namespace Excel
{
class Program
{
static void Main(string[] args)
{
var wb = new HSSFWorkbook();
var sheet = wb.CreateSheet("Model");
var header = sheet.CreateRow(0);
header.CreateCell(0).SetCellValue("Title");
header.CreateCell(1).SetCellValue("Text");
string filename = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".xls");
using (var stream = File.Open(filename, FileMode.Create))
{
wb.Write(stream);
}
}
}
}