private void CreateTxtFromExcel(object sender, RoutedEventArgs e)
        {
            System.Data.DataSet ds;
            string inPath = Assist.RootPath + "Excel/";

            try
            {
                Assist.GetObjPaths(".xlsx", inPath).ForEach(delegate(string path)
                {
                    ds = Assist.ExcelToData(path);
                    Assist.ExcelToTxt(path, ds);
                });
                MessageBox.Show(".excel -> .txt 完成!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Txt2Xml(object sender, RoutedEventArgs e)
        {
            System.Data.DataTable dt;
            string inPath   = Assist.RootPath + "Txt/";
            string filePath = "";

            try
            {
                Assist.GetObjPaths(".txt", inPath).ForEach(delegate(string path)
                {
                    filePath = path;
                    dt       = Assist.TxtToData(path);
                    Assist.TxtToXML(path, dt);
                });
                MessageBox.Show("Txt -> Xml (for Server) 完成!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(filePath + "," + ex.Message);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 字符串转类型
        /// </summary>
        static public object stringToType(string inStr)
        {
            object t = inStr;

            if (inStr.Contains("+"))// Excel 类型结构 eg.a+i+1
            {
                string[] ss      = inStr.Split('+');
                string   strType = ss[1];

                Regex rgx = new Regex(@"[\[\]]{1}");
                if (rgx.IsMatch(strType))
                {
                    strType = rgx.Replace(strType, "");
                    if (strType == "i")
                    {
                        t = typeof(List <System.Int32>);
                    }
                    else if (strType == "ui")
                    {
                        t = typeof(List <System.UInt32>);
                    }
                    else if (strType == "f")
                    {
                        t = typeof(List <System.Single>);
                    }
                    else if (strType == "l")
                    {
                        t = typeof(List <System.Int64>);
                    }
                    else if (strType == "s")
                    {
                        t = typeof(List <System.String>);
                    }
                    else
                    {
                        //CustomType
                        t = "List<Cfg" + Assist.FirstLetterUp(strType) + ">";
                    }
                }
                else
                {
                    if (strType == "i")
                    {
                        t = typeof(System.Int32);
                    }
                    else if (strType == "ui")
                    {
                        t = typeof(System.UInt32);
                    }
                    else if (strType == "f")
                    {
                        t = typeof(System.Single);
                    }
                    else if (strType == "l")
                    {
                        t = typeof(System.Int64);
                    }
                    else if (strType == "s")
                    {
                        t = typeof(System.String);
                    }
                    else
                    {
                        //CustomType
                        t = "Cfg" + Assist.FirstLetterUp(strType);
                    }
                }
            }
            else
            {
                if (inStr == "long")
                {
                    t = typeof(System.Int64);
                }
                else if (inStr != "" && Assist.IsNumber(inStr))
                {
                    t = inStr.Contains(".") ? typeof(System.Single) : typeof(System.UInt32);
                }
            }
            return(t);
        }