ASP.NET Excel Viewer Control
How to open, view a Excel .xlsx document online in web browser without Office, interop using C# ASP.NET
How to read, view, edit Microsoft Office Excel in web browser using C# ASP.NET PDF Viewer control.
EdgePDF is an ASP.NET PDF viewer and editor web control. You could also view Microsoft Office Excel file in web browser with EdgePDF using C# ASP.NET
- Open, read a Excel file from server side file system
- EdgePDF will automatically convert loaded Excel Workbook or selected Sheets to PDF document in ASP.NET
- View, comment Excel file online in web browser
How to view a Excel file programmatically in asp.net using C#
Preparation
To run the following tutorial successfully, we need the following setup ready.
- Install EdgePDF demo project in IIS
- A demo Office Excel document in folder C:\temp\excel-1.xlsx
How to read, view a Office Excel file online in web browser in ASP.NET C#?
The following steps and C# demo source code will help to setup a demo ASP.NET project, which allows you to read, view a Microsoft Excel file in web browser using ASP.NET C# code.
After you have completed the following guide, you can open, view a Office Excel file online in web browser through url (a sample url
http://localhost:56643/?yourtarget=excel-1.xlsx)
- Open file UserCommandProcessHandler.ashx from {EdgePDF demo project}/RasterEdge_Resource_Files/
- Go to method FileProcess()
- Create a new byte[] object with viewed Excel file in byte array
- Call method REProcessControl.PageLoadFile() to load, view Excel file in EdgePDF. The Excel file (excel-1.xlsx) has been converted into PDF file and rendered in EdgePDF online in web browser
public override PDFWebDocument FileProcess()
{
HttpRequest request = this.Context.Request;
if (!String.IsNullOrEmpty(request.QueryString["yourtarget"]))
{
String docid = request.QueryString["yourtarget"];
byte[] dataBytes = System.IO.File.ReadAllBytes(@"C:\\temp\" + docid);
return REProcessControl.PageLoadFile(request, this.Manager, dataBytes, docid);
}
else
{
Logger.Log(">>> Unknown load file mode. Load default file defined in Web.config.", LogType.DEBUG);
// load default file. defined in Web.config
return REProcessControl.PageLoadFile(request, this.Manager, "", LoadType.Server);
}
}