//シートの読み込み
		static StringGrid ReadSheet(ISheet sheet, string path)
		{
			int lastRowNum = sheet.LastRowNum;

			StringGrid grid = new StringGrid(path + ":" + sheet.SheetName, CsvType.Tsv);
			for (int rowIndex = sheet.FirstRowNum; rowIndex <= lastRowNum; ++rowIndex)
			{
				IRow row = sheet.GetRow(rowIndex);

				List<string> stringList = new List<string>();
				if (row != null)
				{
					foreach (var cell in row.Cells)
					{
						for (int i = stringList.Count; i < cell.ColumnIndex; ++i)
						{
							stringList.Add("");
						}
						stringList.Add(cell.ToString());
					}
				}
				grid.AddRow(stringList);
			}
			grid.ParseHeader();
			return grid;
		}
Beispiel #2
0
        //シートの読み込み
        static StringGrid ReadSheet(ISheet sheet, string path)
        {
            int lastRowNum = sheet.LastRowNum;

            StringGrid grid = new StringGrid(path + ":" + sheet.SheetName, sheet.SheetName, CsvType.Tsv);

            for (int rowIndex = sheet.FirstRowNum; rowIndex <= lastRowNum; ++rowIndex)
            {
                IRow row = sheet.GetRow(rowIndex);

                List <string> stringList = new List <string>();
                if (row != null)
                {
                    foreach (var cell in row.Cells)
                    {
                        for (int i = stringList.Count; i < cell.ColumnIndex; ++i)
                        {
                            stringList.Add("");
                        }
                        stringList.Add(cell.ToString());
                    }
                }
                grid.AddRow(stringList);
            }
            grid.ParseHeader();
            return(grid);
        }
Beispiel #3
0
        //シートの読み込み
        static StringGrid ReadSheet(ISheet sheet, string path, char ignoreSheetMark, bool parseFormula)
        {
            int lastRowNum = sheet.LastRowNum;

            StringGrid grid = new StringGrid(path + ":" + sheet.SheetName, sheet.SheetName, CsvType.Tsv);

            if (sheet.SheetName.Length > 0 && sheet.SheetName[0] == ignoreSheetMark)
            {
                return(grid);
            }

            for (int rowIndex = sheet.FirstRowNum; rowIndex <= lastRowNum; ++rowIndex)
            {
                IRow row = sheet.GetRow(rowIndex);

                List <string> stringList = new List <string>();
                if (row != null)
                {
                    foreach (var cell in row.Cells)
                    {
                        for (int i = stringList.Count; i < cell.ColumnIndex; ++i)
                        {
                            stringList.Add("");
                        }
                        if (parseFormula)
                        {
                            try
                            {
                                switch (cell.CellType)
                                {
                                case CellType.Formula:
                                case CellType.String:
                                    stringList.Add(cell.StringCellValue);
                                    break;

                                default:
                                    stringList.Add(cell.ToString());
                                    break;
                                }
                            }
                            catch (System.Exception e)
                            {
                                Debug.LogError(e.Message);
                                stringList.Add(cell.ToString());
                            }
                        }
                        else
                        {
                            stringList.Add(cell.ToString());
                        }
                    }
                }
                grid.AddRow(stringList);
            }
            grid.ParseHeader();
            return(grid);
        }
            StringGrid MakeScenarioSettingGrid(int version)
            {
                StringGrid grid = new StringGrid(AdvSheetParser.SheetNameScenario, AdvSheetParser.SheetNameScenario, CsvType.Tsv);

                grid.AddRow(new List <string> {
                    AdvParser.Localize(AdvColumnName.FileName), AdvParser.Localize(AdvColumnName.Version)
                });
                grid.ParseHeader();

                foreach (var sheet in ScenarioSheets)
                {
                    grid.AddRow(new List <string> {
                        this.Name + "/Scenario/" + sheet.SheetName, "" + version
                    });
                }
                return(grid);
            }
//#if UNITY_EDITOR

        /// <summary>
        /// エクセルからCSVファイルにコンバートする際に、シナリオ設定データをマージして作成する
        /// </summary>
        /// <param name="grid">シナリオ設定データ</param>
        /// <param name="scenarioSheetDictionary">シナリオデータ</param>
        /// <returns>マージしたシナリオ設定データ</returns>
        public static StringGrid MargeScenarioData(StringGrid grid, StringGridDictionary scenarioSheetDictionary, int version)
        {
            if (grid == null)
            {
                grid = new StringGrid(AdvSettingDataManager.SheetNameScenario, CsvType.Tsv);
                grid.AddRow(new List <string> {
                    AdvParser.Localize(AdvColumnName.FileName), AdvParser.Localize(AdvColumnName.Version)
                });
                grid.ParseHeader();
            }

            List <string> addScnenarioList = new List <string>();

            foreach (string sheetName in scenarioSheetDictionary.Keys)
            {
                bool isFind = false;
                foreach (StringGridRow row in grid.Rows)
                {
                    if (AdvParser.ParseCell <string>(row, AdvColumnName.FileName) == sheetName)
                    {
                        isFind = true;
                    }
                }
                if (!isFind)
                {
                    addScnenarioList.Add(sheetName);
                }
            }
            foreach (string sheetName in addScnenarioList)
            {
                grid.AddRow(new List <string> {
                    sheetName, "" + version
                });
            }
            return(grid);
        }