How to add plugin for Excel Online? - c#

I would like to use Excel functionality from a browser. I currently have an excel based Microsoft office application. It adds an icon to the ribbon and does C# based custom application logic to communicate to a database server.
Since it requires application releases for any changes in the schema I am curious if I can convert this into an web application and still benefit from Excel's built in functionality.
I am expecting this to be possible since Microsoft Excel Online is run inside a browser. My question is, is it possible to add plugin to such online excel document? If yes, any example would be much appreciated.

You absolutely can, and depending on approach you can do so with nothing more than a VSTO project template. This is little more than a ClickOnce application. This can launch a browser within a window to perform the logic.
You may use the Office Interop assemblies to decouple your application from Office apps, yet still communicate easily. Make sure you set Embed Interop Assemblies to true once added as a reference.
For those using Office in the browser, it seems as though Microsoft is shifting into CSOM/JSON/REST, meaning this solution is coded entirely differently than COM. This should help you get started:
https://msdn.microsoft.com/EN-US/library/office/dn268594.aspx.

Related

Create Excel file in Universal Windows App or in Window Store App

I am learning to develop universal windows 10 app using visual studio 2015. I want to implement a function to create an Excel file then write data in this excel file, in my app. I try to develop it in C# adding reference Microsoft.Office.Interop.Excel.
Generate Error: Missing compiler required member System.Runtime.InteropServices.LCIDConversionAttribute
Search this error and find windows store apps doesn't support Microsoft.Office.Interop.Excel.
I am not able to create Excel file. I do not want to use any commercial library (like syncfusion) for this.
How Can I create Excel file in Universal Windows App or in Window storeApp? Please request to tell me any solution.
Thanks
You will not be able to use the Excel interop libraries in a Windows 10 Universal App. The interop is only available on Windows Desktop, and also requires a dependency on another software (Excel) to be installed on the machine. Both of those are somewhat against the spirit (and more importantly, the technology) of the Universal app.
That being said: If all you need is to generate a file (rather than display it), the general solution is to use something like the OpenXML SDK, which also has the advantage of not requiring Excel on the running machine. Admittedly, the OpenXML SDK doesn't look like it's available for the Universal platform either (see here), but you may find a 3rd-party component that is. Or, if you are OK with requiring internet connectivity, you could create a web service that you send data to, and that processes it and creates the file on your behalf (quite a common pattern, with the additional advantage of protecting your intellectual property behind your own web server). The Interop libraries are much more about automating user actions, are were initially build more for use with VBA/VSTO/COM add-ins, where the interactivity was very much part of the experience. If all you're doing is using the Interop to drive the creation of documents, OpenXML would be the better way to go.
Hope this helps!

Editing Documents (.doc) in Browsers

I've been developing a web application with asp.net webforms and in this app I have some documents (.doc, .docx, .rtf files), and my client want to edit these files on browser, they want to open a document in an editor, edit, save it on server (without downloading) and close it. I know it's difficult but I would like to know if it's possible or if is there any easy way to do it. We find something like SkyDrive of Microsoft.
PS: We can pay for components if you can suggest something that really works.
Thank you!
IF the clients have Office installed:
I would recommend http://www.webdavsystem.com/server - this allows you to build a "virtual filesystem" (WebDAV which is based on HTTP) which Office can access thus allowing the client to open/edit/save a document (DOCX etc.) via HTTP(S)... it is pure .NET, integrates nicely with ASP.NET and has even a JavaScript accessible API... esp. the upcoming V 3 comes with a wizard which allows you easily to add that funcionality to your ASP.NET application... (just a happy customer, not affilliated).
IF the clients don't have Office installed then it gets tricky:
To really fully support you would need some sort of Silverlight/Flash/ActiveX/JavaApplet which runs in the clients browser and supports the needed editing features...
I am not aware of such production-quality components except the ones from Microsoft - see http://www.microsoft.com/en-us/office365/online-software.aspx
You could integrate them into your web application although they won't offer the full Office feature set in the browser...

Accessing Sharepoint from a WebApplication

I'm currently investigating SharePoint for our company as a means to make Excel processing accessible through our web application without relying on the Office Interop DLL files. (our sysadmin doesnt want to install Office on the production server, for good reason)
I'm aware that Sharepoint has an Excel Webservice that can be enabled and used by the application. The problem, if it is a problem, is that I need to make a class that wraps all the logic for transforming an Excel into HTML.
So I need to add the references to this webservice to the application.
But what if we need to deploy the application with a customer that has no SharePoint server available, will this cause a problem in the application? We will use checks to make stuff visible and invisible depending on whether a parameter is set, but I'm looking for a means to ensure that I can for example add the required references at runtime when I need them for Sharepoint.
I hope the question is clear.
I'm not sure I understand you completely, but if you're just wondering about changing the URL of a web service(From say http://companyA.co/service.svc?wsdl to http://compB.co/serv.svc?wsdl), depending on where it is, that's easy as pie in .Net, basically just:
service.URL = "http://localhost:51112/Service1.svc?wsdl";

Creating Outlook Email Draft via C# Application

I am in the estimating phase of a project, and one requirement is that my application will create draft emails (with attachments) in MS-Outlook, which the user can then review and send. The app is written in WPF.
The clients will have either Outlook 2003 or Outlook 2007. The files that need to be attached will already exist on the file system when the drafts are generated.
I have done some initial research, but would like to get some opinions from people who have first-hand experience.
Questions:
What tool would you use to
accomplish this?
Will there need to be separate code for Outlook 2003 vs. 2007?
In general, using whatever tools are recommended, is this a relatively straightforward problem to solve?
Thanks for any insight.
a c# wpf application should be able to do the job just fine, you just need to add the outlook libraries in your references and you can work with outlook directly from your WPF app.
I only write for 2003, but I do know that 2003 and 2007 use different libraries. There's probably a clever way check what version of outlook is being and use the methods from the correct library, but it will take some work to figure out.
It's relatively straight forward except for the security prompt you'll get if you send the email. But I suppose if they are going to have them review it first, you should be able to generate the email, open it in an outlook window for them to review, and have them click the send button.
Would you be able to use WebDAV and then simply create the message and drop it in the users' Drafts folder?
Basically, you'll end up using something like this product (or you can roll your own) to create and save the message. You might be able to find an open source solution.
I think there are a couple tools you could use here:
Visual Studio Tools for Office (VSTO)
total control over Outlook
version of Outlook may matter
Assuming you have Exchange, you could use WebDAV, Exchange's XML methodology
version of Outlook wouldn't matter here
Use the built in mailto: functionality
lots of results for using this to include attachments - Google Results
would work for email apps other than Outlook
this probably would be quickest solution, but the least control over the output
An Outlook Add-in is probably a good way to go for this application. The tool set you need is Visual Studio Tools for Office (VSTO). With the possible exception of the WPF requirement, this is pretty straightforward.
Be aware that the API's and the VSTO tools evolved between 2003 and 2007. You can potentially have a single code base but you will need to write for the least common denominator, 2003.
2003 and 2007 also have different Primary Interop Assemblies, the components that bridge the gap between your .NET code and the native code COM interfaces that Outlook has. This can be a challenge when it comes to building and installer for your add-in. If you want your add-in to install the PIA's, you need to detect the version of Office and install the appropriate version, or, more commonly, just build two different installers.
I've never tried to do WPF inside Outlook 2003. There may be some issues with it but I don't know.

.NET: If my .NET automates Office, does the customer have to have Office installed?

If i create a program, which in one small out of the way area, uses Excel automation:
will the application fail when Excel is needed
or will the application fail to start?
Update
Let me ask the same question, but in a more drawn out way:
Will the application be usable by
99.9% of the users who never use the feature that requires Excel
0% of the users, since Excel is not installed.
Let me ask the same question another way:
Will an application fail to initialize that references the COM interop dll's?
Let me ask the same question another way:
Will an application that doesn't use Excel, but references the COM interop DLL's fail to start?
Let me ask the same question another way:
Will an application that doesn't use Excel be usable if Excel is not installed, if that application has a dependancy on the Office Primary Interop dlls?
Let me ask the same question another way:
If my application doesn't use Excel, does the user have to have Excel installed?
The code will properly execute until it tries to make a call to the automation libraries, at that time it will generate an exception.
I have an app that uses Excel automation and I can definitively say that it will fail at runtime, not at load time. In fact we check to see if it's even installed and only show the "Show data in Excel" button if we find it (but the PIAs are deployed to all installs).
If you automate Office... you gotta have Office!
Having said that, the answer changes if you twist the question into: Can I create an Excel spreadsheet without having Excel on the client?
There are many third-party controls to do this; you can write directly to the MS SpreadML XML spec (http://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx; or use third-party libraries that do (like http://www.carlosag.net/Tools/ExcelXmlWriter/).
I think it will fail at runtime, because the Interop Assemblies should be able to load without the COM-Components available on the clients system.
UPDATE: Runtime should mean when you need it!
Using COM in Win32, it will fail when needed.

Categories