office-interop

How to make this custom worksheet initialization faster?

匆匆过客 提交于 2019-12-31 05:12:28
问题 Summary This question is somehow the follow-up to this question: How to implement column self-naming from its index? Having tested the code provided in this above-linked question's answers, I finally encountered a serious performance issue. Performance issue The performance issue occurs upon a Sheet initialization, that is, when I initialize the Sheet's Cells. ''' <summary> ''' Initialize an instance of the Company.Project.Sheet class. ''' </summary> ''' <param name="nativeSheet">The native

Microsoft Interop saveAs command failed

五迷三道 提交于 2019-12-31 03:04:38
问题 I have this simple console app that converts Word documents to PDF using Microsoft Office Interop API. For some reason, this one document always fails and I have attached it and removed all extraneous content: click here For some reason, it works fine when you open the document and perform the saveAs function in Word, but through code, it fails. I've tried SaveAs2, SaveAs and ExportAsFixedFormat methods. I'm running Office 2010 and using Microsoft Word 14.0 Object Library. Thanks. My C# code

Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

早过忘川 提交于 2019-12-30 07:09:28
问题 I am trying to convert docx file into pdf and I have been successful to convert pdf on my local pc. Steps which i have followed in visual studio 2010 is to click on Add reference --> Click to COM -->select "Microsoft Word 12.0 Object Library" and cliked ok My web config gets modified and added the assembly <add assembly="Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/> My .cs code for converting doc to pdf is using Microsoft.Office.Interop

Outlook Filter Items - Get all recurring appointments in a week range

扶醉桌前 提交于 2019-12-30 07:07:05
问题 I'm trying to get all appointments in outlook in week range, but reoccurring appointments are not showing up. Here is the code: var outlook = new Microsoft.Office.Interop.Outlook.Application(); var calendar = outlook.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); calendar.Items.IncludeRecurrences = true; string filter = String.Format("[Start] >= {0} And [End] < {1}", DateTime.Now.Date.ToString("ddddd h:nn AMPM"), DateTime.Now.Date.AddDays(5).ToString("ddddd h

How to raise an event on MS word Keypress

纵饮孤独 提交于 2019-12-29 07:47:28
问题 I am developing a MS-Word addon in which my code has to get access to the letters the user is entering through the keyboard. private void ThisDocument_Startup(object sender, System.EventArgs e) { this.SelectionChange += new SelectionEventHandler(ThisDocument_SelectionChange); } void ThisDocument_SelectionChange(object sender, SelectionEventArgs e) { MessageBox.Show(e.Selection.Text); } I think the SelectionChange event can give me the text but the event is not raised at keypress, Is there any

C# Excel Interop Slow when looping through cells

做~自己de王妃 提交于 2019-12-29 04:54:11
问题 I am trying to extract all text data from an Excel document in C# and am having performance issues. In the following code I open the Workbook, loop over all worksheets, and loop over all cells in the used range, extracting the text from each cell as I go. The problem is, this takes 14 seconds to execute. public class ExcelFile { public string Path = @"C:\test.xlsx"; private Excel.Application xl = new Excel.Application(); private Excel.Workbook WB; public string FullText; private Excel.Range

Reading Outlook Mail with C#

我是研究僧i 提交于 2019-12-29 04:42:08
问题 I am using the following code as I attempt to connect to my Outlook mail. Now, I must be doing something wrong because I try to get the inbox mails and I always get 0 mails (when this is not the case). This is my code Microsoft.Office.Interop.Outlook.NameSpace nameSpace = application.GetNamespace("MAPI"); nameSpace.Logon("", "", Missing.Value, Missing.Value); inboxFolder = nameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); Console.WriteLine("Folders:

Accessing an open Excel Workbook in C#

蹲街弑〆低调 提交于 2019-12-28 13:40:14
问题 I need to access an excel file that is already open. I thought just inspecting the .Workbooks property that it would be there but it isn't. What is the right way to get a reference to the open workbook? var app = new Microsoft.Office.Interop.Excel.Application(); // the count is 0 =( app.Workbooks.Count == 0; EDIT I can get a reference to the Excel Application via... app = (Excel.Application)Marshal.GetActiveObject("Excel.Application"); but app.Workbooks.Count is still 0 why isn't it able to

How to save workbook without showing save dialog with Excel interop?

扶醉桌前 提交于 2019-12-28 06:01:17
问题 I have to create a Console application that exports a DataSet to Excel. The problem is that it shouldn't pop up the save window, it should automatically create the Excel file. So far I have the following code, but I don't know how to make it save automatically. Would appreciate any help. public static void CreateWorkbook(DataSet ds, String path) { int rowindex = 0; int columnindex = 0; Microsoft.Office.Interop.Excel.Application wapp = new Microsoft.Office.Interop.Excel.Application();

How to save workbook without showing save dialog with Excel interop?

别等时光非礼了梦想. 提交于 2019-12-28 06:01:02
问题 I have to create a Console application that exports a DataSet to Excel. The problem is that it shouldn't pop up the save window, it should automatically create the Excel file. So far I have the following code, but I don't know how to make it save automatically. Would appreciate any help. public static void CreateWorkbook(DataSet ds, String path) { int rowindex = 0; int columnindex = 0; Microsoft.Office.Interop.Excel.Application wapp = new Microsoft.Office.Interop.Excel.Application();