コード例 #1
0
        private string SaveWorkbook()
        {
            string filename = Utilities.GetTemporaryFileWithExtension("wwb");
            Workbook workbook = new Workbook();
            workbook.Open(filename);

            foreach (ListViewItem lvi in listViewFiles.Items)
            {
                WorkbookItem wbi = lvi.Tag as WorkbookItem;
                workbook.AddWorkbookItem(wbi);
            }
            workbook.Save();
            return filename;
        }
コード例 #2
0
ファイル: Utilities.cs プロジェクト: killbug2004/WSProf
        public static List<WorkbookItem> ResolveWorkbookItemsFromWorkbook(string filename)
        {
            Workbook workbook = new Workbook();
            workbook.Open(filename);
            List<WorkbookItem> unresolvedWorkbookItems = workbook.GetWorkbookItems();
			List<WorkbookItem> resolvedWorkbookItems = new List<WorkbookItem>();

			if (unresolvedWorkbookItems.Count > 0)
			{
				DocumentProviderProxy docprov = new DocumentProviderProxy();

				foreach (WorkbookItem item in unresolvedWorkbookItems)
				{
					try
					{
						tagWSDOCUMENT wsdoc = docprov.GetDocument(item.DocumentId);
						WorkbookItem newItem = new WorkbookItem(wsdoc)
						{
							PageSelection = item.PageSelection,
							PdfSecurityOptions = item.PdfSecurityOptions
						};
						resolvedWorkbookItems.Add(newItem);
					}
					catch (System.Runtime.InteropServices.COMException e)
					{
						string error = docprov.GetErrorDescription(e.ErrorCode) ;
						
						error = string.IsNullOrEmpty(error)
						        	? "Failed to resolve document in workbook: " + Environment.NewLine + "[" + e.Message + "]"
						        	: error;

						error += Environment.NewLine + Environment.NewLine + "Document: " + item.DocumentId;

						WsMessage.ShowMessage(IntPtr.Zero, error, MessageButtons.WsOK, MessageBranding.WsDefault, MessageType.WsErrorIcon, "", -1);
					}
				}
			}
            return resolvedWorkbookItems;
        }