开发者

Export OracleDataReader to Excel in C#

I have a code like this,

string ConnectionString = ConfigurationManager.ConnectionStrings["ora"].ConnectionString;

OracleConnection conn = new OracleConnection(ConnectionString);

string sql = @"SELECT DISTINCT(B.MUS_K_ISIM), A.HESAP_NO
  FROM S_TAKIP_MUSTERI A, S_TEKLIF B
  WHERE A.HESAP_NO = B.HESAP_NO
  ORDER BY B.MUS_K_ISIM";

conn.Open();

OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = System.Data.CommandType.Text;

OracleDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

How can i export coming so开发者_Go百科me information from DataReader to Excel? What i want, When i click the button, Export the Excel from DataReader.


You could use Microsoft.Office.Interop.Excel to create an instance of excel and then go through and populate the cells in the spreadsheet with the data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜