ASP.NET - Excel like interface in asp.net

Asked By Tridip Bhattacharjee on 15-Jul-09 01:14 AM
please inform me if is there any open source project called excel like interface in web developed by asp.net. i saw google developed a excel in web. that is very good & accurate. so please inform me is there any excel like interface or gridview developed by .net.

Displaying an Excel spreadsheet is not too much

Venkat K replied to Tridip Bhattacharjee on 15-Jul-09 02:04 AM
of an issue. Providing Excel interactivity in a spreadsheet on a Web page is another matter. I'm guessing that to have any interactivity at all the sheet would have to be set up as a datasource and managed by ASP/ASP.NET.

What I'm wondering about, though, and I've never tried this so don't take this as gospel, is trying to have actual Excel functionality (formula resolution, etc.) in an online spreadsheet.
There are commercial products that will do the job. See http://www.spreadsheetconverter.com/l_excel.htm?gclid=CPzI0K7H-pcCFQITswodaw2sCw, but note that this is a conversion process, so you will probably not be able to use the result in a local copy of Excel.

The Interoperability services make it very

Venkat K replied to Tridip Bhattacharjee on 15-Jul-09 02:07 AM

easy to work with COM Capable Applications such as Word and Excel.

You can refer the Excel.dll into your application and create the excel file.

Here is the CODE:

1. CREATING NEW EXCEL.APPLICATION:

Application exc = new Application();
if (exc == null) {
Console.WriteLine("ERROR: EXCEL couldn't be started");
return 0;
}

2. TO MAKE APPLICATION VISIBLE:

exc.set_Visible(0, true);

3. TO GET THE WORKBOOKS COLLECTION:

Workbooks workbooks = exc.Workbooks;
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet, 0);

4. TO GET THE WORKSHEETS COLLECTION:

_Worksheet worksheet = (_Worksheet) sheets.get_Item(1);
if (worksheet == null) {
Console.WriteLine ("ERROR in worksheet == null");
}

5. TO SET THE VALUE FOR CELL:

Range range1 = worksheet.get_Range("C1", Missing.Value);
if (range1 == null) {
Console.WriteLine ("ERROR: range == null");
}
const int nCells = 1;
Object[] args1 = new Object[1];
args1[0] = nCells;
range1.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, range1, args1);

The Example:

using System;
using System.Reflection; // For Missing.Value and BindingFlags
using System.Runtime.InteropServices; // For COMException
using Excel;
class AutoExcel
{
public static int Main()
{
Application exc =
new Application();
if (exc == null)
{
Console.WriteLine("ERROR: EXCEL couldn't be started!");
return 0;
}
exc.set_Visible(0,
true);
Workbooks workbooks = exc.Workbooks;
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet, 0);
Sheets sheets = workbook.Worksheets;
_Worksheet worksheet = (_Worksheet) sheets.get_Item(1);
if (worksheet == null)
{
Console.WriteLine ("ERROR: worksheet == null");
}
Range range1 = worksheet.get_Range("C1", Missing.Value);
if (range1 == null)
{
Console.WriteLine ("ERROR: range == null");
}
const int nCells = 1;
Object[] args1 =
new Object[1];
args1[0] = nCells;
range1.GetType().InvokeMember("Value", BindingFlags.SetProperty,
null,range1, args1);
return 100;
}
}

Now let us observe how to send a single dimension array to Excel:
It is similar to set the value for the cell. Only change is we use array as args2[0] = array2.

const int nCell = 5;
Range range2 = worksheet.get_Range("A1", "E1");
int[] array2 = new int [nCell];
for (int i=0; i < array2.GetLength(0); i++) {
array2[i] = i+1;
}
Object[] args2 =
new Object[1];
args2[0] = array2;
range2.GetType().InvokeMember("Value", BindingFlags.SetProperty,
null, range2, args2);

The OutPut:




Cheers!

Excel like interface in asp.net

mv ark replied to Tridip Bhattacharjee on 15-Jul-09 03:15 AM
You can also check these open source projects related to building Excel-like interfaces -
http://sourceforge.net/projects/zss/
http://sourceforge.net/projects/simplsheet/
http://sourceforge.net/search/?type_of_search=soft&words=spreadsheet
Google Spreadsheets Data API  - http://code.google.com/apis/spreadsheets/overview.html
RE
Ravenet Rasaiyah replied to Tridip Bhattacharjee on 15-Jul-09 03:45 AM
Hi

I have worked and write as article in codegain.com. take look at this.

http://www.codegain.com/index.php?option=com_content&view=article&id=155:upload-excel-file-to-server-and-look-preview-in-aspnet&catid=62:miscellaneous&Itemid=139

thank you