C# EPPlus Excel文件Fill.PatternType、Fill.PatternColor或Fill.BackgroundColor
我正在尝试生成一个Excel文件,其背景与普通Excel文件类似。当我在我的程序中创建我的时,它会将背景设置为黑色,而你看不到任何东西。我不确定是否设置了错误的属性,但以下是我正在尝试的:C# EPPlus Excel文件Fill.PatternType、Fill.PatternColor或Fill.BackgroundColor,c#,excel,epplus,C#,Excel,Epplus,我正在尝试生成一个Excel文件,其背景与普通Excel文件类似。当我在我的程序中创建我的时,它会将背景设置为黑色,而你看不到任何东西。我不确定是否设置了错误的属性,但以下是我正在尝试的: sheet.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid; //sheet.Cells.Style.Fill.BackgroundColor.SetColor( Color.Empty ); sheet.Cells.Style.Fill.Pattern
sheet.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
//sheet.Cells.Style.Fill.BackgroundColor.SetColor( Color.Empty );
sheet.Cells.Style.Fill.PatternColor.SetColor( Color.Transparent );
我所要做的就是创建一个没有背景的excel文件,就像手动创建一个空白excel文件一样。有什么想法吗?你唯一要做的就是:
ws.Cells[range].Style.Fill.PatternType = ExcelFillStyle.None;
//ws.Cells[range].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Transparent);
在您自己的代码中:
sheet.Cells.Style.Fill.PatternType = ExcelFillStyle.None;
//sheet.Cells.Style.Fill.BackgroundColor.SetColor( Color.Empty );
//sheet.Cells.Style.Fill.PatternColor.SetColor( Color.Transparent );
就这样如果你只是省略了这两行怎么办?如果你只想使用默认设置,你就不必触摸背景样式。嗨@Ernie,我想在工作表中的某个地方为单元格设置背景颜色,这会迫使我设置填充。PattenType@Ernie,我通过只为相关单元格设置填充.PatternType来解决这个问题。