I'm using the NPOI library to be able to generate an Excel file.
This is the first time I've been in touch with this library and would like help putting background color on the cells in the first row.
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);
}
}
}
}