开发者

application that will create an excel and read values from another excel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question

i need help to create a program that

  1. will create an excel file with just the press of a button and it will also fill开发者_JS百科 some cells
  2. then another button will open an openfile dialogue to choose another excel file from which the program must read some values, calculate
  3. return the results in the program or/and export them in a new excel

any ideas are welcome, please if anyone knows to tell me at least where to start from.

is C# and visual studio 2010 a good choice for a project like this or should i use another language?

if i decide to go on with c# where can i find a list of commands to manipulate excel from my program?

Thanks in advance for your time!!!


I learnt a clever trick for this a few years back ... i would guess that it still works today ...

using ole connections you can simply "connect" to an excel file as if it were a database (you can do this with csv files too) ...

first thing to do is connect to both your excel files:

using(OleDbCommand com = new OleDbCommand ("select * from sheetName", new OleDbConnection(excelFilePath)))
{
   com.Connection.Open();
   IDataReader reader = com.ExecuteReader();
   // do stuff with the sheet data
   com.Connection.Close();
}

if you wrap that up in a method or something you can have the select from sheet 1 and another method with an insert or update for sheet 2 (in other file).

Can't remember where i found this ... neat though right :)

... so bottom line ...

treat your excel files like a database :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜