Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Best way to perform numerous calculations on data from asp.net webpage -- updated with more info

Posted on 2012-04-04
3
Medium Priority
?
191 Views
Last Modified: 2012-06-21
Afternoon All,

My current website project will be created from VS2010Express C#.  
Step 1 would be to read excel contents from users pc, done by using OleDB to Read Excel
         
The goal is to perform numerous and extensive statistic/financial  calculations on this data.  Based on all the calculations I perform the end result is showing charts and statistics on website.

So far the data is in a dataset.  In terms of funtionality... I'm looking to search through rows/columns for specific items... add columns... grab certain rows or columns....
what would offer more functionality for me.  Doing all my calculations from a datatable... or transferring to an array and doing calc there??

appreciate everyones advice and as I'm sure you can tell I'm pretty new to this

thanks
0
Comment
Question by:solarissf
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 2000 total points
ID: 37814143
You want to read an Excel workbook from your client's workstation, perform calculations using its data, then display the results?  This can be done.  It can't all be done on the client workstation, however, without processing the workbook file as XML, and this is not always possible (earlier versions didn't store workbooks as .DOCX).  The best and most consistent way of doing this is to upload the workbook to your server, process the caluclation there, then return the results in a new Web page.  Does this sound like what you might want to do?
0
 

Author Comment

by:solarissf
ID: 37814352
Yes, I do want to read an excel workbook from a user logging into my website.  I think I have this part successfully done by using the below code.

Unfortunately I do not know what XML is.  Based on how I think this works is based on the below code I have already stripped the users excel sheet and now have the info in my dataset.  Which I was planning on putting in a datatable to run my calculations.  Is there anything wrong with my plan of attack?



using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.OleDb;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        string path =@"C:\Documents and Settings\sforero\Desktop\peer.xlsm";

        string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;"; 

        //string strConn = "Provider= Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + "; " + "Extended Properties=Excel 8.0;";

        OleDbConnection conn = new OleDbConnection(connstr);

        string strSQL = "select * from [Data$]";

        OleDbCommand cmd = new OleDbCommand(strSQL, conn);

        DataSet ds = new DataSet();

        OleDbDataAdapter da = new OleDbDataAdapter(cmd);

        da.Fill(ds);

        GridView1.DataSource = ds;

        GridView1.DataBind();

 

 

Open in new window

0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 37823658
Sorry for the delay in getting back to you, but you certainly took my suggestion and ran with it.  Glad it worked for you, and thanks for the points.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question