Call GetDataToExport to get images of the graph, along with optional workbook contents, workbook settings, and GraphML.
AddAttachmentsAndAlternateHtml ( MailMessage oMailMessage, Microsoft.Office.Interop.Excel.Workbook oWorkbook, NodeXLControl oNodeXLControl, Boolean bExportWorkbookAndSettings, Boolean bExportGraphML, Boolean bUseFixedAspectRatio ) { Debug.Assert(oMailMessage != null); Debug.Assert(oWorkbook != null); Debug.Assert(oNodeXLControl != null); Debug.Assert(oNodeXLControl.ActualWidth >= GraphExporterUtil.MinimumNodeXLControlWidth); Debug.Assert(oNodeXLControl.ActualHeight >= GraphExporterUtil.MinimumNodeXLControlHeight); AssertValid(); String sSuggestedFileNameNoExtension = GetSuggestedFileNameNoExtension(oWorkbook); String sGraphMLFileNameNoExtension = sSuggestedFileNameNoExtension + "-GraphML"; Byte [] abtFullSizeImage, abtThumbnail, abtWorkbookContents, abtGraphMLZipped; String sWorkbookSettings; GraphExporterUtil.GetDataToExport(oWorkbook, oNodeXLControl, bExportWorkbookAndSettings, bExportGraphML, Path.ChangeExtension(sGraphMLFileNameNoExtension, "xml"), bUseFixedAspectRatio, out abtFullSizeImage, out abtThumbnail, out abtWorkbookContents, out sWorkbookSettings, out abtGraphMLZipped); AddAttachments(oMailMessage, sSuggestedFileNameNoExtension, sGraphMLFileNameNoExtension, abtFullSizeImage, abtWorkbookContents, sWorkbookSettings, abtGraphMLZipped); AddAlternateHtml(oMailMessage, abtFullSizeImage); }
ExportToNodeXLGraphGallery ( Microsoft.Office.Interop.Excel.Workbook workbook, NodeXLControl nodeXLControl, String title, String description, String spaceDelimitedTags, String author, String password, Boolean exportWorkbookAndSettings, Boolean exportGraphML, Boolean useFixedAspectRatio ) { Debug.Assert(workbook != null); Debug.Assert(nodeXLControl != null); Debug.Assert(nodeXLControl.ActualWidth >= GraphExporterUtil.MinimumNodeXLControlWidth); Debug.Assert(nodeXLControl.ActualHeight >= GraphExporterUtil.MinimumNodeXLControlHeight); Debug.Assert(!String.IsNullOrEmpty(title)); Debug.Assert(!String.IsNullOrEmpty(author)); AssertValid(); Byte [] abtFullSizeImage, abtThumbnail, abtWorkbookContents, abtGraphML; String sWorkbookSettings; // Note that the name of the Zipped GraphML is not important. When a // user downloads the GraphML from the Graph Gallery website, the // website will rename the GraphML before giving it to the user. GraphExporterUtil.GetDataToExport(workbook, nodeXLControl, exportWorkbookAndSettings, exportGraphML, "GraphML.xml", useFixedAspectRatio, out abtFullSizeImage, out abtThumbnail, out abtWorkbookContents, out sWorkbookSettings, out abtGraphML); NodeXLGraphGalleryServiceClient oClient = new NodeXLGraphGalleryServiceClient(GetWcfServiceBinding(), new EndpointAddress( ProjectInformation.NodeXLGraphGalleryWcfServiceUrl) ); oClient.Endpoint.Binding.SendTimeout = new TimeSpan(0, SendTimeoutMinutes, 0); try { oClient.AddGraph4(title, author, password, description, spaceDelimitedTags, abtFullSizeImage, abtThumbnail, abtWorkbookContents, sWorkbookSettings, abtGraphML); } catch (ProtocolException oProtocolException) { // The following text search detects an exception thrown by the WCF // service when the exported byte count exceeds the maximum that // can be handled by the WCF service. // // This isn't a very robust test. Is there a better way to do // it? An earlier version attempted to calculate the number of // bytes that would be exported before attempting to export them, // but it didn't seem to be doing so accurately. // // See the MaximumBytes constant for more details. if (oProtocolException.Message.IndexOf("(400) Bad Request") >= 0) { throw new GraphTooLargeException(); } throw (oProtocolException); } }