示例#1
0
        private static IFill GenerateFill(Brush brush)
        {
            if (brush != null)
            {
                SolidColorBrush solidBrush = brush as SolidColorBrush;
                if (solidBrush != null)
                {
                    return(PatternFill.CreateSolidFill(solidBrush.Color));
                }
            }

            return(null);
        }
        public void SetSorting(Workbook workbook)
        {
            #region radspreadprocessing-features-sorting_4
            Worksheet worksheet = workbook.ActiveWorksheet;

            CustomValuesSortCondition condition1 = new CustomValuesSortCondition(5, new string[] { "regular", "1 day", "2 days", "express" }, SortOrder.Ascending);
            FillColorSortCondition    condition2 = new FillColorSortCondition(7, PatternFill.CreateSolidFill(Color.FromRgb(181, 18, 27)), SortOrder.Ascending);
            FillColorSortCondition    condition3 = new FillColorSortCondition(7, PatternFill.CreateSolidFill(Color.FromRgb(94, 151, 50)), SortOrder.Ascending);
            #endregion

            #region radspreadprocessing-features-sorting_5
            worksheet.SortState.Set(new CellRange(3, 0, 17, 7), condition1, condition2, condition3);
            #endregion

            #region radspreadprocessing-features-sorting_6
            worksheet.Cells[3, 0, 17, 7].Sort(condition1, condition2, condition3);
            #endregion
        }
示例#3
0
        private void CreateWorkbookStyles()
        {
            CellStyle normalStyle = this.workbook.Styles["Normal"];

            normalStyle.Fill              = PatternFill.CreateSolidFill(new ThemableColor(ThemeColorType.Background1));
            normalStyle.FontFamily        = new ThemableFontFamily(ThemeFontType.Minor);
            normalStyle.FontSize          = UnitHelper.PointToDip(10);
            normalStyle.VerticalAlignment = RadVerticalAlignment.Center;

            CellStyle companyNameStyle = this.workbook.Styles.Add("CompanyNameStyle");

            companyNameStyle.FontFamily          = new ThemableFontFamily(ThemeFontType.Major);
            companyNameStyle.FontSize            = UnitHelper.PointToDip(48);
            companyNameStyle.HorizontalAlignment = RadHorizontalAlignment.Left;

            CellStyle expensePeriodStyle = this.workbook.Styles.Add("ExpensePeriodStyle");

            expensePeriodStyle.FontFamily          = new ThemableFontFamily("Segoe UI Light");
            expensePeriodStyle.FontSize            = UnitHelper.PointToDip(20);
            expensePeriodStyle.HorizontalAlignment = RadHorizontalAlignment.Right;

            CellStyle columnHeadersStyle = this.workbook.Styles.Add("ColumnHeadersStyle");

            columnHeadersStyle.FontFamily   = new ThemableFontFamily(ThemeFontType.Major);
            columnHeadersStyle.BottomBorder = new CellBorder(CellBorderStyle.Thick, new ThemableColor(ThemeColorType.Accent2));
            columnHeadersStyle.FontSize     = UnitHelper.PointToDip(14);

            CellStyle departmentTotalStyle = this.workbook.Styles.Add("DepartmentTotalStyle");

            departmentTotalStyle.CopyPropertiesFrom(normalStyle);
            departmentTotalStyle.FontSize   = UnitHelper.PointToDip(14);
            departmentTotalStyle.FontFamily = new ThemableFontFamily("Segoe UI Light");

            CellStyle totalStyle = this.workbook.Styles.Add("TotalStyle");

            totalStyle.Fill      = PatternFill.CreateSolidFill(new ThemableColor(ThemeColorType.Accent2));
            totalStyle.FontSize  = UnitHelper.PointToDip(14);
            totalStyle.ForeColor = new ThemableColor(ThemeColorType.Background1);
        }
        private static Task <Workbook> CreateWorkbookAsync()
        {
            return(Task.Run(() =>
            {
                Workbook workbook = new Workbook();
                workbook.Worksheets.Add();
                Worksheet worksheet = workbook.ActiveWorksheet;
                string headingStyle = "Heading 1";
                IFill valueFill = PatternFill.CreateSolidFill(new ThemableColor(ThemeColorType.Accent1, ColorShadeType.Shade1));
                CellBorders sumSeparatorBorder = new CellBorders
                {
                    Top = new CellBorder(CellBorderStyle.Dashed, new ThemableColor(ThemeColorType.Text1))
                };

                // header
                worksheet.Cells[0, 0].SetValueAsText("ASSETS");
                worksheet.Cells[0, 0, 0, 1].SetStyleName(headingStyle);

                // current assets
                worksheet.Cells[1, 0].SetValueAsText("CURRENT ASSETS");
                worksheet.Cells[2, 0].SetValueAsText("Cash and cash equivalents");
                worksheet.Cells[2, 1].SetValue(421);
                worksheet.Cells[3, 0].SetValueAsText("Short-term investments");
                worksheet.Cells[3, 1].SetValue(1791);
                worksheet.Cells[4, 0].SetValueAsText("Accounts reveivable");
                worksheet.Cells[4, 1].SetValue(2116);
                worksheet.Cells[5, 0].SetValueAsText("Deferred income taxes");
                worksheet.Cells[5, 1].SetValue(512);
                worksheet.Cells[2, 1, 5, 1].SetFill(valueFill);
                worksheet.Cells[6, 0].SetValueAsText("TOTAL CURRENT ASSETS");
                worksheet.Cells[6, 1].SetValueAsFormula(GetRangeSumFormula(2, 5, 1));
                worksheet.Cells[6, 0, 6, 1].SetBorders(sumSeparatorBorder);

                // other assets
                worksheet.Cells[8, 0].SetValueAsText("OTHER ASSETS");
                worksheet.Cells[9, 0].SetValueAsText("Property and equipment at cost");
                worksheet.Cells[9, 1].SetValue(11354);
                worksheet.Cells[10, 0].SetValueAsText("Less accumulated deprecation");
                worksheet.Cells[10, 1].SetValue(-5106);
                worksheet.Cells[11, 0].SetValueAsText("Property and equipment (net)");
                worksheet.Cells[11, 1].SetValue(6935);
                worksheet.Cells[12, 0].SetValueAsText("Long-term cash investments");
                worksheet.Cells[12, 1].SetValue(511);
                worksheet.Cells[13, 0].SetValueAsText("Equity investments");
                worksheet.Cells[13, 1].SetValue(1971);
                worksheet.Cells[14, 0].SetValueAsText("Deferred income taxes");
                worksheet.Cells[14, 1].SetValue(1145);
                worksheet.Cells[9, 1, 14, 1].SetFill(valueFill);
                worksheet.Cells[15, 0].SetValueAsText("TOTAL OTHER ASSETS");
                worksheet.Cells[15, 1].SetValueAsFormula(GetRangeSumFormula(9, 14, 1));
                worksheet.Cells[15, 0, 15, 1].SetBorders(sumSeparatorBorder);

                // footer
                worksheet.Cells[17, 0].SetValueAsText("TOTAL ASSETS");
                worksheet.Cells[17, 1].SetValueAsFormula(GetCellsSumFormula(6, 1, 15, 1));
                worksheet.Cells[17, 0, 17, 1].SetStyleName(headingStyle);

                // some ui formatting
                worksheet.Cells[1, 0, 17, 0].SetIndent(2);
                worksheet.Cells[1, 1, 17, 1].SetFormat(new CellValueFormat(@"\$#,##0.00"));
                worksheet.Columns[0, 1].AutoFitWidth();

                return workbook;
            }));
        }
 public void CreateFillColorSortCondition()
 {
     #region radspreadprocessing-features-sorting_3
     FillColorSortCondition condition = new FillColorSortCondition(0, PatternFill.CreateSolidFill(Color.FromRgb(181, 18, 27)), SortOrder.Ascending);
     #endregion
 }