Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open excel/word document from ASP.NET in Office Web Apps to edit?

I have an ASP.NET web application hosted on Azure for use internally by our company. On this site, I keep a few spreadsheets and word documents that I would like employees of the company to be able to click on, and have them open directly in Microsoft's Office Web Apps where they can view and edit them. This is very similar to being logged in to SkyDrive and clicking on the file. Here is what I'm looking for:

Requirements:

  1. The user should be able to edit the documents directly in their browser and save them.

  2. My ASP.NET web application should be able to obtain a list of the documents and display them.

  3. My ASP.NET web application should be able to allow users to upload new documents

  4. The user should not have to login more than once (i.e., they should only have to login to our internal ASP.NET web application).

What I've tried: I cannot seem to figure out how to do this though, here are a couple things I've thought of and tried.

  • Using SkyDrive + API: Keeping the documents in SkyDrive, sharing them across employees, and using the SkyDrive/Live API to log them in and open the documents. This doesn't work for us because SkyDrive does not allow you to share documents without making them completely public (i.e., anyone with the link can view/edit them). They must be kept internally.

  • Using SkyDrive Pro: SkyDrive pro has the benefit of better sharing credentials. You can share something with a particular user, and only that user (i.e., they need to be logged in to view/edit it). Unfortunately, SkyDrive Pro is not supported in the Live API so I cannot access the files directly from my ASP.NET application.

  • Sharepoint: I think a possibility is SharePoint by keeping the documents in a Document Library and a using SharePoint Client. I think I can specify user credentials to obtain a list of documents in the Document Library, but I'm not sure that I can "open" one of those documents in the Office Web within their without bothering them to login to the SharePoint site again, and again. Especially if their own personal login times out? I have to re-enter my SharePoint password constantly using SharePoint in my browser, I do not want this when integrating with our ASP.NET app.

It would be great if Microsoft integrated the Office Web Apps in to Azure, potentially allowing you to open Excel and Word documents stored in Blob Storage. But that's not possible.

Anyone have any other ideas?

like image 590
gnychis Avatar asked Dec 13 '13 18:12

gnychis


2 Answers

This is an old technology, and it only works in Internet explorer, but I think it is elegant in the way it works. Notice it is deprecated.

You start by installing Office Web Components OWC, a google search should give you that. Then for spreadsheets you add an object like this

<object classid="clsid:0002E551-0000-0000-C000-000000000046" id="Spreadsheet1" width="1100" height="900">
                <param name="DataType" value="XMLURL" />
                <param name="AllowPropertyToolbox" value="1" />
                <param name="AutoFit" value="1" />
                <param name="CalculationPoco" value="-4105" />
                <param name="Caption" value="" />
                <param name="DisplayColumnHeadings" value="0" />
                <param name="DisplayGridlines" value="-1" />
                <param name="DisplayHorizontalScrollBar" value="1" />
                <param name="DisplayOfficeLogo" value="0" />
                <param name="DisplayPropertyToolbox" value="0" />
                <param name="DisplayRowHeadings" value="0" />
                <param name="DisplayTitleBar" value="1" />
                <param name="DisplayToolbar" value="0" />
                <param name="DisplayVerticalScrollBar" value="-1" />
                <param name="DisplayWorkbookTabs" value="1" />
                <param name="EnableEvents" value="-1" />
                <param name="MaxHeight" value="90%" />
                <param name="MaxWidth" value="90%" />
                <param name="MoveAfterReturn" value="-1" />
                <param name="MoveAfterReturnDirection" value="-4121" />
                <param name="RightToLeft" value="0" />
                <param name="ScreenUpdating" value="1" />
                <param name="EnableUndo" value="1" />

                <p>OWC required.</p>
            </object>

And then you can get the object via javascript and manipulate values to and from a database, or whatever you want.

    exlObj = document.all.Spreadsheet1;
    exlObj.XMLURL ="/Excel/Whatever.xml";
    exlObj.ActiveSheet.Unprotect();
    exlObj.Range('Sheet1!$A1').Value = 5;

Notice that when you set the xml-url then you have to have the excel saved in a 2003 xml format. I wonder if it exits as a new technology.

But it is deprecated etc. So I guess a more pure solution also must exist.

like image 68
Thomas Koelle Avatar answered Sep 17 '22 03:09

Thomas Koelle


Take a look at Office Web Apps and in particular the section on deploying the Office Web Apps Server.

At the bottom of the overview page it states:

Office Web Apps Server provides a page at the address http://OfficeWebAppsServername/op/generate.aspx that you can use to generate links to publicly available documents that have UNC or URL addresses. When a user selects a generated URL, Online Viewers enable Office Web Apps Server to get the file from its location and then render it by using Office Web Apps.

like image 28
Steve Avatar answered Sep 17 '22 03:09

Steve