コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            XtraReport1 report = new XtraReport1();

            report.CreateDocument(false);

            int addedPagesCount         = 0;
            IDictionaryEnumerator items = report.Groups.GetEnumerator();

            while (items.MoveNext())
            {
                DictionaryEntry item = (DictionaryEntry)items.Current;
                int             i    = Convert.ToInt32(item.Value) + addedPagesCount;
                if (i % 2 == 0)
                {
                    XtraReport2 emptyPage = new XtraReport2();
                    emptyPage.CreateDocument(false);
                    addedPagesCount++;
                    report.Pages.Insert(i + 1, emptyPage.Pages[0]);
                }
            }


            ReportPrintTool tool = new ReportPrintTool(report);

            tool.ShowPreviewDialog();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Josh-Kao-1992/test
        private void button2_Click(object sender, EventArgs e)
        {
            XtraReport1 report  = new XtraReport1();
            XtraReport2 report2 = new XtraReport2();

            report.CreateDocument(false);
            report2.CreateDocument(false);
            report.ExportToXlsx("test1.xlsx", new DevExpress.XtraPrinting.XlsxExportOptions()
            {
                SheetName = "report1"
            });
            report2.ExportToXlsx("test2.xlsx", new DevExpress.XtraPrinting.XlsxExportOptions()
            {
                SheetName = "report2"
            });

            Workbook workbook = new DevExpress.Spreadsheet.Workbook();

            workbook.LoadDocument("test1.xlsx");

            Workbook workbook2 = new DevExpress.Spreadsheet.Workbook();

            workbook2.LoadDocument("test2.xlsx");

            workbook.Worksheets.Insert(1, "report2");
            workbook.Worksheets[1].CopyFrom(workbook2.Worksheets[0]);
            workbook.SaveDocument("test3.xlsx");
            Process.Start("test3.xlsx");
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Josh-Kao-1992/test
        private void button1_Click(object sender, EventArgs e)
        {
            XtraReport1 report  = new XtraReport1();
            XtraReport2 report2 = new XtraReport2();

            report.CreateDocument(false);
            report2.CreateDocument(false);
            report.Pages.AddRange(report2.Pages);
            ReportPrintTool tool = new ReportPrintTool(report);

            tool.ShowPreviewDialog();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: GaryGillGenome/miles
        private void GenerateReport(string folderName)
        {
            label3.Text = "";

            if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "")
            {
                label3.Text = "Require Source and Destination folder to process this request";
                return;
            }
            string reportPath = textBox2.Text.Trim(); //@"c:\\Temp\Test.pdf";
            string sourcePath = textBox1.Text.Trim(); //@"C:\repos\miles\SFX Trade Panel\Archive r3 - May 2018 (updated) -lite\Strat Trade Files-20180424-170500";


            // A path to export a report.
            execSummaryList = new List <Dictionary <string, string> >();


            DataTable dtExecSummary        = new DataTable(); // null;// ConvertJsonToDatatable(jsonObj);
            DataTable dtNetPnL             = new DataTable();
            DataTable dtNetPips            = new DataTable();
            int       euTransactionCounter = 0;
            int       gbTransactionCounter = 0;
            int       usTransactionCounter = 0;
            double    euNetPnlTotal        = 0;
            double    gbNetPnlTotal        = 0;
            double    usNetPnlTotal        = 0;

            double euNetPipsTotal = 0;
            double gbNetPipsTotal = 0;
            double usNetPipsTotal = 0;

            //double netPipsTotal = 0;
            //int transactionsTotal = 0;

            if (Directory.Exists(sourcePath + "/" + folderName))
            {
                string[] files = Directory.GetFiles(sourcePath + "/" + folderName);
                if (files == null || files.Length <= 0)
                {
                    label3.Text = "No files found in the source folder";
                    return;
                }
                foreach (var f in files)
                {
                    if (f.Contains("ExecSumReport_stratmator"))
                    {
                        var parsedTxt = File.ReadAllLines(f);
                        //string[] c = { "\n" };
                        Dictionary <string, string> d = new Dictionary <string, string>();
                        foreach (var s in parsedTxt)
                        {
                            var eachLine   = s;
                            var parsedCols = s.Split(',');
                            d.Add(parsedCols[0], parsedCols[1]);
                        }
                        Console.Write("File: ", d);
                        execSummaryList.Add(d);
                        //ToDataTable(execSummaryList);
                    }
                    else if (f.EndsWith("Trade.xlsx"))
                    {
                        //string[] c = { "\n" };
                        SaveAsCsv(f, f.Replace(".xlsx", ".csv"));
                        var parsedTxt = File.ReadAllLines(f.Replace(".xlsx", ".csv"));
                        Dictionary <string, string> d = new Dictionary <string, string>();
                        int lineCntr = 0;
                        foreach (var s in parsedTxt)
                        {
                            lineCntr++;
                            if (lineCntr == 1)
                            {
                                continue;
                            }

                            var eachLine   = s;
                            var parsedCols = s.Split(',');
                            var symx       = 0;
                            if (parsedCols[4].Contains("JPY"))
                            {
                                symx = 10000;
                            }
                            else
                            {
                                symx = 100;
                            }
                            double netPipsVal = 0;
                            if (parsedCols[2].Equals("SELL"))
                            {
                                netPipsVal = (double.Parse(parsedCols[5]) - double.Parse(parsedCols[9])) * symx;
                            }
                            else
                            {
                                netPipsVal = (double.Parse(parsedCols[9]) - double.Parse(parsedCols[5])) * symx;
                            }

                            if (parsedCols[4].Equals("EURUSDpro"))
                            {
                                euNetPnlTotal  += double.Parse(parsedCols[13]);
                                euNetPipsTotal += netPipsVal;
                                euTransactionCounter++;
                            }
                            else if (parsedCols[4].Equals("GBPUSDpro"))
                            {
                                gbTransactionCounter++;
                                gbNetPnlTotal  += double.Parse(parsedCols[13]);
                                gbNetPipsTotal += netPipsVal;
                            }
                            else if (parsedCols[4].Equals("USDCADpro"))
                            {
                                usTransactionCounter++;
                                usNetPnlTotal  += double.Parse(parsedCols[13]);
                                usNetPipsTotal += netPipsVal;
                            }
                        }
                        var           arr           = new List <string>();
                        string        csvContent    = String.Empty;
                        List <string> chartAttrList = new List <string>();
                        //Add headers
                        csvContent += "Items,Transactions,NetPnl,NetPips" + "\n";
                        chartAttrList.Add("EURUSDpro");
                        chartAttrList.Add(euTransactionCounter.ToString());
                        chartAttrList.Add(euNetPnlTotal.ToString());
                        chartAttrList.Add(euNetPipsTotal.ToString());
                        //chartsData.Add("EURUSDpro", chartAttrList);
                        csvContent += string.Join(",", chartAttrList) + "\n";

                        chartAttrList = new List <string>();
                        chartAttrList.Add("GBPUSDpro");
                        chartAttrList.Add(gbTransactionCounter.ToString());
                        chartAttrList.Add(gbNetPnlTotal.ToString());
                        chartAttrList.Add(gbNetPipsTotal.ToString());
                        //chartsData.Add("GBPUSDpro", chartAttrList);
                        csvContent += string.Join(",", chartAttrList) + "\n";

                        chartAttrList = new List <string>();
                        chartAttrList.Add("USDCADpro");
                        chartAttrList.Add(usTransactionCounter.ToString());
                        chartAttrList.Add(usNetPnlTotal.ToString());
                        chartAttrList.Add(usNetPipsTotal.ToString());
                        //.Add("USDCADpro", chartAttrList);
                        csvContent += string.Join(",", chartAttrList) + "\n";
                        var          filenameArry = f.Split('\\');
                        var          filename     = filenameArry[filenameArry.Length - 1];
                        StreamWriter csv          = new StreamWriter(f.Replace(filename, "PieChartTotal.csv"), false);
                        csv.Write(csvContent);
                        csv.Close();

                        Console.Write("File: ", d);
                        //execSummaryList.Add(d);
                    }
                }
            }
            else
            {
                label3.Text = "Folder doesn't exist";
                return;
            }

            using (XtraReport2 report = new XtraReport2())
            {
                // Specify PDF-specific export options.
                PdfExportOptions pdfOptions = report.ExportOptions.Pdf;

                pdfOptions.PageRange       = "1, 3-5";
                report.Parameters[1].Value = execSummaryList[0]["ROI"];
                CultureInfo provider      = CultureInfo.InvariantCulture;
                var         srcPathParsed = folderName.Split('-');
                var         dateStr       = srcPathParsed[srcPathParsed.Length - 2];
                report.Parameters[0].Value = DateTime.ParseExact(dateStr, "yyyyMMdd", provider).ToLongDateString();// DateTime.Now.ToLongDateString();
                // Specify the quality of exported images.
                pdfOptions.ConvertImagesToJpeg = false;
                pdfOptions.ImageQuality        = PdfJpegImageQuality.Medium;

                // Specify the PDF/A-compatibility.
                pdfOptions.PdfACompatibility = PdfACompatibility.PdfA3b;

                // The following options are not compatible with PDF/A.
                // The use of these options will result in errors on PDF validation.
                //pdfOptions.NeverEmbeddedFonts = "Tahoma;Courier New";
                //pdfOptions.ShowPrintDialogOnOpen = true;

                // If required, you can specify the security and signature options.
                //pdfOptions.PasswordSecurityOptions
                //pdfOptions.SignatureOptions

                // If required, specify necessary metadata and attachments
                // (e.g., to produce a ZUGFeRD-compatible PDF).
                //pdfOptions.AdditionalMetadata
                //pdfOptions.Attachments

                // Specify the document options.
                pdfOptions.DocumentOptions.Application = "Test Application";
                pdfOptions.DocumentOptions.Author      = "DX Documentation Team";
                pdfOptions.DocumentOptions.Keywords    = "DevExpress, Reporting, PDF";
                pdfOptions.DocumentOptions.Producer    = Environment.UserName.ToString();
                pdfOptions.DocumentOptions.Subject     = "Document Subject";
                pdfOptions.DocumentOptions.Title       = "Document Title";

                // Checks the validity of PDF export options
                // and return a list of any detected inconsistencies.
                IList <string> result = pdfOptions.Validate();
                try
                {
                    if (result.Count > 0)
                    {
                        Console.WriteLine(String.Join(Environment.NewLine, result));
                    }
                    else
                    {
                        report.ExportToPdf(reportPath + "/DailyReport_" + folderName.Replace(" ", "") + ".pdf", pdfOptions);
                    }
                    MessageBox.Show(folderName + " folder processed in " + textBox2.Text);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error in processing the report: " + e.Message);
                    return;
                }
            }
            // Generate pdf from htm
            CreateHtmlToPdf(Path.Combine(sourcePath, folderName), reportPath, folderName);
        }