Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EPPlus Excel文件Fill.PatternType、Fill.PatternColor或Fill.BackgroundColor_C#_Excel_Epplus - Fatal编程技术网

C# EPPlus Excel文件Fill.PatternType、Fill.PatternColor或Fill.BackgroundColor

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

我正在尝试生成一个Excel文件,其背景与普通Excel文件类似。当我在我的程序中创建我的时,它会将背景设置为黑色,而你看不到任何东西。我不确定是否设置了错误的属性,但以下是我正在尝试的:

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来解决这个问题。