Exemple #1
0
        protected void WriteRows()
        {
            bool done = false;

            int totalRowsReturned = 0;

            //  Read pageSize records at a time and write out the CSV file.
            while (!done)
            {
                ArrayList recList = data.GetRows(pageSize);
                if (recList == null)
                {
                    break; //we are done
                }
                totalRowsReturned = recList.Count;
                foreach (BaseRecord rec in recList)
                {
                    foreach (BaseColumn col in data.ColumnList)
                    {
                        if (col == null)
                        {
                            continue;
                        }

                        if (!data.IncludeInExport(col))
                        {
                            continue;
                        }

                        String val = GetDataForExport(col, rec);

                        base.WriteColumnData(val, data.IsString(col));
                    }
                    base.WriteNewRow();
                }

                //  If we already are below the pageSize, then we are done.
                if ((totalRowsReturned < pageSize))
                {
                    done = true;
                }
            }
        }
Exemple #2
0
        public override void Export(System.Web.HttpResponse response)
        {
            bool   done = false;
            object val;

            if (response == null)
            {
                return;
            }

            CreateExcelBook();

            int width         = 0;
            int columnCounter = 0;

            //  First write out the Column Headers
            foreach (ExcelColumn col in data.ColumnList)
            {
                width = GetExcelCellWidth(col);
                if (data.IncludeInExport(col))
                {
                    AddColumnToExcelBook(columnCounter, col.ToString(), GetExcelDataType(col), width, GetDisplayFormat(col));
                    columnCounter++;
                }
            }
            // Read pageSize records at a time and write out the Excel file.
            int totalRowsReturned = 0;

            while (!done)
            {
                ArrayList recList = data.GetRows(pageSize);

                if (recList == null)
                {
                    break;
                }
                totalRowsReturned = recList.Count;

                foreach (BaseRecord rec in recList)
                {
                    AddRowToExcelBook();
                    columnCounter = 0;
                    foreach (ExcelColumn col in data.ColumnList)
                    {
                        if (!data.IncludeInExport(col))
                        {
                            continue;
                        }

                        val = GetValueForExcelExport(col, rec);
                        AddCellToExcelRow(columnCounter, GetExcelDataType(col), val, col.DisplayFormat);

                        columnCounter++;
                    }
                }

                // If we already are below the pageSize, then we are done.
                if ((totalRowsReturned < pageSize))
                {
                    done = true;
                }
            }

            SaveExcelBook(response);
        }