Exemple #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;
                }
            }
        }