Пример #1
0
        public void AutoRun()
        {
            string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                object[][] SimpleData = LoadDataSet(Path.Combine(DataPath, "Countries.txt"));
                SimpleVirtualArrayDataSource SimpleTable = new SimpleVirtualArrayDataSource(null, SimpleData, new string[] { "Rank", "Country", "Area", "Date" }, "SimpleTable");

                using (FlexCelReport genericReport = new FlexCelReport(true))
                {
                    genericReport.AddTable("SimpleData", SimpleTable);

                    object[][] Complex1 = LoadDataSet(Path.Combine(DataPath, "Countries.txt"));
                    ComplexVirtualArrayDataSource ComplexAreas = new ComplexVirtualArrayDataSource(null, Complex1, new string[] { "Rank", "Country", "Area", "Date" }, "ComplexAreas");
                    object[][] Complex2 = LoadDataSet(Path.Combine(DataPath, "Populations.txt"));
                    ComplexVirtualArrayDataSource ComplexPopulations = new ComplexVirtualArrayDataSource(null, Complex2, new string[] { "Rank", "Country", "Population", "Date" }, "ComplexPopulations");

                    genericReport.AddTable("ComplexAreas", ComplexAreas, TDisposeMode.DisposeAfterRun);
                    genericReport.AddTable("ComplexPopulations", ComplexPopulations, TDisposeMode.DisposeAfterRun);



                    genericReport.Run(Path.Combine(DataPath, "Virtual Datasets.template.xls"), saveFileDialog1.FileName);
                }

                if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Process.Start(saveFileDialog1.FileName);
                }
            }
        }
        public ComplexVirtualArrayDataSourceState(ComplexVirtualArrayDataSource aTableData, string sort, TMasterDetailLink[] masterDetailLinks, TSplitLink splitLink)
            : base(aTableData)
        {
            if (sort == null || sort.Trim().Length == 0)
            {
                SortedData = aTableData.Data; //no need to clone, this is invariant.
            }
            else
            {
                SortedData = (object[][])aTableData.Data.Clone();
                int sortcolumn = aTableData.GetColumn(sort);
                if (sortcolumn < 0)
                {
                    throw new Exception("Can not find column \"" + sort + "\" in dataset \"" + TableName);
                }
                Array.Sort(SortedData, new ArrayComparer(sortcolumn));
            }


            //here we should use the data in masterdetaillinks and splitlink to create indexes to make the FilteredrowCount and MoveMasterRecord methods faster.
            //on this demo we are not going to do it.
            if ((masterDetailLinks != null && masterDetailLinks.Length > 0) || splitLink != null)
            {
                FilteredData = new List <object[]>();
            }
        }