/// <summary>
        /// Export data to a range of different file formats;
        /// ask the user for filename and file format
        ///
        /// NOTE this has been replaced by the two-part scheme above:
        ///   first get the filename, then the caller loads the data
        ///   from the server, then it calls ExportToFile.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="ADialogTitle"></param>
        /// <param name="ADefaultExtension"></param>
        /// <returns></returns>
        public static bool ExportWithDialog(XmlDocument doc, string ADialogTitle, string ADefaultExtension = "yml")
        {
            // TODO: openoffice
            // See also http://sourceforge.net/apps/mediawiki/openpetraorg/index.php?title=Data_liberation
            SaveFileDialog DialogSave = new SaveFileDialog();

            DialogSave.Filter = Catalog.GetString(
                "Text file (*.yml)|*.yml|XML file (*.xml)|*.xml|Excel file (*.xlsx)|*.xlsx|Spreadsheet file (*.csv)|*.csv");
            DialogSave.DefaultExt = ADefaultExtension;
            string[] filterLines = DialogSave.Filter.Split(new char[] { '|' });

            for (int count = 0; count < filterLines.Length; count++)
            {
                if (count % 2 == 1 && filterLines[count] == "*." + ADefaultExtension)
                {
                    DialogSave.FilterIndex = count / 2 + 1;
                }
            }

            DialogSave.AddExtension     = true;
            DialogSave.RestoreDirectory = true;
            DialogSave.Title            = ADialogTitle;

            if (DialogSave.ShowDialog() == DialogResult.OK)
            {
                if (DialogSave.FileName.ToLower().EndsWith("xml"))
                {
                    doc.Save(DialogSave.FileName);
                    return(true);
                }
                else if (DialogSave.FileName.ToLower().EndsWith("csv"))
                {
                    return(TCsv2Xml.Xml2Csv(doc, DialogSave.FileName));
                }
                else if (DialogSave.FileName.ToLower().EndsWith("yml"))
                {
                    return(TYml2Xml.Xml2Yml(doc, DialogSave.FileName));
                }
                else if (DialogSave.FileName.ToLower().EndsWith("xlsx"))
                {
                    using (FileStream fs = new FileStream(DialogSave.FileName, FileMode.Create))
                    {
                        if (TCsv2Xml.Xml2ExcelStream(doc, fs, false))
                        {
                            fs.Close();
                            return(true);
                        }
                    }

                    return(false);
                }
            }

            return(false);
        }
        /// <summary>
        /// Put this (XML formatted) data on a local file
        /// </summary>
        /// <param name="doc">XML data to be exported</param>
        /// <param name="FileName">Filename from GetExportFilename, above</param>
        /// <returns>true if successful</returns>
        public static bool ExportTofile(XmlDocument doc, string FileName)
        {
            if (FileName.EndsWith("xml"))
            {
                doc.Save(FileName);
                return(true);
            }
            else if (FileName.EndsWith("csv"))
            {
                return(TCsv2Xml.Xml2Csv(doc, FileName));
            }
            else if (FileName.EndsWith("yml"))
            {
                return(TYml2Xml.Xml2Yml(doc, FileName));
            }

            return(false);
        }
        /// <summary>
        /// Export data to a range of different file formats;
        /// ask the user for filename and file format
        ///
        /// NOTE this has been replaced by the two-part scheme above:
        ///   first get the filename, then the caller loads the data
        ///   from the server, then it calls ExportToFile.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="ADialogTitle"></param>
        /// <returns></returns>
        public static bool ExportWithDialog(XmlDocument doc, string ADialogTitle)
        {
            // TODO: TExcel excel = new TExcel();
            // TODO: openoffice
            // See also http://sourceforge.net/apps/mediawiki/openpetraorg/index.php?title=Data_liberation
            SaveFileDialog DialogSave = new SaveFileDialog();

            DialogSave.DefaultExt = "yml";
            DialogSave.Filter     = Catalog.GetString(
                "Text file (*.yml)|*.yml|XML file (*.xml)|*.xml|Petra export (*.ext)|*.ext|Spreadsheet file (*.csv)|*.csv");
            DialogSave.AddExtension     = true;
            DialogSave.RestoreDirectory = true;
            DialogSave.Title            = ADialogTitle;

            if (DialogSave.ShowDialog() == DialogResult.OK)
            {
                if (DialogSave.FileName.ToLower().EndsWith("xml"))
                {
                    doc.Save(DialogSave.FileName);
                    return(true);
                }
                else if (DialogSave.FileName.ToLower().EndsWith("ext"))
                {
                    return(false);
                }
                else if (DialogSave.FileName.ToLower().EndsWith("csv"))
                {
                    return(TCsv2Xml.Xml2Csv(doc, DialogSave.FileName));
                }
                else if (DialogSave.FileName.ToLower().EndsWith("yml"))
                {
                    return(TYml2Xml.Xml2Yml(doc, DialogSave.FileName));
                }
            }

            return(false);
        }