Beispiel #1
0
        public static void ExportTo(this PivotGridControl pvtGrid, string fileName, bool openAfterExport = false)
        {
            var ext = new FileInfo(fileName).Extension;

            switch (ext)
            {
            case ".csv":
                pvtGrid.ExportToCsv(fileName);
                break;

            case ".htm":
            case ".html":
                pvtGrid.ExportToHtml(fileName);
                break;

            case ".bmp":
                pvtGrid.ExportToImage(fileName);
                break;

            case ".mht":
                pvtGrid.ExportToMht(fileName);
                break;

            case ".pdf":
                pvtGrid.ExportToPdf(fileName);
                break;

            case ".rtf":
                pvtGrid.ExportToRtf(fileName);
                break;

            case ".txt":
                pvtGrid.ExportToText(fileName);
                break;

            case ".xls":
                pvtGrid.ExportToXls(fileName);
                break;

            case ".xlsx":
                pvtGrid.ExportToXlsx(fileName);
                break;

            default:
                throw new Exception("გთხოვთ აირჩიოთ სწორი ფაილის ტიპი.");
            }


            if (openAfterExport)
            {
                try
                {
                    Process.Start(fileName);
                }
                catch
                {
                    //if (throwError) throw;
                }
            }
        }
Beispiel #2
0
        static void DoExportEx(string title, string filter, string exportFormat, PivotGridControl grid)
        {
            if (grid == null)
            {
                return;
            }

            string fname = grid.FindForm().Text;

            fname = fname.Replace(" ", "");
            fname = fname.Replace('/', '_');
            //fname = FileUtility.GetValidateItemName(fname);
            fname = fname + "_" + DateTime.Now.ToString("yyyyMMddHHmmss");

            string fileName = ShowSaveFileDialog(title, filter, fname);

            if (string.IsNullOrEmpty(fileName) == false)
            {
                PivotGridExportHelper exporter = new PivotGridExportHelper();
                exporter.exportGrid = grid;
                exporter.stop       = false;
                exporter.thread     = new Thread(new ThreadStart(exporter.StartExport));
                exporter.thread.Start();
                Cursor currentCursor = Cursor.Current;
                Cursor.Current = Cursors.WaitCursor;

                switch (exportFormat)
                {
                case "htm": grid.ExportToHtml(fileName);
                    break;

                case "mht": grid.ExportToMht(fileName);
                    break;

                case "pdf": grid.ExportToPdf(fileName);
                    break;

                case "xls": grid.ExportToXls(fileName);
                    break;

                case "rtf": grid.ExportToRtf(fileName);
                    break;

                case "txt": grid.ExportToText(fileName, "\t");
                    break;
                }
                exporter.EndExport();
                Cursor.Current = currentCursor;
                OpenFile(fileName);
            }
        }
Beispiel #3
0
        public static void ExportGridToFile(PivotGridControl grid, string ext)
        {
            switch (ext)
            {
            case "xls":
                grid.ExportToXls(File.ShowSaveFileDialog(ext), true);
                return;

            case "pdf":
                grid.ExportToPdf(File.ShowSaveFileDialog(ext));
                return;

            case "htm":
                grid.ExportToHtml(File.ShowSaveFileDialog(ext));
                return;

            case "rtf":
                grid.ExportToRtf(File.ShowSaveFileDialog(ext));
                return;
            }
        }