Exemplo n.º 1
0
        /// <summary>
        /// Otwarcie okna dialogowego do wybrania pliku XLS
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenFile_Click(object sender, RoutedEventArgs e)
        {
            //otwarcie okna dialogowego
            Service.FileDialog dialog   = new Service.FileDialog();
            string             FileName = dialog.OpenDialog();

            //otwarcie pliku XLS
            FileStream  fileStream = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            ExcelParser xlsManager = new ExcelParser(fileStream);

            //parsowanie pliku xls
            List <ExcelContent> fileContent = new List <ExcelContent>();

            fileContent = xlsManager.ParseExcel();

            //dodanie wyniku parsowania do kolekcji
            ExcelFiles.Add(new ExcelFile()
            {
                FileName = FileName,
                Content  = fileContent
            });

            excelContent.ItemsSource = rows;

            FileList.Items.Refresh();
        }
Exemplo n.º 2
0
        public List <ExcelContent> Transformfile()
        {
            if (HttpContext.Current.Request.Files.Count == 0)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Plik jest wymagany."));
            }

            Stream filename = HttpContext.Current.Request.Files[0].InputStream;

            ExcelParser         mmMaker       = new ExcelParser(filename);
            List <ExcelContent> parsedContent = mmMaker.ParseExcel();

            return(parsedContent);
        }
        static void Main()
        {
            InitModules.PopulateProducts();

            Console.WriteLine("Parsing excel reports...");
            var excelReports = ExcelParser.ParseExcel(path);

            Console.WriteLine("Inserting sales reports...");

            foreach (var report in excelReports)
            {
                DBManager.InsertSalesReports(report);
            }

            Console.WriteLine("Generating pdf aggregated sales report.");
            DatabaseToPdfWriter pdfWriter = new DatabaseToPdfWriter();
            var reports = DBManager.RetrieveReports();

            pdfWriter.GeneratePDFAggregatedSalesReports(reports, "..\\..\\Report.pdf");

            Console.WriteLine("Generating sales by vendor XML file...");
            DatabaseToXmlWriter xmlWriter = new DatabaseToXmlWriter();

            xmlWriter.GenerateSalesReportByVendor(DBManager.RetrieveReportByVendors(), "..\\..\\Sales-by-Vendors-report.xml");
            XmlParser xmlParser = new XmlParser();

            DBManager.InsertVendorExpenses(xmlParser.ParseFile("..\\..\\Vendors-Expenses.xml"));

            Console.WriteLine("Inserting data in MongoDb...");
            Manager mongoManager = new Manager("mongodb://localhost");

            mongoManager.AddProducts(DBManager.GetMonthlyProducts());

            Console.WriteLine("Generating .xls file...");
            DBManager.RetrieveProductReport();
            DatabaseToExcelWriter.CreateExcelTable(DBManager.RetrieveTotalReport(DateTime.Now));
        }