Example #1
0
        static void Main(string[] args)
        {
            Data data = new Data();

            SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
            Console.WriteLine("Welcome To the Reporter...\n\n");
            string[] yearMonths = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };

            getData(ref data, ref yearMonths);

            //= ======================================================================================================== =
            ExcelFile      report = new ExcelFile();
            ExcelWorksheet sheet  = report.Worksheets.Add("Yearly Report");

            zabatellogo(ref sheet, data.compName);
            zabatHeader(ref sheet, ref data, yearMonths);

            dataEntry(ref sheet, ref data, ref yearMonths);

            ExcelWorksheet chartsh = report.Worksheets.Add(SheetType.Chart, "Chart");
            ExcelChart     chart   = chartsh.Charts.Add(ChartType.Pie, 0, 0, 0, 0, LengthUnit.Centimeter);

            chart.DataLabels.LabelPosition = DataLabelPosition.InsideEnd;
            // chart data.
            // period +1 for header.
            chart.SelectData(sheet.Cells.GetSubrangeRelative(7, 1, 2, data._period + 1), true);

            report.Save(Globals.savePath + data.compName + ".xlsx");

            Console.Write("Succesfully Created... Do you want to make a pdf copy?");
            char pdf = char.Parse(Console.ReadLine());

            if (char.ToLower(pdf) == 'y')
            {
                sheet.PrintOptions.Portrait  = true;
                sheet.PrintOptions.PaperType = PaperType.A4;

                report.Save(Globals.savePath + data.compName + ".pdf", new PdfSaveOptions()
                {
                    SelectionType = SelectionType.EntireFile
                });
            }
            System.Diagnostics.Process.Start("explorer.exe", Globals.savePath);
        }
Example #2
0
    static void Example1()
    {
        var presentation = new PresentationDocument();

        // Add new PowerPoint presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Add simple PowerPoint presentation title.
        var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle,
                                               116.8, 20, 105, 10, GemBox.Presentation.LengthUnit.Millimeter);

        textBox.AddParagraph().AddRun("New presentation with chart element.");

        // Create PowerPoint chart and add it to slide.
        var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Bar,
                                           49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter);

        // Get underlying Excel chart.
        ExcelChart     excelChart = (ExcelChart)chart.ExcelChart;
        ExcelWorksheet worksheet  = excelChart.Worksheet;

        // Add data for Excel chart.
        worksheet.Cells["A1"].Value = "Name";
        worksheet.Cells["A2"].Value = "John Doe";
        worksheet.Cells["A3"].Value = "Fred Nurk";
        worksheet.Cells["A4"].Value = "Hans Meier";
        worksheet.Cells["A5"].Value = "Ivan Horvat";

        worksheet.Cells["B1"].Value = "Salary";
        worksheet.Cells["B2"].Value = 3600;
        worksheet.Cells["B3"].Value = 2580;
        worksheet.Cells["B4"].Value = 3200;
        worksheet.Cells["B5"].Value = 4100;

        // Select data.
        excelChart.SelectData(worksheet.Cells.GetSubrange("A1:B5"), true);

        presentation.Save("Created Chart.pdf");
    }
    static void Example1()
    {
        var document = new DocumentModel();

        // Create Word chart and add it to document.
        var chart = new Chart(document, GemBox.Document.ChartType.Bar,
                              new FloatingLayout(
                                  new HorizontalPosition(HorizontalPositionType.Center, HorizontalPositionAnchor.Margin),
                                  new VerticalPosition(VerticalPositionType.Top, VerticalPositionAnchor.Paragraph),
                                  new Size(14, 7, GemBox.Document.LengthUnit.Centimeter)));

        document.Sections.Add(
            new Section(document,
                        new Paragraph(document, "New document with chart element."),
                        new Paragraph(document, chart)));

        // Get underlying Excel chart.
        ExcelChart     excelChart = (ExcelChart)chart.ExcelChart;
        ExcelWorksheet worksheet  = excelChart.Worksheet;

        // Add data for Excel chart.
        worksheet.Cells["A1"].Value = "Name";
        worksheet.Cells["A2"].Value = "John Doe";
        worksheet.Cells["A3"].Value = "Fred Nurk";
        worksheet.Cells["A4"].Value = "Hans Meier";
        worksheet.Cells["A5"].Value = "Ivan Horvat";

        worksheet.Cells["B1"].Value = "Salary";
        worksheet.Cells["B2"].Value = 3600;
        worksheet.Cells["B3"].Value = 2580;
        worksheet.Cells["B4"].Value = 3200;
        worksheet.Cells["B5"].Value = 4100;

        // Select data.
        excelChart.SelectData(worksheet.Cells.GetSubrange("A1:B5"), true);

        document.Save("Created Chart.pdf");
    }