Smrf.NodeXL.ExcelTemplate.ApplicationUtil.TryGetTemplatePath C# (CSharp) Method

TryGetTemplatePath() public static method

public static TryGetTemplatePath ( String &templatePath ) : System.Boolean
templatePath String
return System.Boolean
    TryGetTemplatePath
    (
        out String templatePath
    )
    {
        String sTemplateFolderPath;

        if (RunningInDevelopmentEnvironment)
        {
            // Samples, depending on which program is being run:
            //
            //   1. "C:\NodeXL\ExcelTemplate\bin\Debug"
            //
            //   2. "C:\NodeXL\NetworkServer\bin\Debug"
            //
            //   3. "C:\NodeXL\GraphMLFileProcessor\bin\Debug"

            sTemplateFolderPath = Path.GetDirectoryName(
                GetExecutingAssemblyPath() );

            // The template in the development environment is under the
            // ExcelTemplate folder.  For cases 2 and 3, fix the folder.

            const String ExcelTemplateFolderName = "ExcelTemplate";

            sTemplateFolderPath = sTemplateFolderPath.Replace(
                "NetworkServer", ExcelTemplateFolderName);

            sTemplateFolderPath = sTemplateFolderPath.Replace(
                "GraphMLFileProcessor", ExcelTemplateFolderName);
        }
        else
        {
            // The deployment process puts the template file in a subfolder of
            // the deployment folder.

            sTemplateFolderPath = Path.Combine(
                GetApplicationFolder(),
                ProjectInformation.ExcelTemplateSubfolder
                );
        }

        templatePath = Path.Combine(
            sTemplateFolderPath, ProjectInformation.ExcelTemplateName);

        return ( File.Exists(templatePath) );
    }

Usage Example

Ejemplo n.º 1
0
        ExportSelectionToNewNodeXLWorkbook()
        {
            AssertValid();

            // Get the path to the application's template.

            String sTemplatePath;

            if (!ApplicationUtil.TryGetTemplatePath(out sTemplatePath))
            {
                throw new ExportWorkbookException(
                          ApplicationUtil.GetMissingTemplateMessage());
            }

            Workbook oNewNodeXLWorkbook = null;

            CopyTableToNewNodeXLWorkbook(WorksheetNames.Edges,
                                         TableNames.Edges, sTemplatePath, ref oNewNodeXLWorkbook);

            CopyTableToNewNodeXLWorkbook(WorksheetNames.Vertices,
                                         TableNames.Vertices, sTemplatePath, ref oNewNodeXLWorkbook);

            if (oNewNodeXLWorkbook == null)
            {
                throw new ExportWorkbookException(
                          "There are no selected edges or vertices to export to a new"
                          + " workbook."
                          );
            }

            return(oNewNodeXLWorkbook);
        }
All Usage Examples Of Smrf.NodeXL.ExcelTemplate.ApplicationUtil::TryGetTemplatePath