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
コード例 #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);
            }
        }
コード例 #2
0
        ImportGraphMLFilesInternal
        (
            ImportGraphMLFilesAsyncArgs oImportGraphMLFilesAsyncArgs,
            BackgroundWorker oBackgroundWorker,
            DoWorkEventArgs oDoWorkEventArgs
        )
        {
            Debug.Assert(oImportGraphMLFilesAsyncArgs != null);
            Debug.Assert(oBackgroundWorker != null);
            Debug.Assert(oDoWorkEventArgs != null);
            AssertValid();

            Int32 iGraphMLFiles = 0;

            foreach (String sGraphMLFilePath in Directory.GetFiles(
                         oImportGraphMLFilesAsyncArgs.SourceFolderPath, "*.graphml"))
            {
                if (oBackgroundWorker.CancellationPending)
                {
                    oDoWorkEventArgs.Cancel = true;
                    return;
                }

                String sGraphMLFileName = Path.GetFileName(sGraphMLFilePath);

                oBackgroundWorker.ReportProgress(0,
                                                 String.Format(
                                                     "Importing \"{0}\"."
                                                     ,
                                                     sGraphMLFileName
                                                     ));

                XmlDocument oGraphMLDocument = new XmlDocument();

                try
                {
                    oGraphMLDocument.Load(sGraphMLFilePath);
                }
                catch (XmlException oXmlException)
                {
                    OnXmlException(sGraphMLFileName, oXmlException);
                    continue;
                }

                String sNodeXLWorkbookPath = Path.Combine(
                    oImportGraphMLFilesAsyncArgs.DestinationFolderPath,
                    sGraphMLFileName
                    );

                sNodeXLWorkbookPath = Path.ChangeExtension(sNodeXLWorkbookPath,
                                                           ".xlsx");

                try
                {
                    GraphMLToNodeXLWorkbookConverter.SaveGraphToNodeXLWorkbook(
                        oGraphMLDocument, sGraphMLFilePath, sNodeXLWorkbookPath,
                        null, false);
                }
                catch (XmlException oXmlException)
                {
                    OnXmlException(sGraphMLFileName, oXmlException);
                    continue;
                }

                iGraphMLFiles++;
            }

            oBackgroundWorker.ReportProgress(0,
                                             String.Format(
                                                 "Done.  GraphML files imported: {0}."
                                                 ,
                                                 iGraphMLFiles
                                                 ));
        }