protected ICell ObterCelulaParaCabecalho(int numeroLinha, int numeroColuna, string nomeAba, bool borda, IndexedColors cor = null, XSSFColor corXssf = null) { ICell celula = ObterCelula(numeroLinha, numeroColuna, nomeAba); var estiloTemporario = (XSSFCellStyle)WorkBook.CreateCellStyle(); estiloTemporario = (XSSFCellStyle)EstiloCelulaCabecalho.Clone(); if (!borda) { estiloTemporario.BorderBottom = BorderStyle.None; estiloTemporario.BorderTop = BorderStyle.None; estiloTemporario.BorderLeft = BorderStyle.None; estiloTemporario.BorderRight = BorderStyle.None; } if (cor != null) { estiloTemporario.FillForegroundColor = cor.Index; estiloTemporario.FillPattern = FillPattern.SolidForeground; } else if (corXssf != null) { estiloTemporario.SetFillForegroundColor(corXssf); estiloTemporario.FillPattern = FillPattern.SolidForeground; } celula.CellStyle = estiloTemporario; return(celula); }
private void CriarEstiloCabecalho() { EstiloCelulaCabecalho = (XSSFCellStyle)WorkBook.CreateCellStyle(); EstiloCelulaCabecalho.Alignment = HorizontalAlignment.Center; EstiloCelulaCabecalho.VerticalAlignment = VerticalAlignment.Center; EstiloCelulaCabecalho.SetFont(FonteCabecalho); EstiloCelulaCabecalho.WrapText = true; EstiloCelulaCabecalho.BorderBottom = BorderStyle.Thin; EstiloCelulaCabecalho.BorderTop = BorderStyle.Thin; EstiloCelulaCabecalho.BorderLeft = BorderStyle.Thin; EstiloCelulaCabecalho.BorderRight = BorderStyle.Thin; }