Ejemplo n.º 1
0
        private void SetEstiloExcel()
        {
            //estilo de cabecera
            SLStyle rowHeaderStyle = new SLStyle();

            rowHeaderStyle.SetBottomBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thick, Color.Crimson);
            rowHeaderStyle.SetFont("Century Gothic", 12);
            slMusifan.SetRowStyle(1, rowHeaderStyle);

            //estilo de filas
            SLStyle allRowStyle = new SLStyle();

            allRowStyle.SetBottomBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Medium, Color.DarkGray);
            slMusifan.SetRowStyle(2, Comercio.MisProductos.Count, allRowStyle);

            //estilo de columnas
            SLStyle columnStyle = new SLStyle();

            columnStyle.SetLeftBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Medium, Color.Black);
            slMusifan.SetColumnStyle(1, 13, columnStyle);

            //expandir columnas automaticamente en base a las celdas
            slMusifan.AutoFitColumn(1, 13);

            //fijo la primer fila
            slMusifan.FreezePanes(1, 0);
        }
Ejemplo n.º 2
0
        /// <summary> создание документа excel </summary>
        public SLDocument CreateDocument()
        {
            Document = new SLDocument();

            CreateDefaultStyles();

            for (var i = 0; i < _dataLists.Count; i++)
            {
                var dataList    = _dataLists[i];
                var fieldsInfo  = _fieldsInfo[i];
                var fieldStyles = CreateFieldStyles(fieldsInfo);
                var criteria    = _criteria[i];
                var title       = _titles[i];

                var worksheetName = GetUniqWorksheetName(title);

                Document.AddWorksheet(worksheetName);

                Document.SelectWorksheet(worksheetName);

                LineNum = 1;

                CreateTitle(worksheetName, fieldsInfo.Count);

                CreateCriteriaList(criteria, fieldsInfo.Count);

                CreateCaption(fieldsInfo);

                Document.FreezePanes(LineNum - 1, 0);

                FilterStartLineNum = LineNum - 1;
                CreateDataList(dataList, fieldsInfo, fieldStyles);
                FilterEndLineNum = LineNum - 1;

                Document.Filter(FilterStartLineNum, 1, FilterEndLineNum, fieldsInfo.Count);

                var j = 1;
                foreach (string name in fieldsInfo.Keys)
                {
                    if (fieldsInfo[name].Width != 0)
                    {
                        Document.SetColumnWidth(j, fieldsInfo[name].Width);
                    }
                    else
                    {
                        Document.AutoFitColumn(j);
                    }

                    j++;
                }
                Document.AutoFitRow(1, LineNum);
            }
            return(Document);
        }
Ejemplo n.º 3
0
        private void CreateProtoRefSheet(List <KSolutionGroup> solutionGroupList)
        {
            _currentColumn = 1;
            _currentRow    = 1;

            _sl.AddWorksheet($"ProtoRef");
            _sl.FreezePanes(1, 0);

            _sl.SetColumnWidth(_currentColumn, 17);
            var colSolutionName = _currentColumn;

            _sl.SetCellValue(_currentRow, _currentColumn++, nameof(KSolution.SolutionName));

            _sl.SetColumnWidth(_currentColumn, 30);
            var colServiceName = _currentColumn;

            _sl.SetCellValue(_currentRow, _currentColumn++, nameof(CProtoService.ServiceName));

            _sl.SetColumnWidth(_currentColumn, 30);
            var colRpcName = _currentColumn;

            _sl.SetCellValue(_currentRow, _currentColumn++, nameof(CProtoRpc.RpcName));

            _sl.SetColumnWidth(_currentColumn, 17);
            var colDirection = _currentColumn;

            _sl.SetCellValue(_currentRow, _currentColumn++, nameof(CProtoRpcRef.Direction));
            _currentRow++;

            foreach (var solutionGroup in solutionGroupList)
            {
                foreach (var solution in solutionGroup.Solution)
                {
                    foreach (var project in solution.Project.Where(p => p is KGrpcProject).Select(p => p as KGrpcProject))
                    {
                        if (project.ProtoFile == null)
                        {
                            continue;
                        }
                        var rowStyle = _sl.CreateStyle();

                        rowStyle.Fill.SetPattern(PatternValues.Solid, GetRandomLightColor(), GetRandomLightColor());
                        if (project is KGrpcIntegrationProject)
                        {
                            var integrationProject = project as KGrpcIntegrationProject;
                            foreach (var protoRef in integrationProject.ProtoRef)
                            {
                                _sl.SetCellValue(_currentRow, colSolutionName, solution.SolutionName);
                                _sl.SetCellValue(_currentRow, colServiceName, protoRef.RefServiceName);

                                _sl.SetCellValue(_currentRow, colRpcName, protoRef.RefRpcName);

                                _sl.SetCellValue(_currentRow, colDirection, protoRef.Direction.ToString());


                                _sl.SetCellStyle(_currentRow, 1, _currentRow, _currentColumn, rowStyle);
                                _currentRow++;
                            }
                        }
                    }
                }
            }
        }