Solved

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

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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