Пример #1
0
        // 130501
        //public static string csExportSelected(this GridControl grid, string DirectoryPath, string _filename)
        //{
        //    try
        //    {
        //        string filename = MyLib.GetSaveFileName(DirectoryPath, "xls", "Excel | *.xls", "Save Grid To Excel",
        //                                                _filename);
        //        if (filename != string.Empty)
        //        {
        //            if (File.Exists(filename))
        //            {
        //                File.Delete(filename);
        //            }
        //            //            string.Format("Got Here {0}", filename).csTell();

        //            grid.ExportToXls(filename);
        //            return Path.GetDirectoryName(filename);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        string msg = "valid";
        //        if (grid == null) msg = "null";
        //        msg = string.Format("Message: {0} Directory: {1} FileName: {2}", ex.Message, msg, DirectoryPath,
        //                            _filename);
        //        msg.csTell();
        //    }
        //    "File Not Saved".csTell();
        //    return DirectoryPath;
        //}

        public static string csExport(this GridControl grid, string DirectoryPath, string _filename)
        {
            try
            {
                string filename = MyLib.GetSaveFileName(DirectoryPath, "xls", "Excel | *.xls", "Save Grid To Excel",
                                                        _filename);
                if (filename != string.Empty)
                {
                    if (File.Exists(filename))
                    {
                        File.Delete(filename);
                    }
                    //            string.Format("Got Here {0}", filename).csTell();
                    grid.ExportToXls(filename);
                    return(Path.GetDirectoryName(filename));
                }
            }
            catch (Exception ex)
            {
                string msg = "valid";
                if (grid == null)
                {
                    msg = "null";
                }
                msg = string.Format("Message: {0} Directory: {1} FileName: {2}", ex.Message, msg, DirectoryPath,
                                    _filename);
                msg.csTell();
            }
            "File Not Saved".csTell();
            return(DirectoryPath);
        }
Пример #2
0
        public static string csGridToXLS(this GridControl grid, string folder, string fileName)
        {
            var temp = MyLib.GetSaveFileName(folder
                                             , "xls"
                                             , "xls"
                                             , "Save Grid"
                                             , fileName);

            grid.ExportToXls(temp);
            return(Path.GetDirectoryName(temp));
        }
        public static string csSaveChartImageToFile(this ChartControl c, string path, string chartName = null)
        {
            if (string.IsNullOrEmpty(chartName))
            {
                ChartElement[] t = c.Titles.ToArray();
                if (t.Length > 0)
                {
                    foreach (ChartElement chartElement in t)
                    {
                        chartName += (chartElement + " ");
                    }
                }
            }
            chartName = chartName.Replace("\r\n", " ").Replace("/", "-").Replace(":", "_").Trim();
            // strip out the html
            int loc = chartName.IndexOf('<');

            while (loc > -1)
            {
                // find closing angle bracket
                int floc = chartName.IndexOf('>');
                if (floc > loc)
                {
                    chartName = chartName.Substring(0, loc) + " " + chartName.Substring(floc + 1);
                    loc       = chartName.IndexOf('<');
                }
                else
                {
                    break;
                }
            }
            chartName = chartName.Replace('<', '-').Replace('>', '-');
            var temp = MyLib.GetSaveFileName(path
                                             , "png"
                                             , "png"
                                             , "Save Chart Image"
                                             , chartName);

            if (string.IsNullOrEmpty(temp))
            {
                return(path);
            }
            c.ExportToImage(temp, ImageFormat.Png);
            return(Path.GetDirectoryName(temp));
        }