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

OpenSampleNodeXLWorkbook() public static method

public static OpenSampleNodeXLWorkbook ( ) : void
return void
    OpenSampleNodeXLWorkbook()
    {
        // To create the sample workbook, an empty NodeXL workbook is created
        // from the NodeXL template, and then a GraphML file containing the
        // sample data is imported into it.  It would be simpler to just
        // distribute a complete sample workbook with NodeXL, but that workbook
        // would have to be updated every time the NodeXL template changes.
        // This way, the latest template is always used.

        String sSampleNodeXLWorkbookSubfolderPath = Path.Combine(
            GetApplicationFolder(), SampleNodeXLWorkbookSubfolder);

        XmlDocument oGraphMLDocument = new XmlDocument();

        try
        {
            oGraphMLDocument.Load( Path.Combine(
                sSampleNodeXLWorkbookSubfolderPath,
                SampleNodeXLWorkbookAsGraphMLFileName) );
        }
        catch (Exception oException)
        {
            ErrorUtil.OnException(oException);
            return;
        }

        // The sample workbook data contains placeholders for the path to the
        // image files used in the workbook.  Replace those placeholders with a
        // real image path.

        String sImagePath = Path.Combine(sSampleNodeXLWorkbookSubfolderPath,
            SampleNodeXLWorkbookImageSubfolder);

        oGraphMLDocument.LoadXml( oGraphMLDocument.OuterXml.Replace(
            SampleNodeXLWorkbookImagePlaceholder, sImagePath) );

        try
        {
            GraphMLToNodeXLWorkbookConverter.SaveGraphToNodeXLWorkbook(
                oGraphMLDocument, null, null, null, false);
        }
        catch (ConvertGraphMLToNodeXLWorkbookException
            oConvertGraphMLToNodeXLWorkbookException)
        {
            FormUtil.ShowWarning(
                oConvertGraphMLToNodeXLWorkbookException.Message);
        }
    }