Click here to Skip to main content
12,243,534 members (36,660 online)
Click here to Skip to main content
Add your own
alternative version


103 bookmarked

Display MS Excel Sheets and Charts in ASPX Pages using C#

, 8 Nov 2006
Rate this:
Please Sign up or sign in to vote.
How to display an Excel sheet with its format and also charts in an ASPX page.


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.

Sample Image - ExcelShtAndChrt-In-aspx.jpg

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 Color.

/// <span class="code-SummaryComment"><SUMMARY>

The format details also include conversion of Excel horizontal alignment to .NET horizontal alignment:

/// <span class="code-SummaryComment"><SUMMARY>

Next is the conversion of Excel vertical alignment to .NET vertical alignment:

/// <span class="code-SummaryComment"><SUMMARY>

Chart View

Sample Image - ExcelShtAndChrt-In-aspx.jpg

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

  1. 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 TableRow).
  2. 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.

Forthcoming Plans

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Gnanandam Gopalan
Web Developer
India India
I am basically a C++ Programer done various project for Industrial Automation Activities.

You may also be interested in...

Comments and Discussions

GeneralRe: Problem in Displaying Excel Pin
snpcrud20-Dec-10 11:11
membersnpcrud20-Dec-10 11:11 
GeneralRe: Problem in Displaying Excel Pin
matrixology27-Nov-11 19:25
membermatrixology27-Nov-11 19:25 
GeneralRe: Problem in Displaying Excel Pin
snpcrud28-Nov-11 10:59
membersnpcrud28-Nov-11 10:59 
GeneralRe: Problem in Displaying Excel Pin
matrixology28-Nov-11 18:04
membermatrixology28-Nov-11 18:04 
GeneralNeed same code for VB.Net Pin
AnOnYmOuS_S24-Nov-09 3:18
memberAnOnYmOuS_S24-Nov-09 3:18 
GeneralCool application Pin
Lulama8-Mar-09 22:55
memberLulama8-Mar-09 22:55 
GeneralNice Application Pin
atheequepasha12-Nov-08 19:14
memberatheequepasha12-Nov-08 19:14 
Generaltemp gif file Pin
Member 391781022-Sep-08 6:24
memberMember 391781022-Sep-08 6:24 
GeneralLoading takes a long time Pin
Agnes Loyola16-Jul-08 4:29
memberAgnes Loyola16-Jul-08 4:29 
GeneralDisplay Excel inside the aspx page Pin
Agnes Loyola11-Jul-08 21:56
memberAgnes Loyola11-Jul-08 21:56 
GeneralTo display excel sheet Pin
Agnes Loyola11-Jul-08 2:24
memberAgnes Loyola11-Jul-08 2:24 
AnswerRe: To display excel sheet Pin
Gnanandam Gopalan11-Jul-08 3:46
memberGnanandam Gopalan11-Jul-08 3:46 
GeneralRe: To display excel sheet Pin
Agnes Loyola11-Jul-08 4:06
memberAgnes Loyola11-Jul-08 4:06 
Questionhow to load the Excel sheet in the page load Pin
Agnes Loyola10-Jul-08 2:05
memberAgnes Loyola10-Jul-08 2:05 
AnswerRe: how to load the Excel sheet in the page load Pin
Gnanandam Gopalan10-Jul-08 2:14
memberGnanandam Gopalan10-Jul-08 2:14 
GeneralThanks for nice Example, But I am getting one errors [modified] Pin
Member 204885626-Feb-08 21:50
memberMember 204885626-Feb-08 21:50 
GeneralNice Pin
Pooya Musavi19-Oct-07 9:00
memberPooya Musavi19-Oct-07 9:00 
GeneralRe: Nice Pin
Gnanandam Gopalan22-Oct-07 0:11
memberGnanandam Gopalan22-Oct-07 0:11 
QuestionVB Version Pin
smcirish17-Oct-07 5:19
membersmcirish17-Oct-07 5:19 
GeneralProblem in Horizontal Alignment. Pin
Anees Mhd25-Sep-07 2:13
memberAnees Mhd25-Sep-07 2:13 
GeneralRe: Problem in Horizontal Alignment. Pin
Anees Mhd25-Sep-07 18:48
memberAnees Mhd25-Sep-07 18:48 
GeneralYour Application is greate but ... Pin
hishammm17-May-07 3:57
memberhishammm17-May-07 3:57 
GeneralRe: Your Application is greate but ... Pin
Gnanandam Gopalan21-May-07 0:15
memberGnanandam Gopalan21-May-07 0:15 
GeneralRe: Your Application is greate but ... Pin
shahzad_mca11-Oct-07 7:20
membershahzad_mca11-Oct-07 7:20 
QuestionExcel process not closed Pin
sandu200415-Nov-06 21:36
membersandu200415-Nov-06 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 9 Nov 2006
Article Copyright 2006 by Gnanandam Gopalan
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid