private String FormatCell(ReportCell cell, int columnIndex) { String cellContent; switch (cell.type) { case ReportCellType.Number: cellContent = String.Format("{0}", cell.value); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Money: cellContent = String.Format("R$ {0:0.000}", cell.value); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Percentage: cellContent = String.Format("{0:0.##}%", (double)cell.value * 100); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Totalizer: cellContent = totalizer.GetTotal(columnIndex, cell.subType); break; default: // por defalut considera o conteudo da célula como texto cellContent = String.Format("{0}", cell.value); break; } return(cellContent); }
private Cell CreateCell(ReportCell cell, int columnIndex) { String cellContent; switch (cell.type) { case ReportCellType.Number: cellContent = String.Format("{0}", cell.value); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Money: cellContent = String.Format("R$ {0:0.000}", cell.value); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Percentage: cellContent = String.Format("{0:0.##}%", (double)cell.value * 100); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Totalizer: cellContent = totalizer.GetTotal(columnIndex, cell.subType); break; default: // por defalut considera o conteudo da célula como texto cellContent = String.Format("{0}", cell.value); break; } Cell newCell = new Cell(cellContent); newCell.SetHorizontalAlignment(cell.align.ToString()); newCell.SetVerticalAlignment(ElementTags.ALIGN_MIDDLE); return(newCell); }
/// <summary> /// Insere o rodapé na tabela de dados do relatório /// </summary> public void InsertFooter(Object[] footerCells) { ReportCell[] cells = (ReportCell[])footerCells; // Obtem os totais de cada coluna for (int columnIndex = 0; columnIndex < cells.Length; columnIndex++) { if (cells[columnIndex].type == ReportCellType.Totalizer) { cells[columnIndex].value = totalizer.GetTotal(columnIndex, cells[columnIndex].subType); } } reportTable.DrawFooter(cells); }
private String FormatCell(ReportCell cell, int columnIndex) { String cellContent; Boolean isText = false; switch (cell.type) { case ReportCellType.Number: cellContent = String.Format("{0}", cell.value); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Money: cellContent = String.Format("R$ {0:0.000}", cell.value); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Percentage: cellContent = String.Format("{0:0.##}%", (double)cell.value * 100); totalizer.IncTotal(columnIndex, cell.value, cell.type); break; case ReportCellType.Totalizer: cellContent = totalizer.GetTotal(columnIndex, cell.subType); break; default: // por defalut considera o conteudo da célula como texto cellContent = String.Format("{0}", cell.value); isText = true; break; } // Ajusta apontuação decimal e de milhar para evitar virgulas extras pois o // csv fica quebrado se houverem virgulas além daquelas que separam colunas if ((!isText) && (decimalSeparatorIsComma)) { cellContent = cellContent.Replace(".", ""); // retira pontuação de milhar cellContent = cellContent.Replace(",", "."); // substitui virgula por ponto } // Retira as vírulas dos campos contendo texto if (isText) { cellContent = cellContent.Replace(",", ""); } return(cellContent); }
/// <summary> /// Insere o rodapé na tabela de dados do relatório /// </summary> public void InsertFooter(Object[] footerCells) { // Só insere o rodapé na última página int lastPage = pageControl.GetPageCount(); if (currentPage != lastPage) { return; } ReportCell[] cells = (ReportCell[])footerCells; // Obtem os totais de cada coluna for (int columnIndex = 0; columnIndex < cells.Length; columnIndex++) { if (cells[columnIndex].type == ReportCellType.Totalizer) { cells[columnIndex].value = totalizer.GetTotal(columnIndex, cells[columnIndex].subType); } } reportTable.DrawFooter(cells); }