コード例 #1
0
        public void ResizeColumns()
        {
            #region radspreadprocessing-working-with-rows-and-columns-resizing_2
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            ColumnSelection columnSelection = worksheet.Columns[5, 7];
            double          columnWidth     = columnSelection.GetWidth().Value.Value;
            columnSelection.SetWidth(new ColumnWidth(columnWidth + 50, true));
            #endregion
        }
コード例 #2
0
        protected Workbook createWorkbook()
        {
            Workbook workbook = new Workbook();

            workbook.Sheets.Add(SheetType.Worksheet);
            Worksheet worksheet = workbook.ActiveWorksheet;

            worksheet.Name = "OTE RT";
            List <TaskB> tasks = new List <TaskB>();

            try {
                string recFilter = gridMain.MasterTableView.FilterExpression;
                GridSortExpressionCollection gridSortExxpressions = gridMain.MasterTableView.SortExpressions;
                TasksController cont       = new TasksController();
                int             tasksCount = cont.CountAllTasks(recFilter);
                tasks = cont.GetAllTasks(0, tasksCount, recFilter, gridSortExxpressions);
            }
            catch (Exception) { }
            prepareDocument(worksheet);
            int         currentRow = 1;
            CellBorder  border     = new CellBorder(CellBorderStyle.Thin, tcBlack);
            CellBorders borders    = new CellBorders(border, border, border, border, null, null, null, null);
            double      fontSize   = 12;

            foreach (TaskB curTask in tasks)
            {
                worksheet.Cells[currentRow, 0].SetValue(curTask.ID.ToString());
                worksheet.Cells[currentRow, 0].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 0].SetBorders(borders);
                worksheet.Cells[currentRow, 1].SetValue(curTask.RegNo);
                worksheet.Cells[currentRow, 1].SetFormat(new CellValueFormat("@"));
                worksheet.Cells[currentRow, 1].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 1].SetBorders(borders);
                worksheet.Cells[currentRow, 2].SetValue(curTask.OrderDate);
                worksheet.Cells[currentRow, 2].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 2].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 2].SetBorders(borders);
                worksheet.Cells[currentRow, 3].SetValue(curTask.Customer.NameGR);
                worksheet.Cells[currentRow, 3].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 3].SetBorders(borders);
                worksheet.Cells[currentRow, 4].SetValue(curTask.Job.Name);
                worksheet.Cells[currentRow, 4].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 4].SetBorders(borders);
                string distance = curTask.Distance.Position1 + " - " + curTask.Distance.Position2 + " (" + curTask.Distance.KM.ToString() + ")";
                worksheet.Cells[currentRow, 5].SetValue(distance);
                worksheet.Cells[currentRow, 5].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 5].SetBorders(borders);
                worksheet.Cells[currentRow, 6].SetValue(curTask.DateTimeStartOrder.GetValueOrDefault());
                worksheet.Cells[currentRow, 6].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 6].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 6].SetBorders(borders);
                worksheet.Cells[currentRow, 7].SetValue(curTask.DateTimeEndOrder.GetValueOrDefault());
                worksheet.Cells[currentRow, 7].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 7].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 7].SetBorders(borders);
                worksheet.Cells[currentRow, 8].SetValue(curTask.DateTimeDurationOrder);
                worksheet.Cells[currentRow, 8].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 8].SetBorders(borders);
                worksheet.Cells[currentRow, 9].SetValue(double.Parse(curTask.AddedCharges.GetValueOrDefault().ToString()));
                worksheet.Cells[currentRow, 9].SetFormat(new CellValueFormat(currencyFormat));
                worksheet.Cells[currentRow, 9].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 9].SetBorders(borders);
                worksheet.Cells[currentRow, 10].SetValue(double.Parse(curTask.CostCalculated.GetValueOrDefault().ToString()));
                worksheet.Cells[currentRow, 10].SetFormat(new CellValueFormat(currencyFormat));
                worksheet.Cells[currentRow, 10].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 10].SetBorders(borders);
                if (curTask.DateTimeStartActual.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 11].SetValue(curTask.DateTimeStartActual.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 11].SetValue("");
                }
                worksheet.Cells[currentRow, 11].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 11].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 11].SetBorders(borders);
                if (curTask.DateTimeEndActual.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 12].SetValue(curTask.DateTimeEndActual.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 12].SetValue("");
                }
                worksheet.Cells[currentRow, 12].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 12].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 12].SetBorders(borders);
                if (curTask.IsCanceled == true)
                {
                    worksheet.Cells[currentRow, 13].SetValue(0);
                }
                else
                {
                    worksheet.Cells[currentRow, 13].SetValue(curTask.DateTimeDurationActual.GetValueOrDefault());
                }
                worksheet.Cells[currentRow, 13].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 13].SetBorders(borders);
                if (curTask.PaymentDateOrder.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 14].SetValue(curTask.PaymentDateOrder.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 14].SetValue("");
                }
                worksheet.Cells[currentRow, 14].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 14].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 14].SetBorders(borders);
                worksheet.Cells[currentRow, 15].SetValue(double.Parse(curTask.CostActual.GetValueOrDefault().ToString()));
                worksheet.Cells[currentRow, 15].SetFormat(new CellValueFormat(currencyFormat));
                worksheet.Cells[currentRow, 15].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 15].SetBorders(borders);
                if (curTask.PaymentDateCalculated.GetValueOrDefault().Year > 2000)
                {
                    worksheet.Cells[currentRow, 16].SetValue(curTask.PaymentDateCalculated.GetValueOrDefault());
                }
                else
                {
                    worksheet.Cells[currentRow, 16].SetValue("");
                }
                worksheet.Cells[currentRow, 16].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 16].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 16].SetBorders(borders);
                //if (curTask.PaymentDateActual.GetValueOrDefault().Year > 2000) {
                //    worksheet.Cells[currentRow, 17].SetValue(curTask.PaymentDateActual.GetValueOrDefault());
                //} else {
                //    worksheet.Cells[currentRow, 17].SetValue("");
                //}
                //worksheet.Cells[currentRow,17].SetFormat(new CellValueFormat(dateFormat));
                //worksheet.Cells[currentRow,17].SetFontSize(fontSize);
                //worksheet.Cells[currentRow,17].SetBorders(borders);
                string isCanc = "ΟΧΙ";
                if (curTask.IsCanceled == true)
                {
                    isCanc = "ΝΑΙ";
                }
                worksheet.Cells[currentRow, 17].SetValue(isCanc);
                worksheet.Cells[currentRow, 17].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 17].SetBorders(borders);
                worksheet.Cells[currentRow, 18].SetValue(curTask.Comments);
                worksheet.Cells[currentRow, 18].SetIsWrapped(true);
                worksheet.Cells[currentRow, 18].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 18].SetBorders(borders);
                worksheet.Cells[currentRow, 19].SetValue(curTask.InvoceComments);
                worksheet.Cells[currentRow, 19].SetIsWrapped(true);
                worksheet.Cells[currentRow, 19].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 19].SetBorders(borders);
                worksheet.Cells[currentRow, 20].SetValue(curTask.EnteredByUser);
                worksheet.Cells[currentRow, 20].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 20].SetBorders(borders);
                worksheet.Cells[currentRow, 21].SetValue(curTask.DateStamp);
                worksheet.Cells[currentRow, 21].SetFormat(new CellValueFormat(dateFormat));
                worksheet.Cells[currentRow, 21].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 21].SetBorders(borders);
                currentRow++;
            }
            for (int i = 0; i < worksheet.Columns.Count; i++)
            {
                worksheet.Columns[i].AutoFitWidth();
            }
            for (int i = 0; i < worksheet.Columns.Count; i++)
            {
                if (i == 18 || i == 19)
                {
                    worksheet.Columns[i].SetWidth(new ColumnWidth(300, true));
                }
                ColumnSelection columnSelection = worksheet.Columns[i];
                ColumnWidth     columnWidth     = columnSelection.GetWidth().Value;
                double          curColWidth     = columnWidth.Value + 10;
                if (curColWidth > 2000)
                {
                    curColWidth = 2000;
                }
                columnSelection.SetWidth(new ColumnWidth(curColWidth, columnWidth.IsCustom));
            }
            ColumnSelection columnSelection4 = worksheet.Columns[4];
            ColumnWidth     columnWidth4     = columnSelection4.GetWidth().Value;
            double          curColWidth4     = columnWidth4.Value + 10;

            if (curColWidth4 > 2000)
            {
                curColWidth4 = 2000;
            }
            columnSelection4.SetWidth(new ColumnWidth(curColWidth4, columnWidth4.IsCustom));
            return(workbook);
        }
コード例 #3
0
        protected Workbook createWorkbook()
        {
            Workbook workbook = new Workbook();

            workbook.Sheets.Add(SheetType.Worksheet);
            Worksheet worksheet = workbook.ActiveWorksheet;

            worksheet.Name = "KET " + forDate.ToString("dd-MM-yyyy");
            List <TaskForH> tasks = getTasksForHelpers(forDate);

            prepareDocument(worksheet);
            int         currentRow = 1;
            CellBorder  border     = new CellBorder(CellBorderStyle.Thin, tcBlack);
            CellBorders borders    = new CellBorders(border, border, border, border, null, null, null, null);
            double      fontSize   = 12;

            foreach (TaskForH curTask in tasks)
            {
                worksheet.Cells[currentRow, 0].SetValue(curTask.Count.ToString());
                worksheet.Cells[currentRow, 0].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 0].SetBorders(borders);
                worksheet.Cells[currentRow, 1].SetValue(curTask.Customer);
                worksheet.Cells[currentRow, 1].SetFormat(new CellValueFormat("@"));
                worksheet.Cells[currentRow, 1].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 1].SetBorders(borders);
                worksheet.Cells[currentRow, 2].SetValue(curTask.FromPlace);
                worksheet.Cells[currentRow, 2].SetFormat(new CellValueFormat("@"));
                worksheet.Cells[currentRow, 2].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 2].SetBorders(borders);
                worksheet.Cells[currentRow, 3].SetValue(curTask.FromTime + " - " + curTask.ToTime);
                worksheet.Cells[currentRow, 3].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 3].SetBorders(borders);
                worksheet.Cells[currentRow, 4].SetValue(curTask.Comments);
                worksheet.Cells[currentRow, 4].SetIsWrapped(true);
                worksheet.Cells[currentRow, 4].SetFontSize(fontSize);
                worksheet.Cells[currentRow, 4].SetBorders(borders);
                currentRow++;
            }
            for (int i = 0; i < worksheet.Columns.Count; i++)
            {
                worksheet.Columns[i].AutoFitWidth();
            }
            for (int i = 0; i < worksheet.Columns.Count; i++)
            {
                if (i == 4)
                {
                    worksheet.Columns[i].SetWidth(new ColumnWidth(500, true));
                }
                ColumnSelection columnSelection = worksheet.Columns[i];
                ColumnWidth     columnWidth     = columnSelection.GetWidth().Value;
                double          curColWidth     = columnWidth.Value + 10;
                if (curColWidth > 2000)
                {
                    curColWidth = 2000;
                }
                columnSelection.SetWidth(new ColumnWidth(curColWidth, columnWidth.IsCustom));
            }
            ColumnSelection columnSelection4 = worksheet.Columns[4];
            ColumnWidth     columnWidth4     = columnSelection4.GetWidth().Value;
            double          curColWidth4     = columnWidth4.Value + 10;

            if (curColWidth4 > 2000)
            {
                curColWidth4 = 2000;
            }
            columnSelection4.SetWidth(new ColumnWidth(curColWidth4, columnWidth4.IsCustom));
            return(workbook);
        }