programing

"excel package"로 색상 또는 배경을 설정하는 방법

kingscode 2023. 7. 20. 22:46
반응형

"excel package"로 색상 또는 배경을 설정하는 방법

다음 패키지를 사용합니다. 배경색 설정 방법을 알 수 없지만 Excel Package.사용하려고 했습니다.

ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;

그러나 속성을 찾을 수 없다는 것을 보여줍니다.

enter image description here

이와 유사한 것을 사용해야 할 것 같습니다.

worksheet.Cell(5, columnIndex + 1).Style = "background-color: red";

하지만 어떻게 작동하는지 잘 몰라서 튜토리얼을 찾을 수가 없었어요.제발 도와주세요.

다음과 같은 방법을 사용해 보십시오(제공된 EP Plus 샘플 파일에서 발췌).

using (var range = worksheet.Cells[1, 1, 1, 5]) 
    {
        range.Style.Fill.PatternType = ExcelFillStyle.Solid;
        range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
    }

위해서ExcelPackage

workSheet.Cells["A1:B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.LightTrellis;
workSheet.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightSeaGreen);
var allCells = workSheet.Cells["A1:B1"];
var cellFont = allCells.Style.Font;

언급URL : https://stackoverflow.com/questions/17156118/how-to-set-color-or-background-with-excelpackage

반응형