Ejemplo n.º 1
0
        private void MontarCabecalho(IXLWorksheet worksheet, ConselhoClasseAtaFinalCabecalhoDto dadosCabecalho, int totalColunas)
        {
            worksheet.AddPicture(ObterLogo())
            .MoveTo(worksheet.Cell(2, 2))
            .Scale(0.15);

            int indiceColunaTitulo = (int)(totalColunas * 0.8) + 1;

            worksheet.Row(2).Cell(indiceColunaTitulo).Value = "SGP - Sistema de Gestão Pedagógica";
            worksheet.Range(2, indiceColunaTitulo, 2, totalColunas).Merge().Style.Font.Bold = true;
            worksheet.Range(2, indiceColunaTitulo, 2, totalColunas).Style.Font.FontSize     = 10;
            worksheet.Range(2, indiceColunaTitulo, 2, totalColunas).Style.Font.FontName     = "Arial";

            worksheet.Row(3).Cell(indiceColunaTitulo).Value = "ATA DE RESULTADOS FINAIS";
            worksheet.Range(3, indiceColunaTitulo, 3, totalColunas).Merge().Style.Font.FontSize = 10;
            worksheet.Range(3, indiceColunaTitulo, 3, totalColunas).Style.Font.FontName         = "Arial";

            int indiceFinal = SetarItemCabecalho(worksheet, $"DRE: {dadosCabecalho.Dre}", 0.4, LINHA_CABECALHO_DRE, 1, totalColunas);

            indiceFinal = SetarItemCabecalho(worksheet, $"Unidade Escolar (UE): {dadosCabecalho.Ue}", 0.4, LINHA_CABECALHO_DRE, indiceFinal, totalColunas);
            SetarItemCabecalho(worksheet, $"Turma: {dadosCabecalho.Turma}", 0.2, LINHA_CABECALHO_DRE, indiceFinal, totalColunas);

            indiceFinal = SetarItemCabecalho(worksheet, $"Ciclo: {dadosCabecalho.Ciclo}", 0.4, LINHA_CABECALHO_CICLO, 1, totalColunas);
            indiceFinal = SetarItemCabecalho(worksheet, $"Ano Letivo: {dadosCabecalho.AnoLetivo}", 0.4, LINHA_CABECALHO_CICLO, indiceFinal, totalColunas);
            SetarItemCabecalho(worksheet, $"Data: {dadosCabecalho.Data}", 0.2, LINHA_CABECALHO_CICLO, indiceFinal, totalColunas);
        }
Ejemplo n.º 2
0
        public static void AddHeaderToWorkSheet(this IXLWorksheet worksheet, string title, string logo, int tableLength = 5)
        {
            worksheet.Row(1).InsertRowsAbove(5);

            var mergeRangeColumn = 'E';

            if (tableLength != 5)
            {
                mergeRangeColumn = NumberToLetter(tableLength);
            }

            if (!string.IsNullOrEmpty(logo))
            {
                using (var memoryStream = new MemoryStream(File.ReadAllBytes(logo)))
                {
                    worksheet.AddPicture(memoryStream).MoveTo(worksheet.Cell("A1")).WithSize(60, 60);
                }
            }

            worksheet.Cell(2, 1).Value = ConstantHelpers.PROJECT.ToUpper();
            worksheet.Cell(2, 1).Style.Font.FontSize        = 12;
            worksheet.Cell(2, 1).Style.Font.Bold            = true;
            worksheet.Cell(2, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            worksheet.Cell(2, 1).Style.Alignment.Vertical   = XLAlignmentVerticalValues.Center;
            worksheet.Range($"A2:{mergeRangeColumn}2").Merge();

            worksheet.Cell(3, 1).Value = title;
            worksheet.Cell(3, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            worksheet.Cell(3, 1).Style.Alignment.Vertical   = XLAlignmentVerticalValues.Center;
            worksheet.Range($"A3:{mergeRangeColumn}3").Merge();
        }
Ejemplo n.º 3
0
        private void importPicture(IXLWorksheet ws, string startRowName, int startIndex, string imagePath)
        {
            Bitmap bm    = new Bitmap(imagePath);
            var    image = ws.AddPicture(bm)
                           .MoveTo(ws.Cell(startRowName + startIndex.ToString()))

                           .Scale(0.1);
        }
Ejemplo n.º 4
0
        private static void createSummarySheet(XLWorkbook workbook, TECBid bid, TECEstimator estimate)
        {
            IXLWorksheet worksheet = workbook.Worksheets.Add("Summary");

            createProjectInfoSection(worksheet, bid, 1);
            createCostSummarySection(worksheet, estimate, 7);
            createLaborSummarySection(worksheet, estimate, 20, 1);
            createSalesSummarySection(worksheet, estimate, 20, 4);

            var image = worksheet.AddPicture(createPlotImage(estimate));

            image.MoveTo(worksheet.Cell(28, 1).Address);
            //image.Scale(.7);

            worksheet.Columns().AdjustToContents();
            worksheet.PageSetup.PageOrientation = XLPageOrientation.Portrait;
            worksheet.PageSetup.FitToPages(1, 1);
        }
Ejemplo n.º 5
0
        public static async Task AddImage(IXLWorksheet ws, string imageUrl, int row, int col)
        {
            if (imageUrl == null)
            {
                return;
            }
            try
            {
                using var strm = await GetImageStream(imageUrl);

                ws.AddPicture(strm)
                .MoveTo(ws.Cell(row, col))
                .WithSize(100, 100)
                ;
            }
            catch
            {
                Console.WriteLine($"Error finding image: {imageUrl}");
            }
        }