示例#1
0
        private static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Syntax: CompareExcelFiles file1 file2 column [column...]");
                Console.WriteLine("        file1     first file to compare");
                Console.WriteLine("        file2     second file to compare");
                Console.WriteLine("        column    name of column(s) to sort / compare by");

                return;
            }

            var excel  = new ExcelLoader();
            var table1 = excel.Load(args[0]);
            var table2 = excel.Load(args[1]);

            var columns  = args.Skip(2).ToArray();
            var comparer = new TableComparer(columns);

            var diff1 = comparer.Compare(table1, table2);
            var diff2 = comparer.Compare(table2, table1);

            DumpResult(1, args[0], diff1, table1.RowCount, columns);
            DumpResult(2, args[1], diff2, table2.RowCount, columns);
        }
示例#2
0
        private void importButton_Click(object sender, EventArgs e)
        {
            if (_chooseFile?.Exists ?? false)
            {
                var loader = new ExcelLoader();
                var batch  = loader.Load(_chooseFile.FullName);
                if (!string.IsNullOrWhiteSpace(batchInfoTextBox.Text))
                {
                    foreach (var info in batch.Items)
                    {
                        info.BatchNo = batchInfoTextBox.Text;
                    }
                }

                //if (infos != null)
                //{
                //    //foreach (var info in infos)
                //    //    Console.WriteLine(info.QRCodeContent);
                //    var form = new ConfirmImportDataForm(infos);
                //    form.ShowDialog();
                //}
            }
            else
            {
                MessageBox.Show("请选择文件", "请选择文件");
            }
        }
示例#3
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            Console.WriteLine("ROWCOUNT: " + dataGridView1.RowCount);

            ExcelLoader loader = new ExcelLoader();

            Excel.Workbook wb = loader.getWorkbook("C:/Users/fleet/Documents/myWorkbook.xlsx");

            Excel.Worksheet sheet = (Excel.Worksheet)wb.Worksheets.get_Item(1);
            Excel.Range     range = sheet.UsedRange;
            dataGridView1.SuspendLayout();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells[3].Value = (range.Cells[i + 1, 1] as Excel.Range).Value2;
                if (dataGridView1.Rows[i].Cells[2].Value.Equals(dataGridView1.Rows[i].Cells[3].Value))
                {
                    dataGridView1.Rows[i].Cells[4].Style.BackColor = Color.Green;
                    dataGridView1.Rows[i].Cells[4].Value           = "OK";
                }
                else
                {
                    dataGridView1.Rows[i].Cells[4].Style.BackColor = Color.Red;
                    dataGridView1.Rows[i].Cells[4].Value           = "FEHLER";
                }
            }
            dataGridView1.AutoResizeColumns();
            dataGridView1.ResumeLayout();
            loader.quit();
        }
    public static void ProcessConvert()
    {
        FileStream stream = File.Open(Application.dataPath + PATH_EXCEL, FileMode.Open, FileAccess.Read);
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
        ItemDataSet itemDataSet = ScriptableObject.CreateInstance<ItemDataSet>();
        DataTable dataTable;
        ExcelLoader loader;

        if (excelReader.AsDataSet () != null)
        {
            dataTable = excelReader.AsDataSet ().Tables["Item"];
            loader = new ExcelLoader(dataTable);
            itemDataSet.itemDataSet = loader.CreateDataList<ItemData>();
            dataTable = excelReader.AsDataSet ().Tables["Weapon"];
            loader = new ExcelLoader(dataTable);
            itemDataSet.weaponDataSet = loader.CreateDataList<WeaponData>();
            dataTable = excelReader.AsDataSet ().Tables["Magic"];
            loader = new ExcelLoader(dataTable);
            itemDataSet.magicDataSet = loader.CreateDataList<MagicData>();

            foreach(WeaponData weapon in itemDataSet.weaponDataSet)
            {
                weapon.type = ItemType.Weapon;
            }
            foreach(MagicData magic in itemDataSet.magicDataSet)
            {
                magic.type = ItemType.Magic;
            }

            AssetDatabase.CreateAsset(itemDataSet, PATH_ASSET);
        }
        excelReader.Dispose ();
    }
        public static void ReadAllAgemo(string cnPath, string jpPath)
        {
            //string cnPath = "./cn-text";
            //string jpPath = "./jp-text";
            string[] cnFiles = Directory.GetFiles(cnPath, "*.txt", SearchOption.AllDirectories);
            Dictionary <string, AgemoText.Data> cnDictionary = new Dictionary <string, AgemoText.Data>();

            LocText tempLoc = new LocText("");

            foreach (var fileName in cnFiles)
            {
                string fName = Path.GetFileName(fileName);
                if (File.Exists(cnPath + "/" + fName) && File.Exists(jpPath + "/" + fName))
                {
                    List <AgemoText.Data> cnData = AgemoText.ReadAgemoText(File.ReadAllLines(cnPath + "/" + fName, Encoding.Unicode));
                    List <AgemoText.Data> jpData = AgemoText.ReadAgemoText(File.ReadAllLines(jpPath + "/" + fName, Encoding.Unicode));
                    cnDictionary = convData(cnData);
                    for (int i = 0; i < jpData.Count; i++)
                    {
                        tempLoc = new LocText(jpData[i].Text);
                        if (cnDictionary.ContainsKey(jpData[i].TAG))
                        {
                            tempLoc.zh_CN = cnDictionary[jpData[i].TAG].Text;
                        }
                        DataMgr.Instance.GameTextDictionary.Add(fName + "__" + jpData[i].TAG, tempLoc);
                    }
                }
            }

            ExcelLoader excel = new ExcelLoader("./DDS3_Translation.xlsx");

            excel.WriteExcel(DataMgr.Instance.GameTextDictionary);
        }
示例#6
0
        static void ConvertExcelToJson(string excelFilePath, string exportDir)
        {
            using (var excelFile = new FileStream(excelFilePath, FileMode.Open, FileAccess.Read))
            {
                var excelLoader = new ExcelLoader(excelFile);

                while (excelLoader.HasSheetToRead())
                {
                    var excelSheet = excelLoader.LoadNextSheet();

                    var sheetFileName = $"{GetNameFromPath(excelFile.Name)}.{excelSheet.Name}.json";
                    using (var jsonFile = new FileStream($"{exportDir}/{sheetFileName}", FileMode.Create, FileAccess.Write))
                    {
                        using (var streamWriter = new StreamWriter(jsonFile))
                        {
                            var collectionToJsonConverter = new CollectionToJsonConverter(excelSheet.Properties);

                            streamWriter.Write(collectionToJsonConverter.CreateJSONLiteral(excelSheet.Sheet));
                        }

                        Console.WriteLine($"Exported: {jsonFile.Name}");
                    }
                }
            }
        }
示例#7
0
文件: Program.cs 项目: njmube/public
        private static void Main(string[] args)
        {
            if (args.Length < 3)
              {
            Console.WriteLine("Syntax: CompareExcelFiles file1 file2 column [column...]");
            Console.WriteLine("        file1     first file to compare");
            Console.WriteLine("        file2     second file to compare");
            Console.WriteLine("        column    name of column(s) to sort / compare by");

            return;
              }

              var excel = new ExcelLoader();
              var table1 = excel.Load(args[0]);
              var table2 = excel.Load(args[1]);

              var columns = args.Skip(2).ToArray();
              var comparer = new TableComparer(columns);

              var diff1 = comparer.Compare(table1, table2);
              var diff2 = comparer.Compare(table2, table1);

              DumpResult(1, args[0], diff1, table1.RowCount, columns);
              DumpResult(2, args[1], diff2, table2.RowCount, columns);
        }
示例#8
0
 public MainClass()
 {
     GameEnvironment.Setting.ActionDispatcher = new CustomActionDispatcher();
     ExcelLoader.Init();
     SkillEventRegister.Initialize();
     NavigationSystem.LoadAllNavigation();
 }
示例#9
0
        /// <summary>
        /// 加载Excel文件
        /// </summary>
        /// <param name="options">导入设置</param>
        public void loadExcel(Program.Options options)
        {
            mOptions = options;

            //-- Excel File
            string excelPath = options.ExcelPath;
            string excelName = Path.GetFileNameWithoutExtension(excelPath);

            //-- Header
            int header = options.HeaderRows;

            //-- Encoding
            Encoding cd = new UTF8Encoding(false);

            if (options.Encoding != "utf8-nobom")
            {
                foreach (EncodingInfo ei in Encoding.GetEncodings())
                {
                    Encoding e = ei.GetEncoding();
                    if (e.HeaderName == options.Encoding)
                    {
                        cd = e;
                        break;
                    }
                }
            }
            mEncoding = cd;

            //-- Load Excel
            ExcelLoader excel = new ExcelLoader(excelPath, header);

            //-- 导出JSON
            mJson = new JsonExporter(excel, options.Lowcase, options.ExportArray, options.DateFormat);
        }
示例#10
0
        public static void Export(string dllFpath, string inputExcelFpath, string outputFpath, string password)
        {
            List <Type> types = new List <Type>();

            foreach (Type type in Assembly.LoadFrom(dllFpath).GetTypes())
            {
                if (!type.IsClass)
                {
                    continue;
                }

                if (type.GetCustomAttributes(typeof(ExportAttribute), true).FirstOrDefault() == null)
                {
                    continue;
                }

                types.Add(type);
            }

            ExcelLoader      loader = new ExcelLoader(inputExcelFpath);
            SQLiteConnection conn   = new SQLiteConnection(outputFpath, password,
                                                           SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);

            for (int i = 0; i < types.Count; ++i)
            {
                Type          type     = types[i];
                List <object> dataList = loader.GetDataList(type, type.Name);
                Console.WriteLine($"{i + 1}/{types.Count} {type} :  {dataList.Count}");

                conn.DropTable(type);
                conn.CreateTable(type);
                conn.InsertAll(dataList, type);
            }
        }
        public void ThenItShouldContainRowsForItemsAndOneForHeader(int p0, int p1)
        {
            SpreadsheetStream.Seek(0, SeekOrigin.Begin);

            ExcelLoader.LoadReadOnlyFromStream(SpreadsheetStream)
            .ReadRows()
            .Count.Should().Be(p0);
        }
示例#12
0
    public List <IntegraDU> ReestrSheet1()
    {
        Excel.Worksheet WSSource = Globals.ThisAddIn.Application.Sheets["Реестр"];
        EnableCalculations(false);
        Globals.ThisAddIn.Application.CopyObjectsWithCells = true;
        ExcelLoader _excelLoader = new ExcelLoader(Globals.ThisAddIn.Application);

        return(_excelLoader.MapRows(WSSource));
    }
示例#13
0
    public List <Character> Refresh(Scene scn)
    {
        LoadScnMark(scn.ScnID, scn.ScnList.markPath);
        List <excel_refresh> excels = ExcelLoader.LoadRefreshExcel(scn.ScnList.id);

        if (excels == null)
        {
            return(null);
        }
        return(RefreshList(scn));
    }
示例#14
0
    public static void ReloadExcel(string excelName, string[] files = null)
    {
        InitializeFactory();

        if (files != null)
        {
            filesNames[excelName] = files;
        }
        ExcelLoader.ParseConfig(excelName);

        UninitializeFactory();
    }
        public void Case01()
        {
            using (var cn = LocalDb.GetConnection(dbName))
            {
                CreateSchema(cn);

                var loader = new ExcelLoader();
                using (var stream = GetResource("case01.xlsx"))
                {
                    loader.SaveAsync(stream, cn, "upload", "Case01").Wait();
                }
            }
        }
示例#16
0
 private static Task <(Dictionary <string, string[]>, string[], Dictionary <string, string[]>)> loadLexicalFieldAsync()
 {
     (Dictionary <string, string[]>, string[], Dictionary <string, string[]>)result;
     try
     {
         result = ExcelLoader.LoadLexicalField(Helpers.GetExecutingDirectoryPath() + @"\Data\ChampsLexicaux.xlsx");
     }
     catch (Exception)
     {
         throw;
     }
     return(Task.FromResult(result));
 }
示例#17
0
    private List <IntegraDUExcel> ReestrSheet()
    {
        Excel.Worksheet WSSource = Globals.ThisAddIn.Application.Sheets["Реестр"];
        EnableCalculations(false);
        Globals.ThisAddIn.Application.CopyObjectsWithCells = true;
        ExcelLoader _excelLoader = new ExcelLoader(Globals.ThisAddIn.Application);

        _excelLoader.AttachRows(WSSource);
        return((from row in _excelLoader.Rows
                where row.UNIU != null
                orderby row.AddressObject, row.AddressHouse
                select row).ToList());
    }
示例#18
0
    private List <IntegraHouses> HouseSheet()
    {
        Excel.Worksheet WSSource = Globals.ThisAddIn.Application.Sheets["Дома"];
        EnableCalculations(false);
        Globals.ThisAddIn.Application.CopyObjectsWithCells = true;
        ExcelLoader _excelLoader = new ExcelLoader(Globals.ThisAddIn.Application);

        _excelLoader.AttachHouses(WSSource);
        return((from row in _excelLoader.Houses
                where row.UNOM != null &&
                !string.IsNullOrEmpty(row.UNOM.ToString())
                orderby row.Address
                select row).ToList());
    }
        public async Task BulkCopy()
        {
            using (var cn = LocalDb.GetConnection(dbName))
            {
                await cn.DropAllTablesAsync();

                using (var stream = GetResource("zipcode_us_geo_db.xlsx"))
                {
                    var loader = new ExcelLoader();
                    var result = await loader.BulkSaveAsync(stream, cn, "dbo", "ZipCodes", 1000);

                    Assert.IsTrue(result == 80_237);
                }
            }
        }
        public void ThenEachRowShouldCorrespondToTheDataInTheList()
        {
            SpreadsheetStream.Seek(0, SeekOrigin.Begin);

            var rows = ExcelLoader.LoadReadOnlyFromStream(SpreadsheetStream)
                       .ReadRows()
                       .ToArray();

            //The first row is the titles so we kip it
            for (int i = 1; i < rows.Length; i++)
            {
                rows[i].Any(x => x.ValueType == typeof(long) && x.Value == ToStore[i - 1].ID).Should().BeTrue();
                rows[i].Any(x => x.ValueType == typeof(string) && x.Value == ToStore[i - 1].Title).Should().BeTrue();
                rows[i].Any(x => x.ValueType == typeof(String) && x.Value == ToStore[i - 1].Author).Should().BeTrue();
            }
        }
示例#21
0
        private void PreLoadData()
        {
            var options = IdMsoPackage.GetOptions(ServiceProvider);

            if (options.OfficeApplication != OfficeApplication.NotSpecified &&
                options.OfficeVersion != OfficeVersion.NotSpecified)
            {
                Task.Run(() => ExcelLoader.GetIdsFromCache(options.OfficeVersion, options.OfficeApplication));
            }

            if (options.OfficeApplication != OfficeApplication.NotSpecified &&
                options.OfficeVersion != OfficeVersion.NotSpecified)
            {
                Task.Run((Action)(() => ImageLoader.GetMsoImagesFromCache(options.OfficeVersion)));
            }
        }
示例#22
0
    public static void ExportData(string exportPath, string savaPath)
    {
        //-- Load Excel
        ExcelLoader excel = new ExcelLoader(exportPath, 3, exportPath.GetFileNameWithoutExtend());
        //-- export
        JsonExporter exporter = new JsonExporter(excel);

        exporter.SaveToFile(savaPath + "/" + exportPath.GetFileNameWithoutExtend() + ".json", Encoding.UTF8);


        CSharpExporter csharp = new CSharpExporter(excel.Sheets[0], exportPath.GetFileNameWithoutExtend());

        csharp.CreatCSharpScript();
#if UNITY_EDITOR
        AssetDatabase.Refresh();
#endif
    }
示例#23
0
        public void 기본_동작_테스트()
        {
            using (var fileStream = new FileStream("mockupData.xlsx", FileMode.Open, FileAccess.Read))
            {
                var excelLoader = new ExcelLoader(fileStream);

                var firstSheet  = excelLoader.LoadNextSheet();
                var secondSheet = excelLoader.LoadNextSheet();

                // NOTE @sleepyrainyday 200216: 3번째 시트는 없으므로 null
                Assert.IsNull(excelLoader.LoadNextSheet());

                AreEqual(firstSheetProperties, firstSheet.Properties);
                AreEqual(firstSheetExpected, firstSheet.Sheet);

                AreEqual(secondSheetProperties, secondSheet.Properties);
                AreEqual(secondSheetExpected, secondSheet.Sheet);
            }
        }
示例#24
0
    static void CreateStateEditor()
    {
        if (mInstance != null)
        {
            mInstance.Close();
            mInstance = null;
            return;
        }
        mInstance = EditorWindow.GetWindow <StateEditor>(true, "状态编辑器");
        mInstance.Show();

        if (excel_state_group.excelView == null)
        {
            ExcelLoader.LoadSingleExcel("state_group");
        }
        if (excel_state_effect.excelView == null)
        {
            ExcelLoader.LoadSingleExcel("state_effect");
        }
    }
示例#25
0
        private void Button_SelectFolder_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new VistaFolderBrowserDialog();

            if (openFileDialog.ShowDialog() == false)
            {
                return;
            }

            ViewModel.Files.Clear();
            foreach (var file in Directory.GetFiles(openFileDialog.SelectedPath).Where(f => !Path.GetFileName(f).StartsWith("~$")))
            {
                ViewModel.Files.Add(new ImportEntry()
                {
                    IsSelected = false,
                    Path       = file,
                    Count      = ExcelLoader.LoadFileCount(file)
                });
            }
        }
示例#26
0
    void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("重复创建GameApp!");
            GameObject.Destroy(gameObject);
            return;
        }
        Instance = this;
        DontDestroyOnLoad(gameObject);
        GameObjectPool.Startup();

        UserName = "";
        Platform = Application.platform.ToString();
        DeviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
        DeviceModel            = SystemInfo.deviceModel;
        DeviceTypeStr          = SystemInfo.deviceType.ToString();

        Debug.Log("SystemInfo.deviceModel: " + SystemInfo.deviceModel);
        Debug.Log("SystemInfo.deviceName: " + SystemInfo.deviceName);
        Debug.Log("SystemInfo.deviceType: " + SystemInfo.deviceType.ToString());
        Debug.Log("SystemInfo.graphicsDeviceID: " + SystemInfo.graphicsDeviceID);
        Debug.Log("SystemInfo.graphicsDeviceName: " + SystemInfo.graphicsDeviceName);
        Debug.Log("SystemInfo.graphicsDeviceType: " + SystemInfo.graphicsDeviceType.ToString());
        Debug.Log("SystemInfo.graphicsDeviceVendor: " + SystemInfo.graphicsDeviceVendor);
        Debug.Log("SystemInfo.graphicsDeviceVendorID: " + SystemInfo.graphicsDeviceVendorID);
        Debug.Log("SystemInfo.graphicsDeviceVersion: " + SystemInfo.graphicsDeviceVersion);
        ScreenWidth  = Screen.width;
        ScreenHeight = Screen.height;

        // Net.Instance.HeadFormater = new CustomHeadFormater();
        ExcelLoader.Init();
        SkillEventRegister.Initialize();

        if (directGame)
        {
            SceneSystem.Instance.ChangeScene(SceneSystem.roomScnID);
            return;
        }
        SceneSystem.Instance.ChangeScene(SceneSystem.loginScnID);
    }
示例#27
0
        public void LoadsExcelFile()
        {
            const string FILE_NAME = @"..\..\..\file1.xlsx";

            var sut = new ExcelLoader();

            var result = sut.Load(FILE_NAME);

            Assert.AreEqual(9, result.RowCount); // number of *data* rows
            Assert.AreEqual(4, result.ColCount);
            CollectionAssert.AreEqual(new[] { "A", "B", "C", "D" }, result.Columns);
            CollectionAssert.AreEqual(new[] { "1", "10", "1", "100" }, result.Data[0]);
            CollectionAssert.AreEqual(new[] { "2", "20", "1", "200" }, result.Data[1]);
            CollectionAssert.AreEqual(new[] { "3", "30", "1", "300" }, result.Data[2]);
            CollectionAssert.AreEqual(new[] { "1", "40", "2", "400" }, result.Data[3]);
            CollectionAssert.AreEqual(new[] { "2", "50", "2", "500" }, result.Data[4]);
            CollectionAssert.AreEqual(new[] { "3", "60", "2", "600" }, result.Data[5]);
            CollectionAssert.AreEqual(new[] { "1", "70", "3", "700" }, result.Data[6]);
            CollectionAssert.AreEqual(new[] { "2", "80", "3", "800" }, result.Data[7]);
            CollectionAssert.AreEqual(new[] { "3", "90", "3", "900" }, result.Data[8]);
        }
示例#28
0
        public void MapExcelToDU1()
        {
            var counter       = 0;
            var counterLength = 100;
            var application   = new Excel.Application();
            var e             = new ExcelLoader(application);

            Excel.Workbook workbook  = application.Workbooks.Open("C:\\Temp\\Этап 2.xlsx");
            Excel.Workbook workbook2 = application.Workbooks.Open("C:\\Temp\\Этап 21.xlsx");
            //application.Visible = false;
            var reestr = workbook.Sheets["Реестр"];
            var result = e.MapRows(reestr);
            var gr     = ((IEnumerable <IntegraDU>)result).GroupBy(g => counter++ / counterLength);

            foreach (var g in gr)
            {
                e.MapRows(g.ToList(), workbook2.ActiveSheet);
                workbook2.Save();
            }
            application.Visible = true;
        }
        public void InlineLookup()
        {
            using (var cn = LocalDb.GetConnection(dbName, SampleLookupObjects()))
            {
                CreateRows(cn, "dbo.Region", "North", "South", "East", "West");
                CreateRows(cn, "dbo.Type", "Flavorful", "Oblong", "Interminable", "Gingersnap");

                var loader = new ExcelLoader();
                using (var xls = GetResource("inline-lookup.xlsx"))
                {
                    loader.SaveAsync(xls, cn, "dbo", "SalesDataRaw", new Options()
                    {
                        TruncateFirst = true
                    }).Wait();

                    var inlineLookup = new InlineLookup <int>("dbo.SalesDataRaw", "Id", "dbo.SalesDataKeyed", new Lookup[]
                    {
                        new Lookup("Region", "RegionId", "dbo.Region", "Name", "Id"),
                        new Lookup("Type", "TypeId", "dbo.Type", "Name", "Id")
                    });

                    inlineLookup.ExecuteAsync(cn).Wait();

                    // region Name + Id combos should be the same
                    var rawRegions   = cn.Query <NameId>("SELECT [Id], [Region] AS [Name] FROM [SalesDataRaw] ORDER BY [Id]");
                    var keyedRegions = cn.Query <NameId>("SELECT [d].[Id], [r].[Name] FROM [SalesDataKeyed] [d] INNER JOIN [Region] [r] ON [r].[Id]=[d].[RegionId] ORDER BY [d].[Id]");
                    Assert.IsTrue(rawRegions.SequenceEqual(keyedRegions));

                    // but there is deliberately one error where Type = Unknown
                    var errors = inlineLookup.GetErrorsAsync(cn).Result;
                    Assert.IsTrue(errors.Count == 1);
                    Assert.IsTrue(errors["Type"].SequenceEqual(new string[] { "Unknown" }));
                }
            }

            void CreateRows(SqlConnection cn, string tableName, params string[] names)
            {
                names.ToList().ForEach(name => cn.Execute($"INSERT INTO {tableName} ([Name]) VALUES (@name)", new { name }));
            }
        }
示例#30
0
        /// <summary>
        /// 加载Excel文件
        /// </summary>
        /// <param name="options">导入设置</param>
        public void loadExcel(Program.Options options)
        {
            _options = options;

            //-- Excel File
            string excelPath = options.excelPath;
            string excelName = Path.GetFileNameWithoutExtension(excelPath);

            HashSet <string> exportTags = new HashSet <string>();

            exportTags.Add("");
            if (options.exportTags != null)
            {
                var tags = options.exportTags.Split(',');
                foreach (var tag in tags)
                {
                    exportTags.Add(tag);
                }
            }

            //-- Encoding
            _encoding = new UTF8Encoding(false);

            //-- Load Excel
            ExcelLoader excel = new ExcelLoader(excelPath);

            //-- Parse Excel
            List <ExcelParser.TableInfo> tableInfos = ExcelParser.ReadSheetData(excel.Sheets[0]);

            //-- 导出 json
            _json = new JsonExporter(tableInfos, excelName, exportTags);

            //-- 导出 xml
            _xml = new XmlExporter(tableInfos, excelName, exportTags);

            //-- C# 结构体定义
            _csharp = new CSharpExporter(tableInfos, excelName, exportTags);
        }
示例#31
0
        private void ImportFromExcel()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect = false;
            openFileDialog.Title       = "选择数据源文件";
            openFileDialog.Filter      = "(*.xls,*.xlsx)|*.xls;*.xlsx;";
            //openFileDialog.ShowDialog();
            if (openFileDialog.ShowDialog() == DialogResult.OK && openFileDialog.CheckFileExists)
            {
                var excelLoader = new ExcelLoader();
                try
                {
                    var batch = excelLoader.Load(openFileDialog.FileName);
                    var form  = new ConfirmImportDataForm(batch);
                    form.ShowDialog();
                }
                catch (Exception exp)
                {
                    MessageBox.Show("无效文件", exp.Message);
                }
            }
        }
    public static void ProcessConvert()
    {
        FileStream stream = File.Open(Application.dataPath + PATH_EXCEL, FileMode.Open, FileAccess.Read);
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
        SkillDataSet skillDataSet = ScriptableObject.CreateInstance<SkillDataSet>();
        DataTable dataTable;
        ExcelLoader loader;

        if (excelReader.AsDataSet () != null)
        {
            dataTable = excelReader.AsDataSet().Tables["Skill"];
            loader = new ExcelLoader(dataTable);
            skillDataSet.skillDataSet = loader.CreateDataList<SkillData>();
            dataTable = excelReader.AsDataSet().Tables["Buff"];
            loader = new ExcelLoader(dataTable);
            skillDataSet.buffDataSet = loader.CreateDataList<BuffData>();
            dataTable = excelReader.AsDataSet().Tables["SkillEffect"];
            loader = new ExcelLoader(dataTable);
            skillDataSet.effectDataSet = loader.CreateDataList<SkillEffectData>();
            AssetDatabase.CreateAsset(skillDataSet, PATH_ASSET);
        }
        excelReader.Dispose ();
    }
        public void OpenXlsFile()
        {
            var pricesDirectory     = "prices";
            var filename            = "1236.xls";
            var path                = Settings.Default.TestDirectoryPath + pricesDirectory + Path.DirectorySeparatorChar + filename;
            List <DataTable> tables = ExcelLoader.LoadTables(path);

            Assert.That(tables.Count, Is.EqualTo(18));
            var table = tables.Where(t => t.TableName == "Лист1").FirstOrDefault();
            var rows  = table.Rows;

            Assert.That(rows.Count, Is.EqualTo(2));
            var    row   = rows[0];
            string value = Convert.ToString(row[0]);

            Assert.That(value, Is.EqualTo("Абилифай 15мг №28 табл."));
            value = Convert.ToString(row[1]);
            Assert.That(value, Is.EqualTo("6330"));
            row   = rows[1];
            value = Convert.ToString(row[0]);
            Assert.That(value, Is.EqualTo("Абитаксел - Тева д/инф. 100мг/16.7мл фл.№1"));
            value = Convert.ToString(row[1]);
            Assert.That(value, Is.EqualTo("11000="));
        }