Click here to Skip to main content
11,704,768 members (60,317 online)
Click here to Skip to main content

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

, 8 Nov 2006 160.7K 5.5K 103
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.

Introduction

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>
</span>

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

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

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

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

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.

Summary

This page will be enhanced by including several functionalities of MS Excel.

License

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

Share

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

 
GeneralNo display for image Pin
Member 778553224-May-11 4:51
memberMember 778553224-May-11 4:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web04 | 2.8.150819.1 | Last Updated 9 Nov 2006
Article Copyright 2006 by Gnanandam Gopalan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid