Open excel word document from asp net in office web apps to edit

How to Open Excel Word from ASP.NET in Web Apps to Edit

ASP.NET is a popular programming language used for developing web . One requirement in web development is the to open and edit Excel or Word documents from the web . In this article, we will explore how to achieve this using Office Web Apps.

Office Web Apps is a web-based version of Microsoft Office that allows users to view, edit, and share Office documents online. It provides a convenient way to collaborate on documents without the need for installing the desktop version of Office.

To open an Excel or Word document from ASP.NET in Office Web Apps, we can make use of the Office Web Apps URL scheme. This scheme allows us to construct a URL that points to the document we want to open in Office Web Apps.

First, let's assume that we have a web application with a that triggers the opening of an Excel document. When the button is clicked, we can use the following code to construct the Office Web Apps URL:


protected void OpenExcelDocument_Click(object sender, EventArgs e)
{
    string documentUrl = "https://example.com/documents/mydocument.xlsx";
    string officeWebAppsUrl = "https://office.example.com/we/ExcelEditor.aspx?edit=1&src=" + HttpUtility.UrlEncode(documentUrl);
    Response.Redirect(officeWebAppsUrl);
}

In the code above, we first specify the URL of the Excel document we want to open. Then, we construct the Office Web Apps URL by appending the document URL as a parameter. The “edit=1” parameter indicates that we want to open the document in edit mode.

When the user clicks the button, the web application will redirect the user to the Office Web Apps URL, which will open the Excel document in the browser. The user can then make changes to the document and save it back to the server.

Similarly, we can open a Word document using the Office Web Apps URL scheme. Here's an example:


protected void OpenWordDocument_Click(object sender, EventArgs e)
{
    string documentUrl = "https://example.com/documents/mydocument.docx";
    string officeWebAppsUrl = "https://office.example.com/we/WordEditor.aspx?edit=1&src=" + HttpUtility.UrlEncode(documentUrl);
    Response.Redirect(officeWebAppsUrl);
}

In this example, we construct the Office Web Apps URL for a Word document. The process is similar to opening an Excel document, but we use the “WordEditor.aspx” endpoint instead.

By using the Office Web Apps URL scheme, we can easily open and edit Excel or Word documents from our ASP.NET web application. This provides a seamless integration with Office Web Apps and allows users to collaborate on documents without leaving the web application.

In conclusion, opening Excel or Word documents from ASP.NET in Office Web Apps is achievable by constructing the appropriate Office Web Apps URL. By leveraging this URL scheme, we can provide a seamless editing experience for users directly our web application.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents