Smrf.NodeXL.ExcelTemplate.GraphMLToNodeXLWorkbookConverter.SaveGraphToNodeXLWorkbook C# (CSharp) Method

SaveGraphToNodeXLWorkbook() public static method

public static SaveGraphToNodeXLWorkbook ( XmlDocument graphMLDocument, String graphMLFilePath, String nodeXLWorkbookPath, String nodeXLWorkbookSettingsFilePath, System.Boolean setAutomateTasksOnOpen ) : void
graphMLDocument System.Xml.XmlDocument
graphMLFilePath String
nodeXLWorkbookPath String
nodeXLWorkbookSettingsFilePath String
setAutomateTasksOnOpen System.Boolean
return void
    SaveGraphToNodeXLWorkbook
    (
        XmlDocument graphMLDocument,
        String graphMLFilePath,
        String nodeXLWorkbookPath,
        String nodeXLWorkbookSettingsFilePath,
        Boolean setAutomateTasksOnOpen
    )
    {
        Debug.Assert(graphMLDocument != null);

        Debug.Assert(nodeXLWorkbookPath == null ||
            nodeXLWorkbookPath.Length > 0);

        // Open Excel.

        Application oExcelApplication = new Application();

        if (oExcelApplication == null)
        {
            throw new ConvertGraphMLToNodeXLWorkbookException(
                ErrorCode.CouldNotOpenExcel,
                "Excel couldn't be opened.  Is it installed on this computer?"
                );
        }

        // ExcelApplicationKiller requires that the application be visible.

        oExcelApplication.Visible = true;

        // Suppress alerts about overwriting an existing file.

        oExcelApplication.DisplayAlerts = false;

        ExcelApplicationKiller oExcelApplicationKiller =
            new ExcelApplicationKiller(oExcelApplication);

        try
        {
            SaveGraphToNodeXLWorkbook(graphMLDocument, graphMLFilePath,
                nodeXLWorkbookPath, nodeXLWorkbookSettingsFilePath,
                setAutomateTasksOnOpen, oExcelApplication);
        }
        finally
        {
            if (nodeXLWorkbookPath != null)
            {
                oExcelApplication.Quit();

                // Quitting the Excel application does not remove it from
                // memory.  Kill its process.

                oExcelApplicationKiller.KillExcelApplication();
            }
        }
    }

Same methods

GraphMLToNodeXLWorkbookConverter::SaveGraphToNodeXLWorkbook ( XmlDocument oGraphMLDocument, String sGraphMLFilePath, String sNodeXLWorkbookPath, String sNodeXLWorkbookSettingsFilePath, System.Boolean bSetAutomateTasksOnOpen, Application oExcelApplication ) : void

Usage Example

コード例 #1
0
        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);
            }
        }
All Usage Examples Of Smrf.NodeXL.ExcelTemplate.GraphMLToNodeXLWorkbookConverter::SaveGraphToNodeXLWorkbook