Solved

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

Posted on 2012-04-06
3
543 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now