ConvertExcelFilesToJson() public method

Converts all excel files in the input folder to json and saves them in the output folder. Each sheet within an excel file is saved to a separate json file with the same name as the sheet name. Files, sheets and columns whose name begin with '~' are ignored.
public ConvertExcelFilesToJson ( string inputPath, string outputPath, bool recentlyModifiedOnly = false ) : void
inputPath string Input path.
outputPath string Output path.
recentlyModifiedOnly bool If set to true, will only process recently modified files only.
return void
    /// <summary>
    /// Class attribute [InitializeOnLoad] triggers calling the static constructor on every refresh.
    /// </summary>
    static ExcelToJsonAutoConverter()
    {
        string inputPath = EditorPrefs.GetString(ExcelToJsonConverterWindow.kExcelToJsonConverterInputPathPrefsName, Application.dataPath);
        string outputPath = EditorPrefs.GetString(ExcelToJsonConverterWindow.kExcelToJsonConverterOuputPathPrefsName, Application.dataPath);
        bool onlyModifiedFiles = EditorPrefs.GetBool(ExcelToJsonConverterWindow.kExcelToJsonConverterModifiedFilesOnlyPrefsName, false);

        ExcelToJsonConverter excelProcessor = new ExcelToJsonConverter();
        excelProcessor.ConvertExcelFilesToJson(inputPath, outputPath, onlyModifiedFiles);
    }
示例#2
0
    /// <summary>
    /// Processes the excel files.
    /// </summary>
    private static void ProcessExcelFiles()
    {
        ExcelToJsonConverter excelProcessor = new ExcelToJsonConverter();

        excelProcessor.ConversionToJsonSuccessfull += ExcelSuccessCallback;
        excelProcessor.ConvertExcelFilesToJson(EditorPrefs.GetString(ExcelToJsonConverterWindow.kExcelToJsonConverterInputPathPrefsName, Application.dataPath),
                                               EditorPrefs.GetString(ExcelToJsonConverterWindow.kExcelToJsonConverterOuputPathPrefsName, Application.dataPath),
                                               false);
    }
    /// <summary>
    /// Class attribute [InitializeOnLoad] triggers calling the static constructor on every refresh.
    /// </summary>
    static ExcelToJsonAutoConverter()
    {
        var inputPath         = EditorPrefs.GetString(ExcelToJsonConverterWindow.ExcelToJsonConverterInputPathPrefsName, Application.dataPath);
        var outputPath        = EditorPrefs.GetString(ExcelToJsonConverterWindow.ExcelToJsonConverterOutputPathPrefsName, Application.dataPath);
        var onlyModifiedFiles = EditorPrefs.GetBool(ExcelToJsonConverterWindow.ExcelToJsonConverterModifiedFilesOnlyPrefsName, false);

        var excelProcessor = new ExcelToJsonConverter();

        excelProcessor.ConvertExcelFilesToJson(inputPath, outputPath, onlyModifiedFiles);
    }
示例#4
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();

        GUIContent inputFolderContent = new GUIContent("Input Folder", "Select the folder where the excel files to be processed are located.");

        EditorGUIUtility.labelWidth = 120.0f;
        EditorGUILayout.TextField(inputFolderContent, _inputPath, GUILayout.MinWidth(120), GUILayout.MaxWidth(500));
        if (GUILayout.Button(new GUIContent("Select Folder"), GUILayout.MinWidth(80), GUILayout.MaxWidth(100)))
        {
            _inputPath = EditorUtility.OpenFolderPanel("Select Folder with Excel Files", _inputPath, Application.dataPath);
        }

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        GUIContent outputFolderContent = new GUIContent("Output Folder", "Select the folder where the converted json files should be saved.");

        EditorGUILayout.TextField(outputFolderContent, _outputPath, GUILayout.MinWidth(120), GUILayout.MaxWidth(500));
        if (GUILayout.Button(new GUIContent("Select Folder"), GUILayout.MinWidth(80), GUILayout.MaxWidth(100)))
        {
            _outputPath = EditorUtility.OpenFolderPanel("Select Folder to save json files", _outputPath, Application.dataPath);
        }

        GUILayout.EndHorizontal();

        GUIContent modifiedToggleContent = new GUIContent("Modified Files Only", "If checked, only excel files which have been newly added or updated since the last conversion will be processed.");

        _onlyModifiedFiles = EditorGUILayout.Toggle(modifiedToggleContent, _onlyModifiedFiles);

        if (string.IsNullOrEmpty(_inputPath) || string.IsNullOrEmpty(_outputPath))
        {
            GUI.enabled = false;
        }

        GUILayout.BeginArea(new Rect((Screen.width / 2) - (200 / 2), (Screen.height / 2) - (25 / 2), 200, 25));

        if (GUILayout.Button("Convert Excel Files"))
        {
            _excelProcessor.ConvertExcelFilesToJson(_inputPath, _outputPath, _onlyModifiedFiles);
            AssetDatabase.Refresh();
        }

        GUILayout.EndArea();

        GUI.enabled = true;
    }
 /// <summary>
 /// Processes the excel files.
 /// </summary>
 private static void ProcessExcelFiles()
 {
     ExcelToJsonConverter excelProcessor = new ExcelToJsonConverter();
     excelProcessor.ConversionToJsonSuccessfull += ExcelSuccessCallback;
     excelProcessor.ConvertExcelFilesToJson(EditorPrefs.GetString(ExcelToJsonConverterWindow.kExcelToJsonConverterInputPathPrefsName, Application.dataPath),
                                      EditorPrefs.GetString(ExcelToJsonConverterWindow.kExcelToJsonConverterOuputPathPrefsName, Application.dataPath),
                                      false);
 }