Example #1
0
        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);
        }
        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);
        }
Example #4
0
        /// <summary>
        /// Insere uma linha na tabela de dados do relatório
        /// </summary>
        public void InsertRow(int rowIndex, Object[] rowCells)
        {
            ReportCell[] cells = (ReportCell[])rowCells;

            // So renderiza as linhas pertencentes a página corrente
            if ((rowIndex >= startIndex) && (rowIndex <= endIndex))
            {
                reportTable.DrawRow(cells);
            }

            // Só adiciona os totais na última página
            int lastPage = pageControl.GetPageCount();

            if (currentPage != lastPage)
            {
                return;
            }

            // Soma os valores aos totais de cada coluna
            for (int columnIndex = 0; columnIndex < cells.Length; columnIndex++)
            {
                if (cells[columnIndex].IsNumeric)
                {
                    totalizer.IncTotal(columnIndex, cells[columnIndex].value, cells[columnIndex].type);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Insere uma linha na tabela de dados do relatório
        /// </summary>
        public void InsertRow(int rowIndex, Object[] rowCells)
        {
            ReportCell[] cells = (ReportCell[])rowCells;
            reportTable.DrawRow(cells);

            // Soma os valores aos totais de cada coluna
            for (int columnIndex = 0; columnIndex < cells.Length; columnIndex++)
            {
                if (cells[columnIndex].IsNumeric)
                {
                    totalizer.IncTotal(columnIndex, cells[columnIndex].value, cells[columnIndex].type);
                }
            }
        }