?
Solved

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

Posted on 2012-04-06
3
Medium Priority
?
557 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 1000 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 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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