Reputation: 2997
I have been looking for a way to set the PatternType of cells in a column to Diagonal Crosshatch while using EPPlus.
First of all, changing the library is not an option here since the original work is not mine and I wouldn't want to mess it up.
So how do we set the PatternType to lets say Diagonal Crosshatch or Thin Horizontal Strips Honestly, searched entire internet, and no clue how to do this.
Sample line of code, that I have been using:
ws.Cells["D1:D" + lastRowNumber].Style.Fill.PatternType=OfficeOpenXml.Style.ExcelFillStyle.Gray125;
Upvotes: 1
Views: 6320
Reputation: 561
In order to change pattern types you would just change the ExcelFillStyle.
For Thin Horizontal Stripes:
ws.Cells["D1:D" + lastRowNumber].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.ThinHorizontal;
For Diagonal Crosshatch:
ws.Cells["D1:D" + lastRowNumber].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.LightTrellis;
Upvotes: 3