Exemple #1
0
    /*
     *
     * static void Main (string[] args)
     * {
     *      // Excelのブックを作成
     *      var book = new HSSFWorkbook ();
     *
     *      // シートを作成
     *      var sheet = book.CreateSheet ("何とかレポート");
     *
     *      // ヘッダーにあたる行を作成
     *      CreateHeaderRow (book, sheet);
     *
     *
     *      //`AssetBudleDataChecker.CreateHeaderRow(NPOI.HSSF.UserModel.HSSFWorkbook, NPOI.HSSF.UserModel.HSSFSheet)' has some invalid arguments
     *
     *
     *      // とりあえず10行くらいデータ作成
     *      foreach (var index in Enumerable.Range(1, 10)) {
     *              CreateRow (book, sheet, index);
     *      }
     *
     *      // 2列目と3列目は、そのままだと幅が足りないので広げる(256で1文字ぶんの幅らしい)
     *      sheet.SetColumnWidth (1, 256 * 12);
     *      sheet.SetColumnWidth (2, 256 * 15);
     *
     *      // output.xlsに保存
     *      using (var fs = new FileStream ("otuput.xls", FileMode.OpenOrCreate, FileAccess.Write)) {
     *              book.Write (fs);
     *      }
     * }
     *
     *
     * // ヘッダー行を作成する
     * private static void CreateHeaderRow (HSSFWorkbook book, HSSFSheet sheet)
     * {
     *      var row = sheet.CreateRow (0);
     *
     *      // 0列目はIDの列
     *      var idCell = row.CreateCell (0);
     *      idCell.SetCellValue ("ID");
     *
     *      // 1列目は名前の列
     *      var nameCell = row.CreateCell (1);
     *      nameCell.SetCellValue ("名前");
     *
     *      // 3列目は誕生日の列
     *      var birthdayCell = row.CreateCell (2);
     *      birthdayCell.SetCellValue ("誕生日");
     *
     *      // 4方に罫線
     *      var style = book.CreateCellStyle ();
     *      style.BorderTop = HSSFBorderFormatting.BORDER_THIN;
     *      style.BorderLeft = HSSFBorderFormatting.BORDER_THIN;
     *      style.BorderBottom = HSSFBorderFormatting.BORDER_THIN;
     *      style.BorderRight = HSSFBorderFormatting.BORDER_THIN;
     *
     *      // 薄いグリーンの背景色で塗りつぶす
     *      style.FillForegroundColor = HSSFColor.LIGHT_GREEN.index;
     *      style.FillPattern = HSSFCellStyle.SOLID_FOREGROUND;
     *      // テキストはセンタリング
     *      style.Alignment = HSSFCellStyle.ALIGN_CENTER;
     *
     *      // 太字
     *      var font = book.CreateFont ();
     *      font.Boldweight = HSSFFont.BOLDWEIGHT_BOLD;
     *      style.SetFont (font);
     *
     *      // 全てのヘッダー用のセルに、上で作ったスタイルを適用する
     *      foreach (var cell in new[] { idCell, nameCell, birthdayCell }) {
     *              cell.CellStyle = style;
     *      }
     *
     * }
     *
     * private static System.Random r = new System.Random ();
     *
     * // index行目のデータを作る
     * private static void CreateRow (HSSFWorkbook book, HSSFSheet sheet, int index)
     * {
     *      // 行を作って
     *      var row = sheet.CreateRow (index);
     *
     *      // id列を作る
     *      var idCell = row.CreateCell (0);
     *      idCell.SetCellValue (index);
     *
     *      // 名前も適当に入れて
     *      var nameCell = row.CreateCell (1);
     *      nameCell.SetCellValue ("田中 太郎" + index);
     *
     *      // 誕生日も適当に
     *      var birthdayCell = row.CreateCell (2);
     *      birthdayCell.SetCellValue (DateTime.Now.AddYears (r.Next (10)));
     *
     *      // 全ての列に4方に罫線のあるスタイルを作って適用する
     *      // あえて別々のスタイルを設定してるのは、誕生日セルにフォーマットを入れるため
     *      foreach (var cell in new[] { idCell, nameCell, birthdayCell }) {
     *              var style = book.CreateCellStyle ();
     *              style.BorderTop = HSSFBorderFormatting.BORDER_THIN;
     *              style.BorderRight = HSSFBorderFormatting.BORDER_THIN;
     *              style.BorderLeft = HSSFBorderFormatting.BORDER_THIN;
     *              style.BorderBottom = HSSFBorderFormatting.BORDER_THIN;
     *
     *              cell.CellStyle = style;
     *      }
     *      // 日付用yyyy年mm月dd日のフォーマットで誕生日は表示するようにする
     *      var format = book.CreateDataFormat ();
     *      birthdayCell.CellStyle.DataFormat = format.GetFormat ("yyyy年mm月dd日");
     * }
     *
     *
     */


    //##################################################
    // Loading
    //##################################################

    //private static readonly string filePath = "Assets/00_AssetBundleData/Resources/Admini/AssetBundleData.xls";
    //private static readonly string exportPath = "Assets/00_AssetBundleData/Resources/Admini/AssetBundleData.asset";


    static AssetBundleData LoadCheckData()
    {
        //	if (!filePath.Equals (asset))
        //		continue;

        AssetBundleData data = (AssetBundleData)AssetDatabase.LoadAssetAtPath(SystemSetting.GetAdminAssetPath(), typeof(AssetBundleData));

        Debug.LogWarning("###### SystemSetting.GetAdminAssetPath() :" + SystemSetting.GetAdminAssetPath());

        return(data);


        //AssetBundleData data = (AssetBundleData)AssetDatabase.LoadAssetAtPath (SystemSetting.GetAdminAssetPath(), typeof(AssetBundleData));

        if (data == null)
        {
            data = ScriptableObject.CreateInstance <AssetBundleData> ();
            AssetDatabase.CreateAsset((ScriptableObject)data, SystemSetting.GetAdminAssetPath());
            data.hideFlags = HideFlags.NotEditable;
        }

        data.list.Clear();

        using (FileStream stream = File.Open(SystemSetting.GetAdminExcelPath(), FileMode.Open, FileAccess.Read)) {
            IWorkbook book = new HSSFWorkbook(stream);

            ISheet sheet = book.GetSheet("AssetList");

            ////Debug.Log (sheet.SheetName);

            for (int i = 1; i < sheet.LastRowNum; i++)
            {
                IRow row = sheet.GetRow(i);

                AssetBundleData.Param p = new AssetBundleData.Param();



                p.assetbundleName = row.GetCell(0).StringCellValue;
                p.version         = (int)row.GetCell(1).NumericCellValue;
                p.type            = (int)row.GetCell(2).NumericCellValue;


                int tmpUpdate = (int)row.GetCell(3).NumericCellValue;

                if (tmpUpdate == 1)
                {
                    p.update = true;
                }
                else
                {
                    p.update = false;
                }

                p.folderName = row.GetCell(5).StringCellValue;
                data.list.Add(p);


                //data.waveParamlist.Add (p);
            }


            return(data);
        }



//		ScriptableObject obj = AssetDatabase.LoadAssetAtPath (exportPath, typeof(ScriptableObject)) as ScriptableObject;
//		EditorUtility.SetDirty (obj);//
        //	}
    }