Class for generator of Excel file
        public void Send2Excel()
        {
            var s = new ExportToExcel <LicenceSummaryLine, List <LicenceSummaryLine> >();

            s.dataToPrint = _licenceSummaryData.ToList();
            s.GenerateReport();
        }
Beispiel #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            //ToExcel(dataGridView1);
            ExportToExcel d = new ExportToExcel();

            d.OutputAsExcelFile(dataGridView1);
        }
        internal async Task Send2Excel(string path, DataGrid GridData)
        {
            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(() =>
                {
                    var s = new ExportToExcel <SaleReportLine, List <SaleReportLine> >();
                    s.StartUp();

                    try
                    {
                        var data = GridData.ItemsSource.OfType <SaleReportLine>();
                        if (data != null)
                        {
                            s.dataToPrint = data.ToList();
                            s.SaveReport(path);
                        }

                        StatusModel.StatusUpdate();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    s.ShutDown();
                },
                                            CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #4
0
        private void ExcelOutputBTN_Click(object sender, RoutedEventArgs e)
        {
            ExportToExcel <SingleAssistError, List <SingleAssistError> > s = new ExportToExcel <SingleAssistError, List <SingleAssistError> >();

            s.dataToPrint = (List <SingleAssistError>)DataGridViewDG.ItemsSource;
            s.GenerateReport();
        }
Beispiel #5
0
        protected void btDismantlingAct_click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(hfODID.Value);

            ExportToExcel.GenerateDismantlingAct(id);
            litScriptS.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?DismantlingAct=Special\"></iframe>";
        }
Beispiel #6
0
 private void ExportActionsListButton_Click(object sender, RoutedEventArgs e)
 {
     if (ActionsViewListBox.HasItems)
     {
         ExportToExcel.GenerateProdScheduleReport((BindingListCollectionView)ActionsViewListBox.ItemsSource);
     }
 }
Beispiel #7
0
        public void Send2Excel(DateTime startDate, DateTime endDate)
        {
            var dt = GetExportReport(startDate, endDate);
            var p  = new ExportToExcel();

            p.GenerateReport(dt);
        }
Beispiel #8
0
        //генерация акта выполненых работ
        protected void btAct_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(hfODID.Value);

            ExportToExcel.GenerateFAct(id);
            litScript.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?Act=Private\"></iframe>";
        }
Beispiel #9
0
        public static void grd_ExportToExcel(MyGrid grd)
        {
            SaveFileDialog fd = new SaveFileDialog();

            fd.Filter = "Excel Files|*.xls";

            if (fd.ShowDialog() == DialogResult.OK)
            {
                DAL.ExportToExcel xls = new ExportToExcel();

                for (int i = 0; i < grd.Columns.Count; i++)
                {
                    if (grd.Columns[i].Visible == true &&
                        grd.Columns[i].DataPropertyName.isEmpty() == false)
                    {
                        xls.addColumn(grd.Columns[i].DataPropertyName, grd.Columns[i].HeaderText);
                    }
                }

                var t = grd.getTable();
                System.IO.File.WriteAllBytes(fd.FileName, xls.exportToExcel(t));
            }
            else
            {
                return;
            }
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <SubItems> lst = null;

            using (var ctx = new SubItemsRepository())
            {
                lst = await ctx.GetSubItemsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <SubItemsExcelLine, List <SubItemsExcelLine> >
            {
                dataToPrint = lst.Select(x => new SubItemsExcelLine
                {
                    ItemNumber = x.ItemNumber,


                    ItemDescription = x.ItemDescription,


                    Quantity = x.Quantity,


                    QtyAllocated = x.QtyAllocated
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #11
0
        public IActionResult GenerateReport([Bind("ReportType")] ReportViewModel report)
        {
            var    fileName = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";
            string url      = "";
            bool   result   = false;

            switch (report.ReportType)
            {
            case LoanReportType.LoanReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"LaporanPinjamanUang_{fileName}");
                var loanReport = _loanService.GenerateLoanReport();
                result = ExportToExcel.Download <LoanReportViewModel>(_hostingEnvironment.WebRootPath, loanReport, $"LaporanPinjamanUang_{fileName}");
                break;

            case LoanReportType.LoanRepaymentReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"LaporanPengembalianPinjamanUang_{fileName}");
                var loanRepaymentReport = _loanRepaymentService.GenerateLoanRepaymentReport();
                result = ExportToExcel.Download <LoanRepaymentReportViewModel>(_hostingEnvironment.WebRootPath, loanRepaymentReport, $"LaporanPengembalianPinjamanUang_{fileName}");
                break;
            }

            ViewBag.Report   = "Download laporan";
            ViewBag.Download = url;
            return(View("Report"));
        }
Beispiel #12
0
        /// <summary>
        /// Exports the process.
        /// </summary>
        /// <param name="filename">The filename.</param>
        private void ExportProcess(string filename)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("#", typeof(int));
            dt.Columns.Add("Domain", typeof(string));
            dt.Columns.Add("Browser Detection", typeof(bool));
            dt.Columns.Add("CSS Prefix", typeof(bool));
            dt.Columns.Add("Edge", typeof(bool));
            dt.Columns.Add("JS Library", typeof(bool));
            dt.Columns.Add("Plugin Free", typeof(bool));
            dt.Columns.Add("Process Time", typeof(double));
            dt.Columns.Add("Has Error", typeof(bool));

            foreach (var item in _items)
            {
                DataRow dr = dt.NewRow();

                dr[0] = item.Id;
                dr[1] = item.SiteHost;
                dr[2] = item.BrowserDetection;
                dr[3] = item.CSSPrefix;
                dr[4] = item.Edge;
                dr[5] = item.JSLib;
                dr[6] = item.PluginFree;
                dr[7] = item.ProcessTime;
                dr[8] = item.HasError;

                dt.Rows.Add(dr);
            }

            dt.AcceptChanges();

            ExportToExcel.ExportScanResult(filename, dt);
        }
        /// <summary>
        /// Microsoft Excel Worksheet DataExporter
        /// </summary>
        /// <param name="description">the produced file's description</param>
        /// <param name="fileName">the produced file's name</param>
        /// <param name="worksheetName">the WorksheetName</param>
        /// <param name="footer">Footer's Text</param>
        /// <param name="header">Header's Text</param>
        /// <param name="numberformat">Number format such as #,##0</param>
        /// <param name="dateTimeFormat">DateTime Format such as yyyy-MM-dd hh:mm</param>
        /// <param name="timeSpanFormat">TimeSpan Format such as hh:mm:ss</param>
        /// <param name="pageLayoutView">Sets the view mode of the worksheet to PageLayout.</param>
        /// <param name="showGridLines">Show GridLines in the worksheet.</param>
        /// <param name="tableStyle">the produced table's style</param>
        public void ToExcel(
            string description     = "Exported Data",
            string fileName        = "data.xlsx",
            string worksheetName   = "worksheet1",
            string footer          = "",
            string header          = "",
            string numberformat    = "#,##0",
            string dateTimeFormat  = "yyyy-MM-dd hh:mm",
            string timeSpanFormat  = "hh:mm:ss",
            bool pageLayoutView    = false,
            bool showGridLines     = false,
            TableStyles tableStyle = TableStyles.Dark9
            )
        {
            var exportToExcel = new ExportToExcel
            {
                DateTimeFormat = dateTimeFormat,
                Description    = description,
                FileName       = fileName,
                Footer         = footer,
                Header         = header,
                Numberformat   = numberformat,
                PageLayoutView = pageLayoutView,
                ShowGridLines  = showGridLines,
                TableStyle     = tableStyle,
                TimeSpanFormat = timeSpanFormat,
                WorksheetName  = worksheetName
            };

            _pdfReport.DataBuilder.CustomExportSettings.Add(exportToExcel);
        }
        private void StopExport_OnClick(object sender, RoutedEventArgs e)
        {
            var           vm            = ViewModel as SecondViewModel;
            ExportToExcel exportToExcel = new ExportToExcel();
            bool          outResult;

            exportToExcel.ExportData(vm?.RootRefObjects, seriesChecklist, out outResult);

            if (outResult)
            {
                StopExport.IsEnabled   = false;
                Export.IsEnabled       = true;
                secText.IsEnabled      = true;
                timercontrol.IsEnabled = true;
                seriesCheck.IsEnabled  = true;
            }
            else
            {
                MessageBox.Show("Something went wrong! Please check your Microsoft Office installed?");
                StopExport.IsEnabled   = false;
                Export.IsEnabled       = true;
                timercontrol.IsEnabled = true;
                secText.IsEnabled      = true;
                seriesCheck.IsEnabled  = true;
            }
        }
Beispiel #15
0
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <Document_Type> lst = null;

            using (var ctx = new Document_TypeRepository())
            {
                lst = await ctx.GetDocument_TypeByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <Document_TypeExcelLine, List <Document_TypeExcelLine> >
            {
                dataToPrint = lst.Select(x => new Document_TypeExcelLine
                {
                    Type_of_declaration = x.Type_of_declaration,


                    Declaration_gen_procedure_code = x.Declaration_gen_procedure_code
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #16
0
        private void mnuPrint_Click(object sender, EventArgs e)
        {
            try
            {
                var frm = new frmSetPrintSize();
                if (frm.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                if (frm._PrintType != EnPrintType.Excel)
                {
                    var cls = new ReportGenerator(StiType.Building_Request_List, frm._PrintType)
                    {
                        Lst = new List <object>(_list)
                    };
                    cls.PrintNew();
                    return;
                }

                ExportToExcel.ExportRequest(_list, this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #17
0
        public void ExportToExcel(string fileName)
        {
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            ExportToCSV   exporterCSV = new ExportToCSV(_separator);
            ExportToExcel exporter    = new ExportToExcel();

            _fileName = fileName;
            string directory = _fileName.Substring(0, _fileName.LastIndexOf(@"\") + 1);

            if (_table != null && _fileName != null && !_fileName.Equals(string.Empty) && Directory.Exists(directory))
            {
                _gridLayoutProperties = _manager.GetLayoutProperties(_excludedColumns);
                if (!exporter.IsOpen(_fileName))
                {
                    if (_canExportToExcel)
                    {
                        exporter.Export(_table, _fileName, "Prueba", _gridLayoutProperties);
                    }
                    else
                    {
                        exporterCSV.Export(_table, _fileName, _gridLayoutProperties);
                    }
                }
                else                 // else "Archivo abierto...."
                {
                    DialogResult result;
                    result = MessageBox.Show("El archivo '" + _fileName + "' se encuentra abierto (Para poder exportar los datos el mismo debe estar cerrado). Ciérrelo y vuelva a intentarlo.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
            }
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }
Beispiel #18
0
        void FN_ExportToExcel()
        {
            var QueryExcel = sysEmailQuery.AsEnumerable().Select(x => new
            {
                name       = x.name,
                email      = x.email,
                port       = x.port,
                isSSL      = x.isSSL,
                smtpClient = x.smtpClient,
                side       = x.side,
                branchName = x.branchName,
                isMajor    = x.isMajor,
                notes      = x.notes
            });
            var DTForExcel = QueryExcel.ToDataTable();

            DTForExcel.Columns[0].Caption = MainWindow.resourcemanager.GetString("trName");
            DTForExcel.Columns[1].Caption = MainWindow.resourcemanager.GetString("sssssssssssss");
            DTForExcel.Columns[2].Caption = MainWindow.resourcemanager.GetString("sssssssssssssss");
            DTForExcel.Columns[3].Caption = MainWindow.resourcemanager.GetString("sssssssssssssss");
            DTForExcel.Columns[4].Caption = MainWindow.resourcemanager.GetString("sssssssssssssss");
            DTForExcel.Columns[5].Caption = MainWindow.resourcemanager.GetString("sssssssssssssss");
            DTForExcel.Columns[6].Caption = MainWindow.resourcemanager.GetString("sssssssssssssss");
            DTForExcel.Columns[7].Caption = MainWindow.resourcemanager.GetString("sssssssssssssss");
            DTForExcel.Columns[8].Caption = MainWindow.resourcemanager.GetString("trNote");

            ExportToExcel.Export(DTForExcel);
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <xcuda_Supplementary_unit> lst = null;

            using (var ctx = new xcuda_Supplementary_unitRepository())
            {
                lst = await ctx.Getxcuda_Supplementary_unitByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <xcuda_Supplementary_unitExcelLine, List <xcuda_Supplementary_unitExcelLine> >
            {
                dataToPrint = lst.Select(x => new xcuda_Supplementary_unitExcelLine
                {
                    Suppplementary_unit_quantity = x.Suppplementary_unit_quantity,


                    Suppplementary_unit_code = x.Suppplementary_unit_code,


                    Suppplementary_unit_name = x.Suppplementary_unit_name,


                    IsFirstRow = x.IsFirstRow
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <CounterPointPOs> lst = null;

            using (var ctx = new CounterPointPOsRepository())
            {
                lst = await ctx.GetCounterPointPOsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <CounterPointPOsExcelLine, List <CounterPointPOsExcelLine> >
            {
                dataToPrint = lst.Select(x => new CounterPointPOsExcelLine
                {
                    PurchaseOrderNo = x.PurchaseOrderNo,


                    Date = x.Date,


                    LineNumber = x.LineNumber,


                    Downloaded = x.Downloaded
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #21
0
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <OverShortSuggestedDocument> lst = null;

            using (var ctx = new OverShortSuggestedDocumentRepository())
            {
                lst = await ctx.GetOverShortSuggestedDocumentsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <OverShortSuggestedDocumentExcelLine, List <OverShortSuggestedDocumentExcelLine> >
            {
                dataToPrint = lst.Select(x => new OverShortSuggestedDocumentExcelLine
                {
                    CNumber = x.CNumber,


                    ReferenceNumber = x.ReferenceNumber
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            ExportToExcel <Adresse> report = new ExportToExcel <Adresse>();

            report.dataToPrint = liste;
            report.GenerateReport();
        }
Beispiel #23
0
        public WPFViewModel(RealFileProvider realFileProvider)
        {
            History = new ObservableCollection <IncomeTaxCalFinder>();

            INotifyPropertyChanged notify;

            this.fileProvider = new RealFileProvider();

            IncomeCalculator        = new IncomeTaxCalFinder();
            IncomeCalculator.Income = 75000;
            States = IncomeCalculator.taxRates;

            CalculateCommand = new DelegateCommand(() =>
            {
                if (IncomeCalculator.Income <= 0)
                {
                    MessageBox.Show("Income must be greater the zero.");
                    return;
                }
                IncomeCalculator.State = SelectedState;
                if (IncomeCalculator.State == null)
                {
                    MessageBox.Show("A state must be selected");
                    return;
                }
                IncomeCalculator.taxableIncome();
                History.Add(IncomeCalculator);
                ExportToExcel.RaiseCanExecuteChanged();

                IncomeCalculator = IncomeCalculator.Clone() as IncomeTaxCalFinder;
                RaisePropertyChanged(nameof(IncomeCalculator));
            });
        }
        public ActionResult Export()
        {
            var all = _landingPageService.GetAll();
            var landingPageExports = new List <LandingPageExport>();

            if (all.IsAny())
            {
                foreach (var landingPage in all)
                {
                    var landingPageExport = new LandingPageExport
                    {
                        FullName    = landingPage.FullName,
                        DateOfBith  = landingPage.DateOfBith,
                        Email       = landingPage.Email,
                        PhoneNumber = landingPage.PhoneNumber,
                        Status      = Common.GetStatusLanddingPage(landingPage.Status),
                        PlaceOfGift = string.Concat(landingPage.ContactInformation.Title, " - ", landingPage.ContactInformation.Address)
                    };
                    landingPageExports.Add(landingPageExport);
                }
            }

            ExportToExcel.ListToExcel(landingPageExports);

            return(new EmptyResult());
        }
Beispiel #25
0
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <EmptyFullCode> lst = null;

            using (var ctx = new EmptyFullCodeRepository())
            {
                lst = await ctx.GetEmptyFullCodesByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <EmptyFullCodeExcelLine, List <EmptyFullCodeExcelLine> >
            {
                dataToPrint = lst.Select(x => new EmptyFullCodeExcelLine
                {
                    EmptyFullCodeName = x.EmptyFullCodeName,


                    EmptyFullDescription = x.EmptyFullDescription
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #26
0
        protected void btWithdrawalActSpecial_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(hfODID.Value);

            ExportToExcel.GenerateWithdrawalActSpecial(id);
            litScriptS.Text = "<iframe style=\"display:none;\" src=\"../GetDocument.ashx?AlternativeAct=Special\"></iframe>";
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <Customs_Procedure> lst = null;

            using (var ctx = new Customs_ProcedureRepository())
            {
                lst = await ctx.GetCustoms_ProcedureByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <Customs_ProcedureExcelLine, List <Customs_ProcedureExcelLine> >
            {
                dataToPrint = lst.Select(x => new Customs_ProcedureExcelLine
                {
                    Extended_customs_procedure = x.Extended_customs_procedure,


                    National_customs_procedure = x.National_customs_procedure,


                    IsDefault = x.IsDefault
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #28
0
        public IActionResult GenerateReport([Bind("ReportType")] ShareReportViewModel report)
        {
            var fileName = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";
            var url      = "";
            var result   = false;

            switch (report.ReportType)
            {
            case ShareReportType.SharePriceReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"DaftarHargaSaham_{fileName}");
                var shareList = _shareService.GetSharePricePage().ToList();
                result = ExportToExcel.Download <SharePriceModel>(_hostingEnvironment.WebRootPath, shareList, $"DaftarHargaSaham_{fileName}");
                break;

            case ShareReportType.ShareholderReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"LaporanPemegangSaham_{fileName}");
                var shareholderReport = _shareTransactionService.GenerateShareholderReport();
                result = ExportToExcel.Download <ShareholderReportViewModel>(_hostingEnvironment.WebRootPath, shareholderReport, $"LaporanPemegangSaham_{fileName}");
                break;
            }

            ViewBag.Report   = "Download laporan";
            ViewBag.Download = url;
            return(View("Report"));
        }
Beispiel #29
0
        public void SendInventoryViaMail(SendInventoryRequestModel objInv, string TemplatePath, string imgPath, int LoginID)
        {
            StringBuilder sbMailTemplate = new StringBuilder();

            sbMailTemplate.Append(System.IO.File.ReadAllText(TemplatePath));

            List <string> lstOfEmailIDs = new List <string>();

            lstOfEmailIDs.Add(objInv.EMailTo);

            DataTable dt = GetDataForExcelExport(objInv.filterText, false, LoginID);

            if (dt.Columns.Count > 0)
            {
                dt.Columns.RemoveAt(0);
                dt.Columns.RemoveAt(dt.Columns.Count - 1);
            }
            byte[] st = ExportToExcel.InventoryExportToExcel(dt, imgPath, true);
            List <MailAttachment> objLst = new List <MailAttachment>();
            var objMA = new MailAttachment();

            objMA.FileBytes = st;
            objMA.FileName  = "InventoryExport.xlsx";
            objLst.Add(objMA);
            sbMailTemplate = sbMailTemplate.Replace("${CustomerName}", objInv.EmailName);
            sbMailTemplate = sbMailTemplate.Replace("${Message}", objInv.Message);

            if (this.objMU == null)
            {
                this.objMU = new MailUtility();
            }
            objMU.SendMail(lstOfEmailIDs, objInv.Subject, true, sbMailTemplate.ToString(), objLst, objInv.EMailCC, objInv.EMailBCC);
        }
Beispiel #30
0
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <TariffSupUnitLkps> lst = null;

            using (var ctx = new TariffSupUnitLkpsRepository())
            {
                lst = await ctx.GetTariffSupUnitLkpsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <TariffSupUnitLkpsExcelLine, List <TariffSupUnitLkpsExcelLine> >
            {
                dataToPrint = lst.Select(x => new TariffSupUnitLkpsExcelLine
                {
                    // TariffCategoryCode = x.TariffCategoryCode ,


                    SuppUnitCode2 = x.SuppUnitCode2,


                    SuppUnitName2 = x.SuppUnitName2,


                    SuppQty = x.SuppQty
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }
Beispiel #31
0
 public void ThenExportTheListToAExcelFileWithHeaderFormat(string fileLocation)
 {
     var expExcel = new ExportToExcel(true, "White", "Blue");
     var result = expExcel.ListToExcel<Person>(persons);
     string directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     using (BinaryWriter writer = new BinaryWriter(File.Create(fileLocation)))
     {
         writer.Write(result, 0, result.Length);
         writer.Flush();
         writer.Close();
     }
 }
 private void btnExportToXLSheet_Click(object sender, RoutedEventArgs e)
 {
     
     ExportToExcel<Spare, List<Spare>> s = new ExportToExcel<Spare, List<Spare>>();
     
     if (null != gridSparesAdded.ItemsSource && gridSparesAdded.Items.Count > 0)
     {
         s.dataToPrint = (List<Spare>)gridSparesAdded.ItemsSource;
         s.GenerateReport();
     }
     else
     {
         MessageBox.Show("No Data Available in Grid");
     }
     
 }
Beispiel #33
0
 private void ExecExportToExcel(object obj)
 {
     ExportToExcel<Todo,TodoList> s = new ExportToExcel<Todo, TodoList>();
     s.dataToPrint = Todos.ToList();
     s.GenerateReport();
 }
Beispiel #34
0
 //
 // Menu->File->Export
 //
 private void Menu_File_Export_Click(object sender, RoutedEventArgs e)
 {
     PortType port = (PortType)this.DataPannel.SelectedContent;
     ExportToExcel<SensorData> s = new ExportToExcel<SensorData>();
     s.dataToPrint = port.Sensor.Data;
     string sensor_info = port.Sensor.Id.ToString() + "-" + port.Sensor.Name + "(" + port.Sensor.ManufactureNumber + ")";
     string sensor_location = "";
     string node_id = nodes[this.DevicePanel.SelectedIndex].Id;
     for (int node_index = 0; node_index < this.nodes.Count; node_index++)
     {
         if (nodes[node_index].Id == node_id)
         {
             sensor_location = "Location: " + nodes[node_index].Location;
             break;
         }
     }
     string sensor_place = node_id + "; " + port.Id;
     s.GenerateReport(sensor_info, sensor_location, sensor_place);
 }
 private void SetHeaderOptions(SimpleExcelExport.Column column, NPOI.SS.UserModel.IRow row, int columnNumber, ExportToExcel exportToExcel)
 {
     HSSFCellStyle style = (HSSFCellStyle)document.CreateCellStyle();
     var font = document.CreateFont();
     if (column.HFontBold)
     {
         font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
     }
     if (!string.IsNullOrEmpty(column.HFontColor))
     {
         System.Drawing.Color fontColor = exportToExcel.GetColor(column.ColumnName, column.HFontColor, typeof(string));
         if (!fontColor.IsEmpty)
         {
             font.Color = GetXLColour(fontColor);
         }
     }
     if (!string.IsNullOrEmpty(column.HBackColor))
     {
         System.Drawing.Color backgroundColor = exportToExcel.GetColor(column.ColumnName, column.HBackColor, typeof(string));
         if (!backgroundColor.IsEmpty)
         {
             style.FillForegroundColor = GetXLColour(backgroundColor);
             style.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
         }
     }
     style.SetFont(font);
     row.Cells[columnNumber].CellStyle = style;
 }
        private void CreateHeader()
        {
            int columnNumber=0;
            var orderedColumns = columns.OrderBy(x => x.ColumnOrder);
            var row = currentSheet.CreateRow(currentRowNumber);
            ExportToExcel exportToExcel = new ExportToExcel();

            foreach (var column in orderedColumns)
            {
                row.CreateCell(columnNumber, NPOI.SS.UserModel.CellType.String);
                var cellt = GetColumnCellType(column.PropType);
                row.Cells[columnNumber].SetCellValue(column.ColumnName);
                currentSheet.SetColumnWidth(columnNumber, (int)((column.ColumnName.Length * 1.5) * 256));
                SetHeaderOptions(column, row, columnNumber, exportToExcel);
                ++columnNumber;
            }
        }
Beispiel #37
0
        private void export_Click(object sender, EventArgs e)
        {
            SaveFileDialog s_dialog = new SaveFileDialog();
            s_dialog.DefaultExt = ".xls";
            s_dialog.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
            s_dialog.ShowDialog();

            //slow method
            //this.WriteToExcelSpreadsheet(s_dialog.FileName,ds.Tables[0]);

            //my own class and methods for faster export
            ExportToExcel export = new ExportToExcel(s_dialog.FileName,ds);

            export.writeToExcel();

            // EXPORT TO MS EXCEL METHOD
        }