Beispiel #1
0
        private void btnCallExportDirect_Click(object sender, System.EventArgs e)
        {
            m_ExportToEmail = false;

            GRExportType ExportType    = GetExportType();
            bool         ShowOptionDlg = ckbShowOptionDlg.Checked;
            string       FileName      = GetExportFileName(true);

            //直接调用ExportDirect方法执行导出任务
            Report.ExportDirect(ExportType, FileName, ShowOptionDlg, true);
        }
Beispiel #2
0
        private void ExportGridReport(GridppReport report, GRExportType exportType, string Title, string FileName)
        {
            DateTime StartTime = DateTime.Now;
            string   msg       = Pub.GetResText("", "MsgExportingData", "");

            msg = string.Format(msg, Title);
            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }
            if (report.DetailGrid != null)
            {
                if (report.ColumnByName("CheckBox") != null)
                {
                    report.ColumnByName("CheckBox").Visible = false;
                }
            }
            bool ret = report.ExportDirect(exportType, FileName, true, false);

            if (report.DetailGrid != null)
            {
                if (report.ColumnByName("CheckBox") != null)
                {
                    report.ColumnByName("CheckBox").Visible = true;
                }
            }
            if (!ret)
            {
                return;
            }
            msg = Pub.GetResText("", "MsgExportSuccess", "");
            msg = string.Format(msg, Title);
            RefreshMsg(msg + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
            Pub.MessageBoxShow(msg, MessageBoxIcon.Information);
        }
Beispiel #3
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     if (dt != null)
     {
         report.ExportDirect(GRExportType.gretXLS, this.Text, true, true);
         report.UnprepareExport();
     }
 }
Beispiel #4
0
 protected virtual void Export()
 {
     if (dt != null)
     {
         ConstructFun(reportFilename);
         report.ExportDirect(GRExportType.gretXLS, this.Text, true, true);
         report.UnprepareExport();
     }
 }
Beispiel #5
0
 private void tsbExport_Click(object sender, EventArgs e)
 {
     try
     {
         if (ReportViewer.Report == null)
         {
             throw new ApplicationException("当前没有可以导出的内容。");
         }
         if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
         {
             _Report.ExportDirect(GRExportType.gretXLS, this.saveFileDialog1.FileName, false, true);
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.OnError(ex);
     }
 }
Beispiel #6
0
        private void button5_Click(object sender, EventArgs e)
        {
            ExportInfo item = ((ExportInfo)comboBox2.SelectedItem);

            Report.ExportDirect(item.ExportType, "Export." + item.ExtFileName, true, false);//最后一个参数设定导出后是否打开
        }
        /// <summary>
        /// 生成底单
        /// </summary>
        public void BuildImage()
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            UpdateControlText1 updateControl = updateControlText;

            try
            {
                if (_list == null || _list.Count == 0)
                {
                    return;
                }
                for (int i = 0; i < _list.Count; i++)
                {
                    if (string.IsNullOrEmpty(_list[i].BillCode))
                    {
                        continue;
                    }
                    _printFileName = !string.IsNullOrEmpty(_list[i].BillCode) ? _list[i].BillCode : DateTime.Now.Ticks.ToString();
                    _tempList.Add(_list[i]);
                    ++_tempIndex;
                    // http://blog.csdn.net/szstephenzhou/article/details/12838961
                    // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
                    if (this.IsHandleCreated)
                    {
                        this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count));
                    }
                    //  2016-1-31下午 这一行代码一定要写,因为要导出模板的面单图片,所以一定要设置true,如果不想要就设置成false就行了,grid++的客服还是很不错的,qq:grid++ report  641243789
                    // _report.BackImagePrint = true;
                    // 直接调用ExportDirect方法执行导出任务,这里我只是导出图片哦
                    _report.ExportDirect(GRExportType.gretIMG, _printFileName, false, false);
                    _tempList.Clear();
                }
                if (_tempIndex > 0)
                {
                    if (ckAddSystemWaterMark.Checked)
                    {
                        string waterMarkFolder = BillPrintHelper.SaveFilePath + "\\水印底单";
                        if (!DirectoryUtil.IsExistDirectory(waterMarkFolder))
                        {
                            DirectoryUtil.CreateDirectory(waterMarkFolder);
                        }
                        var files = DirectoryUtil.GetFileNames(BillPrintHelper.SaveFilePath);
                        foreach (string file in files)
                        {
                            if (Utilities.FileUtil.FileIsExist(file))
                            {
                                // img对象一定要释放,不然内存上升,杨恒连,2016年7月24日15:25:35
                                using (var img = ImageHelper.WatermarkText(Image.FromFile(file), BaseSystemInfo.SoftFullName, ImageHelper.WatermarkPosition.BottomRight, new Font("Verdana", 10, FontStyle.Bold), new SolidBrush(Color.Blue)))
                                {
                                    string fileName = Utilities.FileUtil.GetFileNameNoExtension(file);
                                    img.Save(string.Format(waterMarkFolder + "\\" + fileName + ".png", fileName));
                                }
                            }
                        }
                    }
                    // alertBuildImageInfo.Show(this, "生成底单", string.Format("成功生成{0}张底单图片", _list.Count));
                    //   XtraMessageBox.Show(string.Format("成功生成{0}张底单图片,是否打开文件夹查看?", _list.Count), AppMessage.MSG0000, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //if ( == DialogResult.Yes)
                    //{
                    //    Process.Start(BillPrintHelper.SaveFilePath);
                    //}
                }
            }
            catch (Exception exception)
            {
                //   XtraMessageBox.Show(exception.Message, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.WriteException(exception);
            }
            finally
            {
                btnBuildImage.Enabled = true;
                _tempIndex            = 0;
                if (_list != null)
                {
                    stopWatch.Stop();
                    TimeSpan ts          = stopWatch.Elapsed;
                    string   elapsedTime = string.Format("{0}分{1}秒{2}毫秒", ts.Minutes, ts.Seconds, ts.Milliseconds);
                    // http://blog.csdn.net/szstephenzhou/article/details/12838961
                    // 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
                    if (this.IsHandleCreated)
                    {
                        this.Invoke(updateControl, string.Format("{0}/{1}", _tempIndex, _list.Count) + "  耗时:" + elapsedTime);
                    }
                }
            }
        }