开发者

Export OracleDataReader to Excel in C#

开发者 https://www.devze.com 2023-01-31 06:29 出处:网络
I have a code like this, string ConnectionString = ConfigurationManager.ConnectionStrings[\"ora\"].ConnectionString;

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

精彩评论

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