を使用してExcelスプレッドシートのセルの列全体に色をしようとすると、私はNPOIを使用してExcelファイル内のカラーセルに使用しているC#プログラムです:はNPOI
string pathSource = @"C:\Users\mvmurthy\Downloads\VOExportTemplate (2).xlsx";
HSSFWorkbook templateWorkbook;
HSSFSheet sheet;
HSSFRow dataRow;
using (var fs = new FileStream(pathSource, FileMode.Open, FileAccess.ReadWrite))
{
templateWorkbook = new HSSFWorkbook(fs, true);
sheet = (HSSFSheet)templateWorkbook.GetSheet("ImportTemplate");
int num = sheet.PhysicalNumberOfRows;
for (int i=1; i<num; i++)
{
dataRow = (HSSFRow)sheet.GetRow(i);
HSSFCellStyle hStyle = (HSSFCellStyle)templateWorkbook.CreateCellStyle();
hStyle = (HSSFCellStyle)templateWorkbook.CreateCellStyle();
hStyle.FillForegroundColor = IndexedColors.Red.Index;
hStyle.FillPattern = FillPattern.SolidForeground;
dataRow.Cells[9].CellStyle = hStyle;
}
}
using (var fs = new FileStream(pathSource, FileMode.Open, FileAccess.ReadWrite))
{
templateWorkbook.Write(fs);
}
私は上記のコードを実行するとI次の出力を得ることが、私には、列Kを色付けしたいのです:
私が間違って何をしているのですか?