Solved

Using C# or VB.net to query 1 Excel Spreadsheet then Write result to another.

Posted on 2012-04-06
3
545 Views
Last Modified: 2012-04-09
Hi everyone,

I really need to be able to read the data from three columns in one Excel Spreadsheet (c:\SpreadSheet_1.xls)

then create a New Spreadsheet (c:\SpreadSheet_2.xls) on the fly.

Then write the Spreadsheet 1 queried data ("select Row,Total,Difference from [Archive$]Where Total=104") to Spreadsheet 2


Please note , I'm using Visual Studios 2008 (not sure if that matters).

Thank you in advance for your help on this.

Please provide a full coded solution to this problem.
0
Comment
Question by:NeallyNeal
3 Comments
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 250 total points
ID: 37819587
What code do you have?

EE is not here to build full applications but rather to help with questions you have with your efforts.

One thing to try to see the basic code is to record a macro
Start recording
Create the new spreadsheet
Copy one cell/row
Paste to the new spreadsheet

Basic algorithm for the program

Setup the data connections to the existing spreadsheet
Setup the SQL string
Open the connection
Create the recordset

Create the new spreadsheet
Set ROW = 1   or whatever you want as the first row
While there is data in the recordset
    NewXls.cells(row,1) = RS.Fields("Row")
    NewXls.cells(row,2) = RS.Fields("Total")
    NewXls.cells(row,3) = RS.Fields("Difference")
    Row = Row + 1
Wend

Close the recordset
Close the connection
Save the new spreadsheet

mlmcc
0
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 250 total points
ID: 37820710
0
 

Author Closing Comment

by:NeallyNeal
ID: 37824322
Thanks everyone , I was really stuck on how to write back to excel. Thanks for your help on this one.

Thanks again.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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