コード例 #1
0
        public FileStreamResult ExcelView(Models.UserSearchModel data)
        {
            DataTable users = new DataTable();

            try
            {
                if (data.SearchString == null)
                {
                    data.SearchString = "";
                }
                if (data.SearchString == "")
                {
                    data.SearchValue = 0;
                }
                users = BLayer.User.GetAllB2BForExcel(data.Status, data.SearchString, data.SearchValue, (int)CLayer.Role.Roles.Corporate);
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(new FileStreamResult(DataTableToExcel.GetExcelStream(users, "Report", true, null, null, null), DataTableToExcel.CONTENT_TYPE_XLSX)
            {
                FileDownloadName = "CorporateDetails.xlsx"
            });
        }
コード例 #2
0
        /// <summary>
        ///     导出
        /// </summary>
        /// <returns></returns>
        public void Export(DataTable table, string fileName)
        {
            table.TableName = "MarksixRecord";
            var toExcel = new DataTableToExcel();

            toExcel.Export(table, fileName, "MarksixRecord");
        }
コード例 #3
0
ファイル: Window1.xaml.cs プロジェクト: lwfwind/CVG
        private void Exportbutton_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialogSaveFile = new SaveFileDialog();

            dialogSaveFile.AddExtension    = true; //是否自动添加扩展名
            dialogSaveFile.Filter          = "HTML[*.html]|*.html|Excel 2007[*.xlsx]|*.xlsx|Excel 2003[*.xls]|*.xls";
            dialogSaveFile.OverwritePrompt = true; //文件已存在是否提示覆盖
            //dialogSaveFile.FileName = "文件名";//默认文件名
            dialogSaveFile.CheckPathExists = true; //提示输入的文件名无效
            dialogSaveFile.Title           = "Save As";
            String appOutputPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Output Sample";

            dialogSaveFile.InitialDirectory = appOutputPath;

            //Show dialog
            bool?b = dialogSaveFile.ShowDialog();

            //Click Save button
            if (b == true)
            {
                string filename = dialogSaveFile.FileName;
                if (dialogSaveFile.FilterIndex == 1)
                {
                    viewmodel.QueryResult.ToHtmlTable(filename);
                }
                else
                {
                    DataTableToExcel.DataTabletoExcel(viewmodel.QueryResult, filename);
                }
            }
        }
コード例 #4
0
        public ActionResult ExcelReport(DateTime HiddenToDate, DateTime HiddenFromDate)
        {
            DateTime curdate = HiddenFromDate;

            DateTime ToDate = HiddenToDate;

            DataTable dt = BLayer.OfflineBooking.SupplierPaymentPendingReport(curdate, ToDate);

            return(new FileStreamResult(DataTableToExcel.GetExcelStream(dt, "Report", true, null, null, null), DataTableToExcel.CONTENT_TYPE_XLSX)
            {
                FileDownloadName = "SupplierPaymentPendingReport.xlsx"
            });
        }
コード例 #5
0
        public ActionResult ExcelReport(CLayer.OfflineBooking model, bool IsExcelDownload = true)
        {
            Models.OfflineBookingModel data = new Models.OfflineBookingModel();
            DataTable Reportlist            = null;

            try
            {
                string date1 = Request["FromDate"];
                string date2 = Request["ToDate"];

                string SearchString = Request["SearchString"];

                DateTime FromDate = Convert.ToDateTime(date1);
                DateTime ToDate   = Convert.ToDateTime(date2);

                string FromDates = FromDate.ToString("MMMM dd, yyyy");

                string FromDatesonlyDate = DateTime.Parse(FromDates).ToShortDateString();


                string ToDates = ToDate.ToString("MMMM dd, yyyy");

                string ToDatesonlyDate = DateTime.Parse(ToDates).ToShortDateString();
                Reportlist               = BLayer.OfflineBooking.BankUploadReport(SearchString, LIMIT, FromDate, ToDate, true);
                ViewBag.Filter           = new Models.GrossMarrginReportModel();
                data.OfflineBookingTable = Reportlist;
                Models.OfflineBookingModel forPager = new Models.OfflineBookingModel()
                {
                    SearchString = data.SearchString,
                    SearchValue  = data.SearchValue,
                    FromDate     = data.FromDate,
                    ToDate       = data.ToDate,
                    TotalRows    = 0,
                    Limit        = 2000,
                    currentPage  = data.currentPage
                };
                if (Reportlist.Rows.Count > 0)
                {
                    forPager.TotalRows = Convert.ToInt64(Reportlist.Rows.Count);
                }
                ViewBag.Filter = forPager;
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
            }
            return(new FileStreamResult(DataTableToExcel.GetExcelStream(Reportlist, "Report", false, null, null, null), DataTableToExcel.CONTENT_TYPE_XLSX)
            {
                FileDownloadName = "BankPaymentReport.xlsx"
            });
        }
コード例 #6
0
ファイル: JSEvent.cs プロジェクト: fuchanglei/ehuatong
        public void MN_DataGridSAves(string jsonText)
        {
            string[]       json    = Regex.Split(jsonText, "#@#file_type#@#", RegexOptions.IgnoreCase);
            DataTable      mytable = JsonToDatable.JsonToDataTable(json[0]);
            SaveFileDialog sfd     = new SaveFileDialog();

            sfd.RestoreDirectory = true;
            sfd.FilterIndex      = 1;
            sfd.Title            = "保存文件";
            if (json[1] == "txt")
            {
                sfd.Filter = "文本文件(*.txt)|*.txt";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    ExportDataTable txt = new DataTableToTxt();
                    txt.ExportDataTable_file(sfd.FileName, mytable);
                }
            }
            else if (json[1] == "csv")
            {
                sfd.Filter = "csv文件(*.csv)|*.csv";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    ExportDataTable txt = new DataTableToTxt();
                    txt.ExportDataTable_file(sfd.FileName, mytable);
                }
            }
            else if (json[1] == "xls")
            {
                sfd.Filter = "EXCEl文件--2003(*.xls)|*.xls|EXCEL文件--2007(*.xlsx)|*.xlsx";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    ExportDataTable excel = new DataTableToExcel();
                    excel.ExportDataTable_file(sfd.FileName, mytable);
                }
            }
        }