Пример #1
0
        private void GeraArquivo(System.Data.DataTable dt, string dataInicial, string dataFinal)
        {
            SLDocument sl = new SLDocument();

            int linha = 1;

            //Set das configurações do arquivos e variaveis de style
            SLPageSettings ps = new SLPageSettings();

            ps.Orientation = OrientationValues.Landscape;
            ps.PaperSize   = SLPaperSizeValues.A4Paper;


            sl.SetPageSettings(ps);

            SLStyle bordaAcima = sl.CreateStyle();

            bordaAcima.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle resultBold = sl.CreateStyle();

            resultBold.SetFontBold(true);
            resultBold.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultBold.SetRightBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultBold.SetBottomBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultBold.SetLeftBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle resultRed = sl.CreateStyle();

            resultRed.SetFontBold(true);
            resultRed.SetFontColor(System.Drawing.Color.Red);
            resultRed.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultRed.SetRightBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultRed.SetBottomBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultRed.SetLeftBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle bordaContorno = sl.CreateStyle();

            bordaContorno.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            bordaContorno.SetRightBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            bordaContorno.SetBottomBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            bordaContorno.SetLeftBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle alinhadoCentro = sl.CreateStyle();

            alinhadoCentro.Alignment.Horizontal = HorizontalAlignmentValues.Center;
            alinhadoCentro.Alignment.Vertical   = VerticalAlignmentValues.Center;
            alinhadoCentro.SetWrapText(true);

            sl.SetCellValue(linha, 1, "Código Empresa");
            sl.SetCellValue(linha, 2, "Número do registro do empregado");
            sl.SetCellValue(linha, 3, "Nome");
            sl.SetCellValue(linha, 4, "E-mail");
            sl.SetCellValue(linha, 5, "Data da compra");
            sl.SetCellValue(linha, 6, "Valor da compra");
            sl.SetCellValue(linha, 7, "Quantidade de ingressos");
            sl.SetCellValue(linha, 8, "Parcelas");
            sl.SetCellValue(linha, 9, "Forma de pagamento");
            sl.SetCellValue(linha, 10, "Data de vencimento");

            sl.SetCellStyle(linha, 1, bordaContorno);
            sl.SetCellStyle(linha, 2, bordaContorno);
            sl.SetCellStyle(linha, 3, bordaContorno);
            sl.SetCellStyle(linha, 4, bordaContorno);
            sl.SetCellStyle(linha, 5, bordaContorno);
            sl.SetCellStyle(linha, 6, bordaContorno);
            sl.SetCellStyle(linha, 7, bordaContorno);
            sl.SetCellStyle(linha, 8, bordaContorno);
            sl.SetCellStyle(linha, 9, bordaContorno);
            sl.SetCellStyle(linha, 10, bordaContorno);

            sl.SetCellStyle(linha, 1, resultBold);
            sl.SetCellStyle(linha, 2, resultBold);
            sl.SetCellStyle(linha, 3, resultBold);
            sl.SetCellStyle(linha, 4, resultBold);
            sl.SetCellStyle(linha, 5, resultBold);
            sl.SetCellStyle(linha, 6, resultBold);
            sl.SetCellStyle(linha, 7, resultBold);
            sl.SetCellStyle(linha, 8, resultBold);
            sl.SetCellStyle(linha, 9, resultBold);
            sl.SetCellStyle(linha, 10, resultBold);

            linha++;

            foreach (DataRow dr in dt.Rows)
            {
                sl.SetCellValue(linha, 1, dr[0].ToString());
                sl.SetCellValue(linha, 2, dr[1].ToString());
                sl.SetCellValue(linha, 3, dr[2].ToString());
                sl.SetCellValue(linha, 4, dr[3].ToString());
                sl.SetCellValue(linha, 5, dr[4].ToString());
                sl.SetCellValue(linha, 6, dr[5].ToString());
                sl.SetCellValue(linha, 7, dr[6].ToString());
                sl.SetCellValue(linha, 8, dr[7].ToString());
                sl.SetCellValue(linha, 9, dr[8].ToString());
                sl.SetCellValue(linha, 10, dr[9].ToString());

                sl.SetCellStyle(linha, 1, bordaContorno);
                sl.SetCellStyle(linha, 2, bordaContorno);
                sl.SetCellStyle(linha, 3, bordaContorno);
                sl.SetCellStyle(linha, 4, bordaContorno);
                sl.SetCellStyle(linha, 5, bordaContorno);
                sl.SetCellStyle(linha, 6, bordaContorno);
                sl.SetCellStyle(linha, 7, bordaContorno);
                sl.SetCellStyle(linha, 8, bordaContorno);
                sl.SetCellStyle(linha, 9, bordaContorno);
                sl.SetCellStyle(linha, 10, bordaContorno);
                linha++;
            }
            sl.AutoFitColumn(1);
            sl.AutoFitColumn(2);
            sl.AutoFitColumn(3);
            sl.AutoFitColumn(4);
            sl.AutoFitColumn(5);
            sl.AutoFitColumn(6);
            sl.AutoFitColumn(7);
            sl.AutoFitColumn(8);
            sl.AutoFitColumn(9);
            sl.AutoFitColumn(10);

            string arquivo;

            if (!String.IsNullOrEmpty(dataInicial) && !String.IsNullOrEmpty(dataFinal))
            {
                arquivo = Server.MapPath(@"UploadFile\\" + "Relatorio_Festa_Aposentados "
                                         + dataInicial +
                                         " á " + dataFinal + ".xlsx");
            }
            else
            {
                arquivo = Server.MapPath(@"UploadFile\\" + "Relatorio_Festa_Aposentados_Geral.xlsx");
            }

            sl.SaveAs(arquivo);
        }
Пример #2
0
        private void mergeButton_Click(object sender, EventArgs e)
        {
            bool bRC;
            int  nInfoRow = nFirstRow - 4;
            //int itemCnt = 0;

            string fullTemplateName = Path.Combine(Properties.Settings.Default.LastTemplatePath, sourceTemplateInput.Text);

            bRC = sl.SelectWorksheet("Form1");

            string partNo   = sl.GetCellValueAsString(nInfoRow, 2);
            string partName = sl.GetCellValueAsString(nInfoRow, 4);
            string reportNo = sl.GetCellValueAsString(nInfoRow, 8);
            string serialNo = String.Empty;

            //SLDocument sl = new SLDocument(fullTemplateName, "Form1");

            SLStyle styleFloat = sl.CreateStyle();

            styleFloat.FormatCode = fontFormat;
            styleFloat.SetFontColor(System.Drawing.Color.Black);
            styleFloat.Font.FontName        = fontName;
            styleFloat.Font.FontSize        = Convert.ToInt16(fontSize);
            styleFloat.Alignment.Horizontal = HorizontalAlignmentValues.Center;
            styleFloat.Alignment.Vertical   = VerticalAlignmentValues.Center;
            styleFloat.SetHorizontalAlignment(HorizontalAlignmentValues.Center);

            SLStyle styleFloatV2 = sl.CreateStyle();

            styleFloatV2.Font.FontName        = fontName;
            styleFloatV2.Font.FontSize        = Convert.ToInt16(fontSize);
            styleFloatV2.Alignment.Horizontal = HorizontalAlignmentValues.Center;
            styleFloatV2.Alignment.Vertical   = VerticalAlignmentValues.Center;
            styleFloatV2.SetHorizontalAlignment(HorizontalAlignmentValues.Center);

            SLStyle styleFloatV2LJ = sl.CreateStyle();

            styleFloatV2LJ.Font.FontName        = fontName;
            styleFloatV2LJ.Font.FontSize        = Convert.ToInt16(fontSize);
            styleFloatV2LJ.Alignment.Horizontal = HorizontalAlignmentValues.Left;
            styleFloatV2LJ.Alignment.Vertical   = VerticalAlignmentValues.Center;
            styleFloatV2LJ.SetHorizontalAlignment(HorizontalAlignmentValues.Left);

            SLStyle styleFloatPass = sl.CreateStyle();

            styleFloatPass.FormatCode = fontFormat;
            //styleFloatPass.Fill.SetPatternBackgroundColor(System.Drawing.Color.LightGreen);
            styleFloatPass.SetFontColor(System.Drawing.Color.Black);
            styleFloatPass.Font.FontName        = fontName;
            styleFloatPass.Font.FontSize        = Convert.ToInt16(fontSize);
            styleFloatPass.Font.Bold            = false;
            styleFloatPass.Font.Italic          = false;
            styleFloatPass.Alignment.Horizontal = HorizontalAlignmentValues.Center;
            styleFloatPass.Alignment.Vertical   = VerticalAlignmentValues.Center;
            styleFloatPass.SetHorizontalAlignment(HorizontalAlignmentValues.Center);
            styleFloatPass.Fill.SetPattern(PatternValues.Solid, System.Drawing.Color.White, System.Drawing.Color.White);

            SLStyle styleFloatDev = sl.CreateStyle();

            styleFloatDev.FormatCode = fontFormat;
            styleFloatDev.SetFontColor(System.Drawing.Color.Black);
            styleFloatDev.Font.FontName        = fontName;
            styleFloatDev.Font.FontSize        = Convert.ToInt16(fontSize);
            styleFloatDev.Font.Bold            = false;
            styleFloatDev.Font.Italic          = false;
            styleFloatDev.Alignment.Horizontal = HorizontalAlignmentValues.Center;
            styleFloatDev.Alignment.Vertical   = VerticalAlignmentValues.Center;
            styleFloatDev.SetHorizontalAlignment(HorizontalAlignmentValues.Center);
            styleFloatDev.Fill.SetPattern(PatternValues.Solid, System.Drawing.Color.LightPink, System.Drawing.Color.Red);

            SLStyle styleString = sl.CreateStyle();

            styleString.SetFontColor(System.Drawing.Color.Black);
            styleString.Font.FontName = fontName;
            styleString.Font.FontSize = Convert.ToInt16(fontSize);

//            foreach (resultGrid grid in grids.Values)
            foreach (resultGrid grid in fileToGrid.Values)
            {
                int          nRow;
                TabPage      tabPage = grid.tabPage;
                DataGridView gridCtl = grid.gridControl;
                string       runNo   = grid.runNo;
                string       title   = tabPage.Text;

                bRC = sl.SelectWorksheet("Form1");
                bRC = sl.CopyWorksheet("Form3", title);
                bRC = sl.SelectWorksheet(title);

                // set this sheets serial number
                serialNo = String.Format("{0}-{1}", partNo, runNo);
                sl.SetCellValue(nInfoRow, 12, serialNo);


                foreach (DataGridViewRow row in gridCtl.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }

                    string charNo    = row.Cells["CharNo"].Value.ToString();
                    string nominal   = row.Cells["Nominal"].Value.ToString();
                    string upper     = row.Cells["Upper"].Value.ToString();
                    string lower     = row.Cells["Lower"].Value.ToString();
                    string actual    = row.Cells["Actual"].Value.ToString();
                    string deviation = row.Cells["Deviation"].Value.ToString();

                    nRow = charInfos[charNo].charRow;

                    // Actual
                    double actualVal;
                    if (actual.Length > 0)
                    {
                        actualVal = Math.Abs(Convert.ToDouble(actual));
                        sl.SetCellValue(nRow, 9, actualVal);
                        sl.SetCellStyle(nRow, 9, styleFloat);
                    }

                    sl.SetCellValue(nRow, 9, actual);
                    sl.SetCellStyle(nRow, 9, styleFloat);

                    sl.SetCellStyle(nRow, 2, styleFloatV2);
                    sl.SetCellStyle(nRow, 4, styleFloatV2LJ);
                    sl.SetCellStyle(nRow, 5, styleFloatV2LJ);
                    sl.SetCellStyle(nRow, 6, styleFloatV2);
                    sl.SetCellStyle(nRow, 7, styleFloatV2);
                    sl.SetCellStyle(nRow, 8, styleFloatV2);

                    // Exceed
                    double exceed = 0;
                    if (deviation.Length > 0)
                    {
                        exceed = Math.Abs(Convert.ToDouble(deviation));
                        sl.SetCellValue(nRow, 11, exceed);
                        sl.SetCellStyle(nRow, 11, styleFloatDev);
                    }
                    else
                    {
                        if (charInfos[charNo].isBasic)
                        {
                            string sRequirement = sl.GetCellValueAsString(nRow, 5);

                            if (sRequirement.StartsWith("("))
                            {
                                sl.SetCellValue(nRow, 11, "REFERENCE");
                            }
                            else
                            {
                                sl.SetCellValue(nRow, 11, "BASIC");
                            }
                        }
                        else
                        {
                            sl.SetCellValue(nRow, 11, "PASS");
                        }

                        sl.SetCellStyle(nRow, 11, styleFloatPass);
                    }
                }
            }

            if (statsIncluded)
            {
                SLPageSettings ps = sl.GetPageSettings("CMMStats");

                bRC = sl.SelectWorksheet("CMMStats");
                if (bRC)
                {
                    sl.SetCellValue(nInfoRow, 2, partNo);
                    sl.SetCellValue(nInfoRow, 6, partName);
                    //sl.SetCellValue(nInfoRow, 12, serialNo);
                    sl.SetCellValue(nInfoRow, 13, reportNo);

                    int nRow = nFirstRow;

                    foreach (DataGridViewRow row in statsGrid.gridControl.Rows)
                    {
                        if (row.IsNewRow)
                        {
                            continue;
                        }

                        //CharNo, Nominal, Mean, Variance, StdDev
                        string charNo   = row.Cells["CharNo"].Value.ToString();
                        string nominal  = row.Cells["Nominal"].Value.ToString();
                        string mean     = row.Cells["Mean"].Value.ToString();
                        string variance = row.Cells["Variance"].Value.ToString();
                        string stdDev   = row.Cells["StdDev"].Value.ToString();
                        string desc     = charInfos[charNo].desc;

                        if (nRow > (nFirstRow + 20))
                        {
                            sl.InsertRow(nRow, 1);
                            sl.MergeWorksheetCells(nRow, 3, nRow, 9);
                            sl.CopyRowStyle(nFirstRow, nRow);
                        }

                        sl.SetCellValue(nRow, 2, charNo);
                        sl.SetCellStyle(nRow, 2, sl.GetCellStyle(nFirstRow, 2));
                        sl.SetCellValue(nRow, 3, desc);
                        sl.SetCellStyle(nRow, 3, sl.GetCellStyle(nFirstRow, 3));
                        sl.SetCellStyle(nRow, 4, sl.GetCellStyle(nFirstRow, 4));
                        sl.SetCellStyle(nRow, 5, sl.GetCellStyle(nFirstRow, 5));
                        sl.SetCellStyle(nRow, 6, sl.GetCellStyle(nFirstRow, 6));
                        sl.SetCellStyle(nRow, 7, sl.GetCellStyle(nFirstRow, 7));
                        sl.SetCellStyle(nRow, 8, sl.GetCellStyle(nFirstRow, 8));
                        sl.SetCellStyle(nRow, 9, sl.GetCellStyle(nFirstRow, 9));
                        sl.SetCellValue(nRow, 10, nominal);
                        sl.SetCellStyle(nRow, 10, sl.GetCellStyle(nFirstRow, 10));
                        sl.SetCellValue(nRow, 11, mean);
                        sl.SetCellStyle(nRow, 11, sl.GetCellStyle(nFirstRow, 11));
                        sl.SetCellValue(nRow, 12, variance);
                        sl.SetCellStyle(nRow, 12, sl.GetCellStyle(nFirstRow, 12));
                        sl.SetCellValue(nRow, 13, stdDev);
                        sl.SetCellStyle(nRow, 13, sl.GetCellStyle(nFirstRow, 13));

                        nRow++;
                    }

                    sl.SetPageSettings(ps);
                }
            }
            else
            {
                sl.SelectWorksheet("Form1");
                sl.DeleteWorksheet("CMMStats");
            }


            sl.SelectWorksheet("Form1");
            sl.DeleteWorksheet("Form3");

            string xlsFilename = Path.Combine(Properties.Settings.Default.LastReportPath, targetInput.Text);

            sl.SaveAs(xlsFilename);

            MessageBox.Show(String.Format("Result data merge complete: \n\r{0}", xlsFilename), "FAI Report");
        }
        // TODO: Hyperlink cell range

        /// <summary>
        /// Insert a hyperlink.
        /// </summary>
        /// <param name="RowIndex">The row index.</param>
        /// <param name="ColumnIndex">The column index.</param>
        /// <param name="HyperlinkType">The type of hyperlink.</param>
        /// <param name="Address">The URL for web pages, the file path for existing files, a cell reference (such as Sheet1!A1 or Sheet1!A1:B5), a defined name or an email address. NOTE: Do NOT include the "mailto:" portion for email addresses.</param>
        /// <param name="Display">The display text. Set null or an empty string to use the default.</param>
        /// <param name="ToolTip">The tooltip (or screentip) text. Set null or an empty string to ignore this.</param>
        /// <param name="OverwriteExistingCell">True to overwrite the existing cell value with the hyperlink display text. False otherwise.</param>
        /// <returns>True if successful. False otherwise.</returns>
        public bool InsertHyperlink(int RowIndex, int ColumnIndex, SLHyperlinkTypeValues HyperlinkType, string Address, string Display, string ToolTip, bool OverwriteExistingCell)
        {
            if (RowIndex < 1 || RowIndex > SLConstants.RowLimit)
            {
                return(false);
            }
            if (ColumnIndex < 1 || ColumnIndex > SLConstants.ColumnLimit)
            {
                return(false);
            }

            SLHyperlink hl = new SLHyperlink();

            hl.IsNew = true;

            hl.Reference = new SLCellPointRange(RowIndex, ColumnIndex, RowIndex, ColumnIndex);

            switch (HyperlinkType)
            {
            case SLHyperlinkTypeValues.EmailAddress:
                hl.IsExternal       = true;
                hl.HyperlinkUri     = string.Format("mailto:{0}", Address);
                hl.HyperlinkUriKind = UriKind.Absolute;
                break;

            case SLHyperlinkTypeValues.FilePath:
                hl.IsExternal   = true;
                hl.HyperlinkUri = Address;
                // assume if it starts with ../ or ./ it's a relative path.
                hl.HyperlinkUriKind = Address.StartsWith(".") ? UriKind.Relative : UriKind.Absolute;
                break;

            case SLHyperlinkTypeValues.InternalDocumentLink:
                hl.IsExternal = false;
                hl.Location   = Address;
                break;

            case SLHyperlinkTypeValues.Url:
                hl.IsExternal       = true;
                hl.HyperlinkUri     = Address;
                hl.HyperlinkUriKind = UriKind.Absolute;
                break;
            }

            if (Display == null)
            {
                hl.Display = Address;
            }
            else
            {
                if (Display.Length == 0)
                {
                    hl.Display = Address;
                }
                else
                {
                    hl.Display = Display;
                }
            }

            if (ToolTip != null && ToolTip.Length > 0)
            {
                hl.ToolTip = ToolTip;
            }

            SLCell  c;
            SLStyle style;

            if (slws.CellWarehouse.Exists(RowIndex, ColumnIndex))
            {
                c     = slws.CellWarehouse.Cells[RowIndex][ColumnIndex];
                style = new SLStyle();
                if (c.StyleIndex < listStyle.Count)
                {
                    style.FromHash(listStyle[(int)c.StyleIndex]);
                }
                else
                {
                    style.FromHash(listStyle[0]);
                }
                style.SetFontUnderline(UnderlineValues.Single);
                style.SetFontColor(SLThemeColorIndexValues.Hyperlink);
                c.StyleIndex = (uint)this.SaveToStylesheet(style.ToHash());

                if (OverwriteExistingCell)
                {
                    // in case there's a formula
                    c.CellFormula = null;
                    c.DataType    = CellValues.SharedString;
                    c.CellText    = this.DirectSaveToSharedStringTable(hl.Display).ToString(CultureInfo.InvariantCulture);
                }
                // else don't have to do anything

                slws.CellWarehouse.SetValue(RowIndex, ColumnIndex, c);
            }
            else
            {
                c = new SLCell();

                style = new SLStyle();
                style.FromHash(listStyle[0]);
                style.SetFontUnderline(UnderlineValues.Single);
                style.SetFontColor(SLThemeColorIndexValues.Hyperlink);
                c.StyleIndex = (uint)this.SaveToStylesheet(style.ToHash());

                c.DataType = CellValues.SharedString;
                c.CellText = this.DirectSaveToSharedStringTable(hl.Display).ToString(CultureInfo.InvariantCulture);
                slws.CellWarehouse.SetValue(RowIndex, ColumnIndex, c);
            }

            slws.Hyperlinks.Add(hl);

            return(true);
        }
        /// -----------------------------------------------------------------------------------------------
        /// <summary>
        ///     This setting creator has user-defined styles and columns for the four data-tables in
        ///     mock data; Directors, Managers, Team Leads & Associates.
        ///     Displays a variety of ways to access the Export library with Constructor and
        ///     Property Dependency Injection.
        /// </summary>
        /// <returns>Settings: Custom Styling</returns>
        /// -----------------------------------------------------------------------------------------------
        public static Settings SetupCustomStyles()
        {
            try
            {
                var childList = new List <ChildSetting>();

                /* -------------------------------------------------------------
                 * Setup the column header base style for the child datasets
                 * -----------------------------------------------------------*/
                var baseColumnHeaderStyle = new SLStyle();
                baseColumnHeaderStyle.SetHorizontalAlignment(HorizontalAlignmentValues.Center);
                baseColumnHeaderStyle.SetVerticalAlignment(VerticalAlignmentValues.Center);
                baseColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.DimGray, Color.White);
                baseColumnHeaderStyle.SetBottomBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.SetTopBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.SetVerticalBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.Border.SetRightBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.Border.SetLeftBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.SetFont("Britannic Bold", 12);
                baseColumnHeaderStyle.SetFontColor(Color.White);
                baseColumnHeaderStyle.SetFontBold(true);

                /* -------------------------------------------------------------
                 * Setup the odd row style for the child datasets
                 * -----------------------------------------------------------*/
                var oddRowStyle = new SLStyle();
                oddRowStyle.SetHorizontalAlignment(HorizontalAlignmentValues.Left);
                oddRowStyle.SetVerticalAlignment(VerticalAlignmentValues.Center);
                oddRowStyle.Fill.SetPattern(PatternValues.Solid, Color.White, Color.Black);
                oddRowStyle.SetFont("Helvetica", 10);
                oddRowStyle.SetFontColor(Color.Black);

                /* -------------------------------------------------------------
                 * Setup the even row style derived from the odd,
                 * change only what is necessary.
                 * -----------------------------------------------------------*/
                var evenRowStyle = oddRowStyle.Clone();
                evenRowStyle.Fill.SetPattern(PatternValues.Solid, Color.WhiteSmoke, Color.Black);

                /*  ------------------------------------------------------------
                 *  Create the user-defined columns with property dependency
                 *  injection for the base dataset.
                 *  With this method hover the cursor over the property and
                 *  intellisense will show the comments for it.
                 *  ----------------------------------------------------------*/
                var columns = new List <Column>
                {
                    // Since this id column is not set to visible, you can just leave it out and it will be ignored
                    new Column
                    {
                        BoundColumnName       = "DID",
                        UserDefinedColumnName = "ID",
                        NumberFormat          = NumberFormats.General,
                        HorizontalAlignment   = HorizontalAlignmentValues.Center,
                        ShowField             = false,
                        FieldOrder            = 0
                    },
                    new Column
                    {
                        BoundColumnName       = "SheetName",
                        UserDefinedColumnName = "Director",
                        NumberFormat          = NumberFormats.General,
                        HorizontalAlignment   = HorizontalAlignmentValues.Left,
                        ShowField             = true,
                        FieldOrder            = 1
                    },
                    new Column
                    {
                        BoundColumnName       = "Age",
                        UserDefinedColumnName = "Chronology",
                        NumberFormat          = NumberFormats.Decimal0,
                        HorizontalAlignment   = HorizontalAlignmentValues.Center,
                        ShowField             = true,
                        FieldOrder            = 2
                    },
                    new Column
                    {
                        BoundColumnName       = "Income",
                        UserDefinedColumnName = "Compensation",
                        NumberFormat          = NumberFormats.Accounting2Red,
                        HorizontalAlignment   = HorizontalAlignmentValues.Right,
                        ShowField             = true,
                        FieldOrder            = 3
                    },
                    new Column
                    {
                        BoundColumnName       = "Member",
                        UserDefinedColumnName = "Member ?",
                        NumberFormat          = NumberFormats.General,
                        HorizontalAlignment   = HorizontalAlignmentValues.Center,
                        ShowField             = true,
                        FieldOrder            = 4
                    },
                    new Column
                    {
                        BoundColumnName       = "Registered",
                        UserDefinedColumnName = "Date Registered",
                        NumberFormat          = NumberFormats.DateShort5,
                        HorizontalAlignment   = HorizontalAlignmentValues.Center,
                        ShowField             = true,
                        FieldOrder            = 5
                    }
                };

                /* -------------------------------------------------------------
                 * Define and style base child settings.
                 * This Child will always be present, it represents the
                 * primary dataset for every export and is not really a child.
                 * Using Property Injection Technique
                 * -----------------------------------------------------------*/
                childList.Add(new ChildSetting
                {
                    // Optional name
                    SheetName = "Directors",
                    // Set column visibility
                    ShowColumnHeader = true,
                    // Make the base column header row a little larger
                    // so it will stand out.  Value is in pixels
                    ColumnHeaderRowHeight = 25,
                    // Setup the style for Column Headers
                    ColumnHeaderStyle = baseColumnHeaderStyle,
                    // Row and Alternating Row Styles
                    // If set to false then the odd row style will be overall row style
                    ShowAlternatingRows = false,
                    // Setup the style for all rows
                    OddRowStyle  = oddRowStyle,
                    EvenRowStyle = null,
                    // Add the user-defined columns
                    UserDefinedColumns = columns
                });

                /*  ------------------------------------------------------------
                 *  The first child column headers stylings will be derived
                 *  from the base, change only what needs to be changed.
                 *  ----------------------------------------------------------*/
                var firstColumnHeaderStyle = baseColumnHeaderStyle.Clone();
                firstColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.DarkGray, Color.Black);
                firstColumnHeaderStyle.SetBottomBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.SetTopBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.SetVerticalBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.Border.SetRightBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.Border.SetLeftBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.SetFont("Helvetica", 10);
                firstColumnHeaderStyle.SetFontColor(Color.Black);

                /*  ------------------------------------------------------------
                 *  Create the user-defined columns with constructor dependency
                 *  injection for the base dataset.
                 *  Hover the cursor over the property and intellisense will
                 *  show the comments for it.
                 *  ----------------------------------------------------------*/
                columns = new List <Column>
                {
                    new Column
                    (
                        "SheetName",
                        "Managers",
                        NumberFormats.General,
                        HorizontalAlignmentValues.Left,
                        true,
                        1
                    ),
                    new Column
                    (
                        "Age",
                        "Age",
                        NumberFormats.Decimal0,
                        HorizontalAlignmentValues.Center,
                        true,
                        2
                    ),
                    new Column
                    (
                        "Income",
                        "Compensation",
                        NumberFormats.Currency0Black,
                        HorizontalAlignmentValues.Right,
                        true,
                        3
                    ),
                    new Column
                    (
                        "Registered",
                        "Date Registered",
                        NumberFormats.DateShort1,
                        HorizontalAlignmentValues.Center,
                        true,
                        5
                    )
                };

                /* -------------------------------------------------------------
                 * Define and add the first child
                 * Using Constructor dependency injection
                 * -----------------------------------------------------------*/
                childList.Add(new ChildSetting
                              (
                                  "Managers",             // SheetName
                                  true,                   // Show Column Headers
                                  1,                      // Column Offset to the Right
                                  null,                   // Column Header Row Height
                                  firstColumnHeaderStyle, // Column Header Style
                                  false,                  // Show Alternating Rows, false will default to Odd
                                  oddRowStyle,            // Odd Row Style
                                  null,                   // Even Row Style
                                  columns                 // User-Defined Column (UDCs)
                              ));

                /* -------------------------------------------------------------
                 * The second child column headers stylings will be derived
                 * from the first, change only what needs to be changed.
                 * -----------------------------------------------------------*/
                var secondColumnHeaderStyle = firstColumnHeaderStyle.Clone();
                secondColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.CadetBlue, Color.White);
                secondColumnHeaderStyle.SetFontColor(Color.White);

                /* -------------------------------------------------------------
                 * Define and add the second child
                 * Using Constructor dependency injection
                 * -----------------------------------------------------------*/
                childList.Add(new ChildSetting(
                                  "Team Leads",            // SheetName
                                  true,                    // Show Column Headers
                                  2,                       // Column Offset to the Right
                                  null,                    // Column Header Row Height
                                  secondColumnHeaderStyle, // Column Header Style
                                  false,                   // Show Alternating Rows, false will default to Odd
                                  oddRowStyle,             // Odd Row Style
                                  null,                    // Even Row Style
                                  new List <Column>        // User-Defined Column (UDCs)
                {
                    new Column("TLID", "Team Lead ID", NumberFormats.General, HorizontalAlignmentValues.Left, true,
                               6),
                    new Column("Registered", "Registration Date", NumberFormats.UserDefined,
                               HorizontalAlignmentValues.Center, true, 2, "d-mmm-yy"),
                    new Column("SheetName", "Team Leads", NumberFormats.General, HorizontalAlignmentValues.Left,
                               true, 0),
                    new Column("Age", "How Old?", NumberFormats.General, HorizontalAlignmentValues.Center, true, 1),
                    new Column("Member", "Member?", NumberFormats.General, HorizontalAlignmentValues.Center, true, 3),
                    new Column("Income", "Income", NumberFormats.Accounting2Red, HorizontalAlignmentValues.Right,
                               true, 4),
                    new Column("MID", "Foreign Key", NumberFormats.General, HorizontalAlignmentValues.Right, false)
                }
                                  ));

                /* -------------------------------------------------------------
                 * The third child column headers stylings will be derived
                 * from the first, change only what needs to be changed.
                 * -----------------------------------------------------------*/
                var thirdColumnHeaderStyle = firstColumnHeaderStyle.Clone();
                thirdColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.Aqua, Color.Black);
                thirdColumnHeaderStyle.SetFont("Blackadder ITC", 11);
                thirdColumnHeaderStyle.SetFontColor(Color.Black);

                /* -------------------------------------------------------------
                 * Define and add the third child
                 * Constructor Injection on all
                 * -----------------------------------------------------------*/
                childList.Add(new ChildSetting("Associates", true, 3, 30, thirdColumnHeaderStyle, true, oddRowStyle,
                                               evenRowStyle,
                                               new List <Column>
                {
                    new Column("Registered", "Date", NumberFormats.TimeStamp124, HorizontalAlignmentValues.Left,
                               true, 3),
                    new Column("Member", "Member?", NumberFormats.General, HorizontalAlignmentValues.Center, true, 2),
                    new Column("SheetName", "Associate", NumberFormats.General, HorizontalAlignmentValues.Left, true,
                               0)
                }
                                               ));

                /* -------------------------------------------------------------
                 * Setup and return the primary container for the child datasets
                 * Using Constructor Injection as well
                 * -----------------------------------------------------------*/
                return(new Settings("Organization", childList));
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception Fail: " + ex.Message);
            }
            return(null);
        }
Пример #5
0
        /// -----------------------------------------------------------------------------------------------
        /// <summary>
        ///     Sets up the default styling when user does not predefine styles with a Settings configuration
        /// </summary>
        /// <returns>Settings: Default Styling</returns>
        /// -----------------------------------------------------------------------------------------------
        public static Settings SetupDefaultStyles()
        {
            try
            {
                /* -------------------------------------------------------------
                 * Setup primary container for the child datasets
                 * -----------------------------------------------------------*/
                var settings = new Settings
                {
                    // Optional name
                    Name = "Default Settings Container"
                };

                /* -------------------------------------------------------------
                 * Setup the column header base style for the child datasets
                 * -----------------------------------------------------------*/
                var baseColumnHeaderStyle = new SLStyle();
                baseColumnHeaderStyle.SetHorizontalAlignment(HorizontalAlignmentValues.Center);
                baseColumnHeaderStyle.SetVerticalAlignment(VerticalAlignmentValues.Center);
                baseColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.DimGray, Color.White);
                baseColumnHeaderStyle.SetBottomBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.SetTopBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.SetVerticalBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.Border.SetRightBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.Border.SetLeftBorder(BorderStyleValues.Medium, Color.Black);
                baseColumnHeaderStyle.SetFont("Helvetica", 11);
                baseColumnHeaderStyle.SetFontColor(Color.White);
                baseColumnHeaderStyle.SetFontBold(true);

                /* -------------------------------------------------------------
                 * Setup the odd row style for the child datasets
                 * -----------------------------------------------------------*/
                var oddRowStyle = new SLStyle();
                oddRowStyle.SetHorizontalAlignment(HorizontalAlignmentValues.Left);
                oddRowStyle.SetVerticalAlignment(VerticalAlignmentValues.Center);
                oddRowStyle.Fill.SetPattern(PatternValues.Solid, Color.White, Color.Black);
                oddRowStyle.SetFont("Helvetica", 10);
                oddRowStyle.SetFontColor(Color.Black);

                /* -------------------------------------------------------------
                 * Setup the even row style derived from the odd,
                 * change only what is necessary.
                 * -----------------------------------------------------------*/
                var evenRowStyle = oddRowStyle.Clone();
                evenRowStyle.Fill.SetPattern(PatternValues.Solid, Color.WhiteSmoke, Color.Black);

                /* -------------------------------------------------------------
                 * Define and style base child settings.
                 * This Child will always be present, it represents the
                 * primary dataset for every export.
                 * -----------------------------------------------------------*/
                settings.ChildSettings.Add(new ChildSetting
                                           (
                                               // SheetName (Optional)
                                               "Default Base Child Settings",
                                               // Set Overall Column Visibility
                                               true,
                                               // Column offset to the right
                                               0,
                                               // Make the base column header row a little larger
                                               // so it will stand out.  Value is in pixels
                                               25,
                                               // Setup the style for Column Headers
                                               baseColumnHeaderStyle,
                                               // Row and Alternating Row Styles
                                               // If set to false then the odd row style will be overall row style
                                               true,
                                               // Setup the style for odd & even rows
                                               oddRowStyle,
                                               evenRowStyle,
                                               // No User-Defined column headers
                                               null
                                           ));

                /*  ------------------------------------------------------------
                 *  The first child column headers stylings will be derived
                 *  from the base, change only what needs to be changed.
                 *  ----------------------------------------------------------*/
                var firstColumnHeaderStyle = baseColumnHeaderStyle.Clone();
                firstColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.DarkGray, Color.Black);
                firstColumnHeaderStyle.SetBottomBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.SetTopBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.SetVerticalBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.Border.SetRightBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.Border.SetLeftBorder(BorderStyleValues.Thin, Color.DarkSlateGray);
                firstColumnHeaderStyle.SetFont("Helvetica", 10);
                firstColumnHeaderStyle.SetFontColor(Color.Black);

                /* -------------------------------------------------------------
                 * Define and add the stylings for the first child, which is
                 * a child of the base data-set
                 * -----------------------------------------------------------*/
                settings.ChildSettings.Add(new ChildSetting
                                           (
                                               "Default First Child Settings",
                                               true,
                                               null,
                                               null,
                                               firstColumnHeaderStyle,
                                               true,
                                               oddRowStyle,
                                               evenRowStyle,
                                               null
                                           ));

                /* -------------------------------------------------------------
                 * The second child column headers stylings will be derived
                 * from the first, change only what needs to be changed.
                 * -----------------------------------------------------------*/
                var secondColumnHeaderStyle = firstColumnHeaderStyle.Clone();
                secondColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.CadetBlue, Color.White);
                secondColumnHeaderStyle.SetFontColor(Color.White);

                /* -------------------------------------------------------------
                 * Define and add the stylings for the second child, which is
                 * a child of the first data-set
                 * -----------------------------------------------------------*/
                settings.ChildSettings.Add(new ChildSetting
                                           (
                                               "Default Second Child Settings",
                                               true,
                                               null,
                                               null,
                                               secondColumnHeaderStyle,
                                               true,
                                               oddRowStyle,
                                               evenRowStyle,
                                               null
                                           ));

                /* -------------------------------------------------------------
                 * The third child column headers stylings will be derived
                 * from the first, change only what needs to be changed.
                 * -----------------------------------------------------------*/
                var thirdColumnHeaderStyle = firstColumnHeaderStyle.Clone();
                thirdColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.Aqua, Color.Black);
                thirdColumnHeaderStyle.SetFontColor(Color.Black);

                /* -------------------------------------------------------------
                 * Define and add the stylings for the third child, which is
                 * a child of the second data-set
                 * -----------------------------------------------------------*/
                settings.ChildSettings.Add(new ChildSetting
                                           (
                                               "Default Third Child Settings",
                                               true,
                                               null,
                                               null,
                                               thirdColumnHeaderStyle,
                                               true,
                                               oddRowStyle,
                                               evenRowStyle,
                                               null
                                           ));

                /* -------------------------------------------------------------
                 * The forth child column headers stylings will be derived
                 * from the first, change only what needs to be changed.
                 * -----------------------------------------------------------*/
                var fourthColumnHeaderStyle = firstColumnHeaderStyle.Clone();
                fourthColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.Chartreuse, Color.Black);
                fourthColumnHeaderStyle.SetFontColor(Color.Black);

                /* -------------------------------------------------------------
                 * Define and add the stylings for the fourth child, which is
                 * a child of the third data-set
                 * -----------------------------------------------------------*/
                settings.ChildSettings.Add(new ChildSetting
                                           (
                                               "Default Fourth Child Settings",
                                               true,
                                               null,
                                               null,
                                               fourthColumnHeaderStyle,
                                               true,
                                               oddRowStyle,
                                               evenRowStyle,
                                               null
                                           ));

                /* -------------------------------------------------------------
                 * If five deep isn't enough let's add a sixth one.
                 * The fifth child column headers stylings will be derived
                 * from the first, change only what needs to be changed.
                 * -----------------------------------------------------------*/
                var fifthColumnHeaderStyle = firstColumnHeaderStyle.Clone();
                fifthColumnHeaderStyle.Fill.SetPattern(PatternValues.Solid, Color.BlueViolet, Color.Black);
                fifthColumnHeaderStyle.SetFontColor(Color.White);

                /* -------------------------------------------------------------
                 * Define and add the stylings for the fifth child, which is
                 * a child of the fourth data-set
                 * -----------------------------------------------------------*/
                settings.ChildSettings.Add(new ChildSetting
                                           (
                                               "Default Fifth Child Settings",
                                               true,
                                               null,
                                               null,
                                               fifthColumnHeaderStyle,
                                               true,
                                               oddRowStyle,
                                               evenRowStyle,
                                               null
                                           ));


                return(settings);
            }
            catch (Exception ex)
            {
                Log.Error("SpreadsheetLightWrapper.Export.DefaultStyles.SetupDefaultStyles -> " + ex.Message + ": " + ex);
            }
            return(null);
        }
Пример #6
0
        private void GeraArquivoGeral(DataSet ds, string mes, string ano)
        {
            string dtInicio = Convert.ToDateTime(txtDtInicioRelEstouro.Text).ToString("dd-MM-yyyy");
            string dtFinal  = Convert.ToDateTime(txtDtFinalRelEstouro.Text).ToString("dd-MM-yyyy");

            int qtdestouro = 0, resperiodo = 0, linha = 6;

            int previsao = objBLL.GeraTotalEstouros(Convert.ToDateTime(dtInicio), Convert.ToDateTime(dtFinal));

            SLDocument sl = new SLDocument();

            //Set das configurações do arquivos e variaveis de style
            SLPageSettings ps = new SLPageSettings();

            ps.Orientation = OrientationValues.Landscape;
            ps.PaperSize   = SLPaperSizeValues.A4Paper;


            sl.SetPageSettings(ps);

            SLStyle bordaAcima = sl.CreateStyle();

            bordaAcima.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle resultBold = sl.CreateStyle();

            resultBold.SetFontBold(true);
            resultBold.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultBold.SetRightBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultBold.SetBottomBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultBold.SetLeftBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle resultRed = sl.CreateStyle();

            resultRed.SetFontBold(true);
            resultRed.SetFontColor(System.Drawing.Color.Red);
            resultRed.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultRed.SetRightBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultRed.SetBottomBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            resultRed.SetLeftBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle bordaContorno = sl.CreateStyle();

            bordaContorno.SetTopBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            bordaContorno.SetRightBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            bordaContorno.SetBottomBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);
            bordaContorno.SetLeftBorder(BorderStyleValues.Thin, System.Drawing.Color.Black);

            SLStyle alinhadoCentro = sl.CreateStyle();

            alinhadoCentro.Alignment.Horizontal = HorizontalAlignmentValues.Center;
            alinhadoCentro.Alignment.Vertical   = VerticalAlignmentValues.Center;
            alinhadoCentro.SetWrapText(true);


            //Loops de preenchimento do arquivo
            foreach (DataRow LAreaRel in ds.Tables["AREAS_REL"].Rows)
            {
                foreach (DataRow LQtdEstouro in ds.Tables["QTD_ESTOURO"].Rows)
                {
                    if (LAreaRel[0].ToString() == LQtdEstouro[0].ToString())
                    {
                        qtdestouro = Convert.ToInt32(LQtdEstouro[1]);
                        break;
                    }
                    qtdestouro = 0;
                }

                foreach (DataRow LRespPeriodo in ds.Tables["RESP_PERIODO"].Rows)
                {
                    if (LAreaRel[0].ToString() == LRespPeriodo[0].ToString())
                    {
                        resperiodo = Convert.ToInt32(LRespPeriodo[1]);
                        break;
                    }
                    resperiodo = 0;
                }


                sl.SetCellValue(linha, 1, LAreaRel[0].ToString());
                sl.SetCellValue(linha, 2, qtdestouro);
                sl.SetCellValue(linha, 3, resperiodo);

                sl.SetCellStyle(linha, 1, bordaContorno);
                sl.SetCellStyle(linha, 2, bordaContorno);
                sl.SetCellStyle(linha, 3, bordaContorno);
                sl.SetCellStyle(linha, 4, bordaContorno);

                if (qtdestouro != 0 && resperiodo != 0)
                {
                    sl.SetCellValue(linha, 4, "=ROUND(((B" + linha + "/C" + linha + ")*100),2)");
                }
                else
                {
                    sl.SetCellValue(linha, 4, 0);
                }

                linha++;
            }

            //Atribuindo valores fixos e stylo das celulas
            int auxlinha = linha - 1;

            sl.SetCellValue(1, 1, "Manifestações com previsão de encerramento entre " + dtInicio + " e " + dtFinal);
            sl.SetCellValue(1, 2, previsao.ToString());
            sl.SetCellStyle(1, 1, alinhadoCentro);
            sl.SetCellStyle(1, 2, alinhadoCentro);
            sl.SetCellValue(2, 1, "Respostas das Áreas Gerenciadoras:");
            sl.SetCellValue(2, 2, "=C" + linha + @"&"" ou ""&ROUND(B1/C" + linha + @",4)*100&""%""");
            sl.SetCellValue(3, 1, "Manifestações encerradas após a previsão:");
            sl.SetCellValue(3, 2, "=B" + linha + @"&"" ou ""&ROUND(B" + linha + @"/B1,4)*100&""%""");


            sl.SetCellValue(5, 1, "Áreas Gerenciadoras");
            sl.SetCellValue(5, 2, "Quantidade de estouros dos prazos");
            sl.SetCellValue(5, 3, "Respostas no período");
            sl.SetCellValue(5, 4, "%");
            sl.SetCellStyle(5, 1, resultBold);
            sl.SetCellStyle(5, 2, resultBold);
            sl.SetCellStyle(5, 3, resultBold);
            sl.SetCellStyle(5, 4, resultBold);


            sl.SetCellValue(linha, 1, "Total");
            sl.SetCellValue(linha, 2, "=SUM(B6:B" + auxlinha + ")");
            sl.SetCellValue(linha, 3, "=SUM(C6:C" + auxlinha + ")");

            sl.SetCellStyle(linha, 1, resultBold);
            sl.SetCellStyle(linha, 2, resultRed);
            sl.SetCellStyle(linha, 3, resultRed);

            sl.SetRowHeight(5, 38);
            sl.SetColumnWidth(1, 39);
            sl.SetRowHeight(1, 40);
            sl.AutoFitColumn(2);
            sl.AutoFitColumn(3);
            sl.SetColumnWidth(4, 7);

            sl.SetColumnStyle(1, alinhadoCentro);
            sl.SetColumnStyle(2, alinhadoCentro);
            sl.SetColumnStyle(3, alinhadoCentro);
            sl.SetColumnStyle(4, alinhadoCentro);

            string caminho = Server.MapPath(@"UploadFile\\" + "Relatorio_Estouro "
                                            + mes +
                                            " " + ano + ".xlsx");

            sl.SaveAs(caminho);
        }
Пример #7
0
        private void mergeButton_Click(object sender, EventArgs e)
        {
            bool bRC;
            //int itemCnt = 0;

            string fullTemplateName = Path.Combine(Properties.Settings.Default.LastTemplatePath, sourceTemplateInput.Text);

            bRC = sl.SelectWorksheet("Form1");
            string partNo   = sl.GetCellValueAsString(4, 2);
            string partName = sl.GetCellValueAsString(4, 4);
            string reportNo = sl.GetCellValueAsString(4, 8);
            string serialNo = String.Empty;

            //SLDocument sl = new SLDocument(fullTemplateName, "Form1");

            SLStyle styleFloat = sl.CreateStyle();

            styleFloat.FormatCode = formatCode.Text;
            styleFloat.SetFontColor(System.Drawing.Color.Black);
            styleFloat.Font.FontName = fontName.Text;
            styleFloat.Font.FontSize = Convert.ToInt16(fontSize.Text);

            SLStyle styleString = sl.CreateStyle();

            styleString.SetFontColor(System.Drawing.Color.Black);
            styleString.Font.FontName = fontName.Text;
            styleString.Font.FontSize = Convert.ToInt16(fontSize.Text);

            foreach (resultGrid grid in grids.Values)
            {
                int          nRow;
                TabPage      tabPage = grid.tabPage;
                DataGridView gridCtl = grid.gridControl;
                string       runNo   = grid.runNo;
                string       title   = tabPage.Text;

                bRC = sl.SelectWorksheet("Form1");
                bRC = sl.CopyWorksheet("Form3", title);
                bRC = sl.SelectWorksheet(title);

                // set this sheets serial number
                serialNo = String.Format("{0}-{1}", partNo, runNo);
                sl.SetCellValue(4, 12, serialNo);


                foreach (DataGridViewRow row in gridCtl.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }

                    string charNo    = row.Cells["CharNo"].Value.ToString();
                    string nominal   = row.Cells["Nominal"].Value.ToString();
                    string upper     = row.Cells["Upper"].Value.ToString();
                    string lower     = row.Cells["Lower"].Value.ToString();
                    string actual    = row.Cells["Actual"].Value.ToString();
                    string deviation = row.Cells["Deviation"].Value.ToString();

                    nRow = charInfos[charNo].charRow;

                    // Actual
                    double actualVal;
                    if (actual.Length > 0)
                    {
                        actualVal = Math.Abs(Convert.ToDouble(actual));
                        sl.SetCellValue(nRow, 9, actualVal);
                        sl.SetCellStyle(nRow, 9, styleFloat);
                    }

                    sl.SetCellValue(nRow, 9, actual);
                    sl.SetCellStyle(nRow, 9, styleFloat);

                    // Exceed
                    double exceed = 0;
                    if (deviation.Length > 0)
                    {
                        exceed = Math.Abs(Convert.ToDouble(deviation));
                        sl.SetCellValue(nRow, 11, exceed);
                        sl.SetCellStyle(nRow, 11, styleFloat);
                    }
                }
            }

            if (statsIncluded)
            {
                SLPageSettings ps = sl.GetPageSettings("CMMStats");

                bRC = sl.SelectWorksheet("CMMStats");
                if (bRC)
                {
                    sl.SetCellValue(4, 2, partNo);
                    sl.SetCellValue(4, 6, partName);
                    sl.SetCellValue(4, 12, serialNo);
                    sl.SetCellValue(4, 13, reportNo);

                    //styleFloat.Border.LeftBorder.BorderStyle = BorderStyleValues.Medium;
                    //styleFloat.Border.RightBorder.BorderStyle = BorderStyleValues.Medium;
                    //styleFloat.Border.BottomBorder.BorderStyle = BorderStyleValues.Medium;

                    int nRow = 8;

                    foreach (DataGridViewRow row in statsGrid.gridControl.Rows)
                    {
                        if (row.IsNewRow)
                        {
                            continue;
                        }

                        //CharNo, Nominal, Mean, Variance, StdDev
                        string charNo   = row.Cells["CharNo"].Value.ToString();
                        string nominal  = row.Cells["Nominal"].Value.ToString();
                        string mean     = row.Cells["Mean"].Value.ToString();
                        string variance = row.Cells["Variance"].Value.ToString();
                        string stdDev   = row.Cells["StdDev"].Value.ToString();
                        string desc     = charInfos[charNo].desc;

                        if (nRow > 28)
                        {
                            sl.InsertRow(nRow, 1);
                            sl.MergeWorksheetCells(nRow, 3, nRow, 9);
                            sl.CopyRowStyle(8, nRow);
                        }

                        sl.SetCellValue(nRow, 2, charNo);
                        sl.SetCellStyle(nRow, 2, sl.GetCellStyle("B8"));
                        sl.SetCellValue(nRow, 3, desc);
                        sl.SetCellStyle(nRow, 3, sl.GetCellStyle("C8"));
                        sl.SetCellStyle(nRow, 4, sl.GetCellStyle("D8"));
                        sl.SetCellStyle(nRow, 5, sl.GetCellStyle("E8"));
                        sl.SetCellStyle(nRow, 6, sl.GetCellStyle("F8"));
                        sl.SetCellStyle(nRow, 7, sl.GetCellStyle("G8"));
                        sl.SetCellStyle(nRow, 8, sl.GetCellStyle("H8"));
                        sl.SetCellStyle(nRow, 9, sl.GetCellStyle("I8"));
                        sl.SetCellValue(nRow, 10, nominal);
                        sl.SetCellStyle(nRow, 10, sl.GetCellStyle("J8"));
                        sl.SetCellValue(nRow, 11, mean);
                        sl.SetCellStyle(nRow, 11, sl.GetCellStyle("K8"));
                        sl.SetCellValue(nRow, 12, variance);
                        sl.SetCellStyle(nRow, 12, sl.GetCellStyle("L8"));
                        sl.SetCellValue(nRow, 13, stdDev);
                        sl.SetCellStyle(nRow, 13, sl.GetCellStyle("M8"));

                        nRow++;
                    }

                    sl.SetPageSettings(ps);
                }
            }
            else
            {
                sl.SelectWorksheet("Form1");
                sl.DeleteWorksheet("CMMStats");
            }


            sl.SelectWorksheet("Form1");
            sl.DeleteWorksheet("Form3");

            string xlsFilename = Path.Combine(Properties.Settings.Default.LastReportPath, targetInput.Text);

            sl.SaveAs(xlsFilename);

            MessageBox.Show(String.Format("Result data merge complete: \n\r{0}", xlsFilename), "FAI Report");
        }