Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2012-04-06
3
Medium Priority
?
566 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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…

610 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