The purpose of this article is to show how to display the exact values in an Excel sheet, with its comments, in an aspx page. The code-behind file is in C#. The method shown here helps to display an Excel sheet with its formatting including the font, color, alignment etc. This will be very useful for developers who do MS Office automation. The pre-requisites are that in the DCOM CONFIG your Excel application should be given permissions to be accessed and loaded in the server system.
Conversion of the Excel formats require only a few lines of code. The format details include conversion of Excel attributes to .NET attributes, like Excel color to .NET
The format details also include conversion of Excel horizontal alignment to .NET horizontal alignment:
Next is the conversion of Excel vertical alignment to .NET vertical alignment:
The selection of sheet name will be displayed by "*" delimited. This is because "*" cannot be accepted in Worksheet names.
Problems faced in displaying a Worksheet
- Merging of rows is not included because it needs to find out the logic of combining rows (whereas columns merge is possible on insertion as a
- The chart object is a GIF file, it is generated and put in the server and displayed in an ASPX page. (Here, there is no need to get the chart object inside the page). This is a preliminary trial to put a chart on an ASPX page.
To display all types of MS Office files in ASPX pages and to produce intelligence on data values etc.
Points to Consider
This meets the business requirements with data display alone and no activities processed. A template of Excel with cell references to other Excel files will give a real time stylesheet data report.
This page will be enhanced by including several functionalities of MS Excel.